Ejemplo n.º 1
0
 def test_missing_lang_no_fail(self):
     # when sending a nonexisting lang, we should end up with the original lang, since
     # others might have been cleared and not gotten through the cache
     # we are asserting this won't raise an exception for https://www.pivotaltracker.com/story/show/15348901
     url = "http://videos-cdn.mozilla.net/serv/mozhacks/demos/screencasts/londonproject/screencast.ogv"
     cache_key = video_cache._video_id_key(url)
     video_cache.cache.set(cache_key, "", video_cache.TIMEOUT)
     video_id = video_cache.get_video_id(url)
     video_cache.get_subtitles_dict(video_id, 0, 0, lambda x: x)
Ejemplo n.º 2
0
 def _autoplay_subtitles(self, user, video_id, language_pk, version_no):
     cache =  video_cache.get_subtitles_dict(
         video_id, language_pk, version_no, 
         lambda version: self._subtitles_dict(version))
     if cache and cache.get("language", None) is not None:
         cache['language_code'] = cache['language'].language
         cache['language_pk'] = cache['language'].pk
     return cache
Ejemplo n.º 3
0
 def fetch_subtitles(self, request, video_id, language_code=None, language_pk=None):
     if language_pk is None and language_code is not None:
         try:
             language_pk  = models.SubtitleLanguage.objects.filter(video__video_id=video_id,language=language_code).order_by("-subtitle_count")[0].pk
         except models.SubtitleLanguage.DoesNotExist:
             pass
     cache = video_cache.get_subtitles_dict(
         video_id, language_pk, None,
         lambda version: self._subtitles_dict(version))
     return cache    
Ejemplo n.º 4
0
 def fetch_subtitles(self,
                     request,
                     video_id,
                     language_code=None,
                     language_pk=None):
     if language_pk is None and language_code is not None:
         try:
             language_pk = models.SubtitleLanguage.objects.filter(
                 video__video_id=video_id,
                 language=language_code).order_by("-subtitle_count")[0].pk
         except models.SubtitleLanguage.DoesNotExist:
             pass
     cache = video_cache.get_subtitles_dict(
         video_id, language_pk, None,
         lambda version: self._subtitles_dict(version))
     return cache
Ejemplo n.º 5
0
 def _autoplay_subtitles(self, user, video_id, language_code, version_no):
     return video_cache.get_subtitles_dict(
         video_id, language_code, version_no, 
         lambda version: self._subtitles_dict(version))
Ejemplo n.º 6
0
 def fetch_subtitles(self, request, video_id, language_code=None):
     return video_cache.get_subtitles_dict(
         video_id, language_code, None,
         lambda version: self._subtitles_dict(version))
Ejemplo n.º 7
0
 def fetch_subtitles(self, request, video_id, language_pk):
     cache = video_cache.get_subtitles_dict(
         video_id, language_pk, None,
         lambda version: self._subtitles_dict(version))
     return cache
Ejemplo n.º 8
0
 def _autoplay_subtitles(self, user, video_id, language_code, version_no):
     return video_cache.get_subtitles_dict(
         video_id, language_code, version_no,
         lambda version: self._subtitles_dict(version))
Ejemplo n.º 9
0
 def fetch_subtitles(self, request, video_id, language_code=None):
     return video_cache.get_subtitles_dict(
         video_id, language_code, None,
         lambda version: self._subtitles_dict(version))