Commit a458b90d by louyihua

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.
parent a795edcf
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment