def on_video_url_added(sender, video, **kwargs): video_url = sender account = get_sync_account(video, video_url) if credit.should_add_credit_to_video_url(video_url, account): tasks.add_amara_credit.delay(video_url.pk) if subfetch.should_fetch_subs(video_url): tasks.fetch_subs.delay(video_url.pk)
def on_videourl_save(signal, sender, instance, created, **kwargs): video_url = instance if created: account = get_sync_account(instance.video, instance) if credit.should_add_credit_to_video_url(video_url, account): tasks.add_amara_credit.delay(instance.id) if subfetch.should_fetch_subs(video_url): tasks.fetch_subs.delay(video_url.pk)
def add_amara_credit(video_url_id): video_url = VideoUrl.objects.get(id=video_url_id) account = get_sync_account(video_url.video, video_url) if credit.should_add_credit_to_video_url(video_url, account): try: credit.add_credit_to_video_url(video_url, account) except google.OAuthError: logger.exception("Error adding youtube credit")
def on_video_url_added(sender, video, **kwargs): video_url = sender account = get_sync_account(video, video_url) if credit.should_add_credit_to_video_url(video_url, account): tasks.add_amara_credit.delay(video_url.pk) if subfetch.should_fetch_subs(video_url): team = kwargs.pop('team', None) if team is not None: team = team.pk user = kwargs.pop('user', None) if user is not None: user = user.pk try: tasks.fetch_subs.delay(video_url.pk, user, team) except Exception, e: logger.error("Exception") logger.error(e)
def test_no_account(self): user = UserFactory() video_url = YouTubeVideoFactory().get_primary_videourl_obj() self.assertEqual(should_add_credit_to_video_url(video_url, None), False)
def test_youtube_video_team_account(self): team = TeamFactory() account = YouTubeAccountFactory(team=team) video_url = YouTubeVideoFactory().get_primary_videourl_obj() self.assertEqual(should_add_credit_to_video_url(video_url, account), False)
def test_youtube_video(self): user = UserFactory() account = YouTubeAccountFactory(user=user) video_url = YouTubeVideoFactory().get_primary_videourl_obj() self.assertEqual(should_add_credit_to_video_url(video_url, account), True)
def test_non_youtube_video(self): user = UserFactory() account = BrightcoveCMSAccountFactory(user=user) video_url = BrightcoveVideoFactory().get_primary_videourl_obj() self.assertEqual(should_add_credit_to_video_url(video_url, account), False)
def _update_subtitles_for_language(language): for account, video_url in get_sync_accounts(language.video): tasks.update_subtitles.delay(account.account_type, account.id, video_url.id, language.id) if credit.should_add_credit_to_video_url(video_url, account): tasks.add_amara_credit.delay(video_url.id)
def add_amara_credit(video_url_id): video_url = VideoUrl.objects.get(id=video_url_id) account = get_sync_account(video_url.video, video_url) if credit.should_add_credit_to_video_url(video_url, account): credit.add_credit_to_video_url(video_url, account)