Пример #1
0
 def test_get_thumbnail_url(self):
     """
     get_thubmanil_url() should return the thumbnail URL for the blip.tv
     video.
     """
     self.assertEquals(blip.get_thumbnail_url(BASE_URL),
                       'http://a.images.blip.tv/'
                       'Miropcf-Miro20Introduction767.jpg')
Пример #2
0
 def test_get_thumbnail_url(self):
     """
     get_thubmanil_url() should return the thumbnail URL for the blip.tv
     video.
     """
     self.assertEquals(
         blip.get_thumbnail_url(BASE_URL), 'http://a.images.blip.tv/'
         'Miropcf-Miro20Introduction767.jpg')
Пример #3
0
 def set_values(self, video_obj):
     video_obj.title = blip.scrape_title(self.url, self.shortmem)
     video_obj.thumbnail = blip.get_thumbnail_url(self.url, self.shortmem)
     video_obj.description = strip_tags(blip.scrape_description(self.url, self.shortmem))
     return video_obj
Пример #4
0
 def set_values(self, video_obj):
     video_obj.title = unicode(blip.scrape_title(self.url, self.shortmem))
     video_obj.thumbnail = blip.get_thumbnail_url(self.url, self.shortmem)
     #video_obj.description = strip_tags(blip.scrape_description(self.url, self.shortmem))
     return video_obj
Пример #5
0
    def get_or_create_for_url(cls, video_url):
        parsed_url = urlparse(video_url)
        if 'youtube.com' in parsed_url.netloc:
            yt_video_id = get_video_id(video_url)
            video, created = Video.objects.get_or_create(
                youtube_videoid=yt_video_id,
                defaults={'video_type': VIDEO_TYPE_YOUTUBE, 
                          'allow_community_edits': True})
         
            if created:
                entry = yt_service.GetYouTubeVideoEntry(video_id=video.youtube_videoid)
                video.title = entry.media.title.text
                video.duration = entry.media.duration.seconds
                if entry.media.thumbnail:
                    video.thumbnail = entry.media.thumbnail[-1].url
                video.save()
                video._get_subtitles_from_youtube()
        elif 'blip.tv' in parsed_url.netloc and blip.BLIP_REGEX.match(video_url):
            bliptv_fileid = blip.BLIP_REGEX.match(video_url).groupdict()['file_id']
            video, created = Video.objects.get_or_create(
                bliptv_fileid=bliptv_fileid,
                defaults={'video_type': VIDEO_TYPE_BLIPTV, 
                          'allow_community_edits': True})
            if created:
                video.title = blip.scrape_title(video_url)
                video.bliptv_flv_url = videos_blip.scrape_best_file_url(video_url)
                video.video_url = video.bliptv_flv_url
                video.thumbnail = blip.get_thumbnail_url(video_url)
                video.save()
        elif 'video.google.com' in parsed_url.netloc and google_video.GOOGLE_VIDEO_REGEX.match(video_url):
            video, created = Video.objects.get_or_create(
                video_url=video_url,
                defaults={'video_type': VIDEO_TYPE_GOOGLE,
                          'allow_community_edits': True})
            if created:
                video.title = google_video.scrape_title(video_url)
                video.save()           
        elif 'ustream.tv' in parsed_url.netloc and ustream.USTREAM_REGEX.match(video_url):
            video, created = Video.objects.get_or_create(
                video_url=ustream.get_flash_enclosure_url(video_url),
                defaults={'video_type': VIDEO_TYPE_USTREAM,
                          'allow_community_edits': True})
            if created:
                video.title = ustream.get_title(video_url)
                video.thumbnail = ustream.get_thumbnail_url(video_url)
                video.save()  
        elif 'vimeo.com' in parsed_url.netloc and vimeo.VIMEO_REGEX.match(video_url):
            vimeo_videoid = vimeo.VIMEO_REGEX.match(video_url).group(2)
            video, created = Video.objects.get_or_create(
                vimeo_videoid = vimeo_videoid,
                defaults={'video_type': VIDEO_TYPE_VIMEO,
                          'allow_community_edits': True})
            # TODO: title and thumbnail -- we can't get them without
            # an application oauth key/secret
        elif 'dailymotion.com' in parsed_url.netloc and dailymotion.DAILYMOTION_REGEX.match(video_url):
            metadata = dailymotion.get_metadata(video_url)

            stream_flv_mini_url = metadata.get('stream_flv_mini_url', '')
            if stream_flv_mini_url and stream_flv_mini_url != '':
                dailymotion_videoid = dailymotion.get_video_id(video_url)
                video, created = Video.objects.get_or_create(
                    dailymotion_videoid = dailymotion_videoid,
                    defaults={'video_type': VIDEO_TYPE_DAILYMOTION,
                              'allow_community_edits': True})
                if created:
                    video.title = metadata.get('title') or dailymotion_videoid
                    video.thumbnail = metadata.get('thumbnail_url') or ''
                    video.save()
            else:
                # not hosted by dailymotion and uses a different player
                # TODO: error message / specific exception type?
                raise Exception("dailymotion video actually hosted by partner -- we can't handle this")
        elif FLV_REGEX.match(video_url):
            video, created = Video.objects.get_or_create(
                video_url=video_url,
                defaults={'video_type': VIDEO_TYPE_FLV,
                          'allow_community_edits': True})
        else:
            video, created = Video.objects.get_or_create(
                video_url=video_url,
                defaults={'video_type': VIDEO_TYPE_HTML5,
                          'allow_community_edits': True})
        return video, created