def show_widget(self, request, video_url, is_remote, base_state=None, additional_video_urls=None): video_id = video_cache.get_video_id(video_url) if video_id is None: # for example, private youtube video. return None try: video_urls = video_cache.get_video_urls(video_id) except models.Video.DoesNotExist: video_cache.invalidate_video_id(video_url) video_id = video_cache.get_video_id(video_url) video_urls = video_cache.get_video_urls(video_id) return_value = { 'video_id' : video_id, 'subtitles': None, } return_value['video_urls']= video_urls if additional_video_urls is not None: for url in additional_video_urls: video_cache.associate_extra_url(url, video_id) st_widget_view_statistic_update.delay(video_id=video_id) add_general_settings(request, return_value) if request.user.is_authenticated(): return_value['username'] = request.user.username return_value['drop_down_contents'] = \ video_cache.get_video_languages(video_id) if base_state is not None and base_state.get("language_code", None) is not None: lang_pk = base_state.get('language_pk', None) if lang_pk is None: lang_code = base_state.get('language_code', None) lang_pk = video_cache.pk_for_default_language(video_id, lang_code) subtitles = self._autoplay_subtitles( request.user, video_id, lang_pk, base_state.get('revision', None)) return_value['subtitles'] = subtitles else: if is_remote: autoplay_language = self._find_remote_autoplay_language(request) language_pk = video_cache.pk_for_default_language(video_id, autoplay_language) if autoplay_language is not None: subtitles = self._autoplay_subtitles( request.user, video_id, language_pk, None) return_value['subtitles'] = subtitles return return_value
def track_subtitle_play(self, request, video_id): st_widget_view_statistic_update.delay(video_id=video_id) return {'response': 'ok'}
def track_subtitle_play(self, request, video_id): st_widget_view_statistic_update.delay(video_id=video_id) return {"response": "ok"}