From a458b90d37297dfa86e9b3df46691efed54fcbac Mon Sep 17 00:00:00 2001 From: louyihua Date: Wed, 19 Mar 2014 10:30:25 +0800 Subject: [PATCH] Fix incorrect parse of url in video_module.py Sometimes the video url may look like 'http://abc.com/path/video.mp4?xxxx'. (For example, the Windows Azure's media service will offer such type of url.) The original code in video_module.py will produce 'mp4?xxxx' instead of 'mp4' as the extension of a filename for such type of url, and therefore the video will be non-playable. The fix here uses the built-in urlparse module to retrive only the path component from a url and therefore the extension 'mp4' will be correctly fetched. --- common/lib/xmodule/xmodule/video_module/video_module.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/video_module/video_module.py b/common/lib/xmodule/xmodule/video_module/video_module.py index 3b5bcfac2e..c2067cc026 100644 --- a/common/lib/xmodule/xmodule/video_module/video_module.py +++ b/common/lib/xmodule/xmodule/video_module/video_module.py @@ -43,6 +43,7 @@ from .video_utils import create_youtube_string from xmodule.modulestore.inheritance import InheritanceKeyValueStore from xblock.runtime import KvsFieldData +from urlparse import urlparse log = logging.getLogger(__name__) @@ -253,7 +254,8 @@ class VideoModule(VideoFields, XModule): track_url = None transcript_download_format = self.transcript_download_format - get_ext = lambda filename: filename.rpartition('.')[-1] + # Prevent incorrectly parsing urls like 'http://abc.com/path/video.mp4?xxxx'. + get_ext = lambda filename: urlparse(filename).path.rpartition('.')[-1] sources = {get_ext(src): src for src in self.html5_sources} if self.download_video: