def test_get_url_for_profile(self): """ Tests get_url_for_profile """ profile = "mobile" edx_video_id = constants.VIDEO_DICT_FISH["edx_video_id"] url = api.get_url_for_profile(edx_video_id, profile) self.assertEqual(url, u"http://www.meowmix.com")
def test_get_url_for_profile(self): """ Tests get_url_for_profile """ profile = "mobile" edx_video_id = constants.VIDEO_DICT_FISH['edx_video_id'] url = api.get_url_for_profile(edx_video_id, profile) self.assertEqual(url, u'http://www.meowmix.com')
def test_get_url_for_profile(self): """ Tests get_url_for_profile """ profile = "mobile" edx_video_id = constants.VIDEO_DICT_FISH['edx_video_id'] urls = api.get_url_for_profile(edx_video_id, profile) self.assertEqual(len(urls), 1) self.assertEqual(urls["mobile"], u'http://www.meowmix.com')
def get_youtube_link(video_id): """ Returns the fully-qualified YouTube URL for the given video identifier """ # First try a lookup in VAL. If we have a YouTube entry there, it overrides the # one passed in. if self.edx_video_id and edxval_api: val_youtube_id = edxval_api.get_url_for_profile(self.edx_video_id, "youtube") if val_youtube_id: video_id = val_youtube_id return self.create_youtube_url(video_id)
def editor_saved(self, user, old_metadata, old_content): """ Used to update video values during `self`:save method from CMS. old_metadata: dict, values of fields of `self` with scope=settings which were explicitly set by user. old_content, same as `old_metadata` but for scope=content. Due to nature of code flow in item.py::_save_item, before current function is called, fields of `self` instance have been already updated, but not yet saved. To obtain values, which were changed by user input, one should compare own_metadata(self) and old_medatada. Video player has two tabs, and due to nature of sync between tabs, metadata from Basic tab is always sent when video player is edited and saved first time, for example: {'youtube_id_1_0': u'3_yD_cEKoCk', 'display_name': u'Video', 'sub': u'3_yD_cEKoCk', 'html5_sources': []}, that's why these fields will always present in old_metadata after first save. This should be fixed. At consequent save requests html5_sources are always sent too, disregard of their change by user. That means that html5_sources are always in list of fields that were changed (`metadata` param in save_item). This should be fixed too. """ metadata_was_changed_by_user = old_metadata != own_metadata(self) # There is an edge case when old_metadata and own_metadata are same and we are importing transcript from youtube # then there is a syncing issue where html5_subs are not syncing with youtube sub, We can make sync better by # checking if transcript is present for the video and if any html5_ids transcript is not present then trigger # the manage_video_subtitles_save to create the missing transcript with particular html5_id. if not metadata_was_changed_by_user and self.sub and hasattr(self, 'html5_sources'): html5_ids = get_html5_ids(self.html5_sources) for subs_id in html5_ids: try: Transcript.asset(self.location, subs_id) except NotFoundError: # If a transcript does not not exist with particular html5_id then there is no need to check other # html5_ids because we have to create a new transcript with this missing html5_id by turning on # metadata_was_changed_by_user flag. metadata_was_changed_by_user = True break if metadata_was_changed_by_user: self.edx_video_id = self.edx_video_id and self.edx_video_id.strip() # We want to override `youtube_id_1_0` with val youtube profile in the first place when someone adds/edits # an `edx_video_id` or its underlying YT val profile. Without this, override will only happen when a user # saves the video second time. This is because of the syncing of basic and advanced video settings which # also syncs val youtube id from basic tab's `Video Url` to advanced tab's `Youtube ID`. if self.edx_video_id and edxval_api: val_youtube_id = edxval_api.get_url_for_profile(self.edx_video_id, 'youtube') if val_youtube_id and self.youtube_id_1_0 != val_youtube_id: self.youtube_id_1_0 = val_youtube_id manage_video_subtitles_save( self, user, old_metadata if old_metadata else None, generate_translation=True )
def get_youtube_link(video_id): # First try a lookup in VAL. If we have a YouTube entry there, it overrides the # one passed in. if self.edx_video_id and edxval_api: val_youtube_id = edxval_api.get_url_for_profile(self.edx_video_id, "youtube") if val_youtube_id: video_id = val_youtube_id if video_id: return 'http://youtu.be/{0}'.format(video_id) else: return ''