Fixes for MOB-836 and MOB-766 and MA-96.
This commit is contained in:
@@ -592,3 +592,17 @@ class VideoTranscriptsMixin(object):
|
||||
raise ValueError
|
||||
|
||||
return content, filename, Transcript.mime_types[transcript_format]
|
||||
|
||||
def get_default_transcript_language(self):
|
||||
"""
|
||||
Returns the default transcript language for this video module.
|
||||
"""
|
||||
if self.transcript_language in self.transcripts:
|
||||
transcript_language = self.transcript_language
|
||||
elif self.sub:
|
||||
transcript_language = u'en'
|
||||
elif len(self.transcripts) > 0:
|
||||
transcript_language = sorted(self.transcripts)[0]
|
||||
else:
|
||||
transcript_language = u'en'
|
||||
return transcript_language
|
||||
|
||||
@@ -152,12 +152,7 @@ class VideoModule(VideoFields, VideoTranscriptsMixin, VideoStudentViewHandlers,
|
||||
transcript_language = u'en'
|
||||
languages = {'en': 'English'}
|
||||
else:
|
||||
if self.transcript_language in self.transcripts:
|
||||
transcript_language = self.transcript_language
|
||||
elif self.sub:
|
||||
transcript_language = u'en'
|
||||
else:
|
||||
transcript_language = sorted(self.transcripts.keys())[0]
|
||||
transcript_language = self.get_default_transcript_language()
|
||||
|
||||
native_languages = {lang: label for lang, label in settings.LANGUAGES if len(lang) == 2}
|
||||
languages = {
|
||||
@@ -177,7 +172,6 @@ class VideoModule(VideoFields, VideoTranscriptsMixin, VideoStudentViewHandlers,
|
||||
sorted_languages = OrderedDict(sorted_languages)
|
||||
return track_url, transcript_language, sorted_languages
|
||||
|
||||
|
||||
def get_html(self):
|
||||
transcript_download_format = self.transcript_download_format if not (self.download_track and self.track) else None
|
||||
sources = filter(None, self.html5_sources)
|
||||
@@ -201,16 +195,22 @@ class VideoModule(VideoFields, VideoTranscriptsMixin, VideoStudentViewHandlers,
|
||||
# internally for download links (source, html5_sources) and the youtube
|
||||
# stream.
|
||||
if self.edx_video_id and edxval_api:
|
||||
val_video_urls = edxval_api.get_urls_for_profiles(
|
||||
self.edx_video_id, ["desktop_mp4", "youtube"]
|
||||
)
|
||||
# VAL will always give us the keys for the profiles we asked for, but
|
||||
# if it doesn't have an encoded video entry for that Video + Profile, the
|
||||
# value will map to `None`
|
||||
if val_video_urls["desktop_mp4"] and self.download_video:
|
||||
download_video_link = val_video_urls["desktop_mp4"]
|
||||
if val_video_urls["youtube"]:
|
||||
youtube_streams = "1.00:{}".format(val_video_urls["youtube"])
|
||||
try:
|
||||
val_video_urls = edxval_api.get_urls_for_profiles(
|
||||
self.edx_video_id, ["desktop_mp4", "youtube"]
|
||||
)
|
||||
# VAL will always give us the keys for the profiles we asked for, but
|
||||
# if it doesn't have an encoded video entry for that Video + Profile, the
|
||||
# value will map to `None`
|
||||
if val_video_urls["desktop_mp4"] and self.download_video:
|
||||
download_video_link = val_video_urls["desktop_mp4"]
|
||||
if val_video_urls["youtube"]:
|
||||
youtube_streams = "1.00:{}".format(val_video_urls["youtube"])
|
||||
except edxval_api.ValInternalError:
|
||||
# VAL raises this exception if it can't find data for the edx video ID. This can happen if the
|
||||
# course data is ported to a machine that does not have the VAL data. So for now, pass on this
|
||||
# exception and fallback to whatever we find in the VideoDescriptor.
|
||||
log.warning("Could not retrieve information from VAL for edx Video ID: %s.", self.edx_video_id)
|
||||
|
||||
# If there was no edx_video_id, or if there was no download specified
|
||||
# for it, we fall back on whatever we find in the VideoDescriptor
|
||||
|
||||
Reference in New Issue
Block a user