Ejemplo n.º 1
0
 def setUp(self):
     self.user = UserFactory()
     self.client = APIClient()
     self.client.force_authenticate(user=self.user)
     self.list_url = reverse('api:activity-list')
     # create a bunch of action objects of various types
     self.team = TeamFactory()
     self.team_member = TeamMemberFactory(user=self.user, team=self.team)
     self.video = VideoFactory()
     TeamVideoFactory(video=self.video, team=self.team)
     self.user2 = UserFactory()
     Action.create_video_handler(self.video, self.user)
     self.video.title = 'new-title'
     self.video.save()
     Action.change_title_handler(self.video, self.user)
     # creating comment will automatically create the action object
     Comment(content_object=self.video,
             user=self.user,
             content="Test Comment").save()
     v = pipeline.add_subtitles(self.video, 'en', None, author=self.user)
     Action.create_caption_handler(v, datetime.now())
     Action.create_approved_video_handler(v, self.user2)
     Action.create_rejected_video_handler(v, self.user2)
     Action.create_new_member_handler(self.team_member)
     Action.create_member_left_handler(self.team, self.user)
     self.action_qs = Action.objects.for_user(self.user)
Ejemplo n.º 2
0
    def _import_video(self, video_url, videoid, title, description, thumbnail,
                      videosrt):
        videoid_match = VIDEOID_RE.search(videoid)
        videoid = videoid_match.group(1)
        video_type = YoutubeVideoType(
            'http://www.youtube.com/watch?v={0}'.format(videoid))
        try:
            video_url_obj = VideoUrl.objects.get(
                url=video_type.convert_to_video_url())
            video = video_url_obj.video
        except ObjectDoesNotExist:
            video_url_obj = None
            video = Video()
            video.youtube_videoid = videoid
        video.title = title
        video.description = description
        if video_type.entry.media.duration:
            video.duration = int(video_type.entry.media.duration.seconds)
        video.thumbnail = thumbnail
        video.save()
        Action.create_video_handler(video)

        if videosrt:
            self._import_srt(video, videosrt)
        else:
            SubtitleLanguage(video=video,
                             language='en',
                             is_original=True,
                             is_forked=True).save()

        if not video_url_obj:
            video_url_obj = VideoUrl(videoid=videoid,
                                     url=video_type.convert_to_video_url(),
                                     type=video_type.abbreviation,
                                     original=True,
                                     primary=True,
                                     video=video)
            video_url_obj.save()

        self._save_alternate_url(video, video_url)
Ejemplo n.º 3
0
    def _import_video(self, video_url, videoid, title, description, thumbnail, videosrt):
        videoid_match = VIDEOID_RE.search(videoid)
        videoid = videoid_match.group(1)
        video_type = YoutubeVideoType(
            'http://www.youtube.com/watch?v={0}'.format(videoid))
        try:
            video_url_obj = VideoUrl.objects.get(
                url=video_type.convert_to_video_url())
            video = video_url_obj.video
        except ObjectDoesNotExist:
            video_url_obj = None
            video = Video()
            video.youtube_videoid = videoid
        video.title = title
        video.description = description
        if video_type.entry.media.duration:
            video.duration = int(video_type.entry.media.duration.seconds)
        video.thumbnail = thumbnail
        video.save()
        Action.create_video_handler(video)

        if videosrt:
            self._import_srt(video, videosrt)
        else:
            SubtitleLanguage(video=video, language='en', is_original=True, is_forked=True).save()

        if not video_url_obj:
            video_url_obj = VideoUrl(
                videoid=videoid,
                url=video_type.convert_to_video_url(),
                type=video_type.abbreviation,
                original=True,
                primary=True,
                video=video)
            video_url_obj.save()

        self._save_alternate_url(video, video_url)