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.
This commit is contained in:
louyihua
2014-03-19 10:30:25 +08:00
parent a795edcf22
commit a458b90d37

View File

@@ -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: