Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
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")
Пример #4
0
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)
Пример #5
0
 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)
Пример #6
0
 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)
Пример #7
0
 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)
Пример #8
0
 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)
Пример #9
0
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)
Пример #10
0
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)