Example #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)
Example #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)
Example #3
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)
Example #4
0
 def test_should_fetch_subs_non_youtube_video(self):
     video = VideoFactory()
     assert_false(should_fetch_subs(video.get_primary_videourl_obj()))
Example #5
0
 def test_should_fetch_subs_no_channel_id(self):
     video = YouTubeVideoFactory(channel_id=None)
     assert_false(should_fetch_subs(video.get_primary_videourl_obj()))
Example #6
0
 def test_should_fetch_subs_no_youtube_account(self):
     video = YouTubeVideoFactory(channel_id="username")
     assert_false(should_fetch_subs(video.get_primary_videourl_obj()))
Example #7
0
 def test_should_fetch_subs_with_youtube_account(self):
     YouTubeAccountFactory(channel_id="username", user=UserFactory())
     video = YouTubeVideoFactory(channel_id="username")
     assert_true(should_fetch_subs(video.get_primary_videourl_obj()))