示例#1
0
 def set_values(self, video_obj):
     if vimeo.VIMEO_API_KEY and vimeo.VIMEO_API_SECRET:
         video_obj.thumbnail = vimeo.get_thumbnail_url(self.url, self.shortmem) or ''
         video_obj.small_thumbnail = vimeo.get_small_thumbnail_url(self.url, self.shortmem) or ''
         video_obj.title = vimeo.scrape_title(self.url, self.shortmem)
         video_obj.description = strip_tags(vimeo.scrape_description(self.url, self.shortmem))
         video_obj.save()
     return video_obj
示例#2
0
文件: vimeo.py 项目: crodjer/mirosubs
 def set_values(self, video_obj):
     if vimeo.VIMEO_API_KEY and vimeo.VIMEO_API_SECRET:
         video_obj.thumbnail = vimeo.get_thumbnail_url(
             self.url, self.shortmem) or ''
         video_obj.small_thumbnail = vimeo.get_small_thumbnail_url(
             self.url, self.shortmem) or ''
         video_obj.title = vimeo.scrape_title(self.url, self.shortmem)
         video_obj.description = strip_tags(
             vimeo.scrape_description(self.url, self.shortmem))
         video_obj.save()
     return video_obj
示例#3
0
 def set_values(self, video_obj):
     if vimeo.VIMEO_API_KEY and vimeo.VIMEO_API_SECRET:
         try:
             video_obj.thumbnail = vimeo.get_thumbnail_url(
                 self.url, self.shortmem) or ''
             video_obj.small_thumbnail = vimeo.get_small_thumbnail_url(
                 self.url, self.shortmem) or ''
             video_obj.title = vimeo.scrape_title(self.url, self.shortmem)
             video_obj.description = strip_tags(
                 vimeo.scrape_description(self.url, self.shortmem))
         except Exception:
             # in case the Vimeo video is private.
             pass
示例#4
0
文件: vimeo.py 项目: bscoder/unisubs
 def set_values(self, video_obj):
     if vimeo.VIMEO_API_KEY and vimeo.VIMEO_API_SECRET:
         try:
             video_obj.thumbnail = vimeo.get_thumbnail_url(
                 self.url, self.shortmem) or ''
             video_obj.small_thumbnail = vimeo.get_small_thumbnail_url(
                 self.url, self.shortmem) or ''
             video_obj.title = vimeo.scrape_title(self.url, self.shortmem)
             video_obj.description = strip_tags(
                 vimeo.scrape_description(self.url, self.shortmem))
         except Exception:
             # in case the Vimeo video is private.
             pass
     r = requests.get("https://player.vimeo.com/video/{}/config".format(
         self.video_id))
     if r.status_code == requests.codes.ok:
         try:
             video_obj.duration = r.json[u"video"]["duration"]
         except:
             pass
    def forwards(self, orm):
        qs = orm.VideoUrl.objects.filter(type=VIDEO_TYPE_VIMEO).select_related('video')
        count = qs.count()
        
        i = 0
        for vu in qs:
            i += 1
            if i % 100 == 0:
                print '%s of %s updated...' % (i, count)
                
            video = vu.video

            if video.small_thumbnail:
                continue
            
            try:
                video.small_thumbnail = vimeo.get_small_thumbnail_url(vu.url)
                video.save()
            except Exception, e:
                pass