当前位置: 首页>>代码示例>>Python>>正文


Python Video.subtitles_fetched_counter方法代码示例

本文整理汇总了Python中videos.models.Video.subtitles_fetched_counter方法的典型用法代码示例。如果您正苦于以下问题:Python Video.subtitles_fetched_counter方法的具体用法?Python Video.subtitles_fetched_counter怎么用?Python Video.subtitles_fetched_counter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在videos.models.Video的用法示例。


在下文中一共展示了Video.subtitles_fetched_counter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle

# 需要导入模块: from videos.models import Video [as 别名]
# 或者: from videos.models.Video import subtitles_fetched_counter [as 别名]
    def handle(self, *args, **kwargs):
        try:
            sub_fetch_keys_set.r.ping()
        except:
            if settings.DEBUG:
                raise
            self.handle_error('Statistic update error', '', sys.exc_info())     
            return
        
        count = sub_fetch_keys_set.scard()
        
        while count:
            count -= 1
            key = sub_fetch_keys_set.spop()
            
            if not key:
                break
            
            print 'Handle key: %s' % key
            
            parts = key.split(':')
            d = date(int(parts[-1]), int(parts[-2]), int(parts[-3]))
            
            if len(parts) == 6:
                lang = parts[2]
            else:
                lang = ''
            
            try:
                video = Video.objects.get(video_id=parts[1])
            except Video.DoesNotExist:
                print 'Video does not exist'
                default_connection.delete(key)
                continue
            
            counter_obj, created = SubtitleFetchCounters.objects.get_or_create(date=d, video=video, language=lang)
            counter_obj.count += int(default_connection.getset(key, 0))
            counter_obj.save()
            
        count = changed_video_set.scard()
        
        while count:
            count -= 1

            video_id = changed_video_set.spop()

            if not video_id:
                break
            
            print 'Update statistic for video: %s' % video_id
            
            subtitles_fetched_counter = Video.subtitles_fetched_counter(video_id, True)
            widget_views_counter = Video.widget_views_counter(video_id, True)
            view_counter = Video.view_counter(video_id, True)
            
            Video.objects.filter(video_id=video_id).update(view_count=F('view_count')+view_counter.getset(0))
            Video.objects.update(widget_views_count=F('widget_views_count')+widget_views_counter.getset(0))
            Video.objects.update(subtitles_fetched_count=F('subtitles_fetched_count')+subtitles_fetched_counter.getset(0))
开发者ID:MechanisM,项目名称:mirosubs,代码行数:60,代码来源:update_statistic.py

示例2: forwards

# 需要导入模块: from videos.models import Video [as 别名]
# 或者: from videos.models.Video import subtitles_fetched_counter [as 别名]
 def forwards(self, orm):
     if db.dry_run:
         return
     
     try:
         from videos.models import Video, SubtitleLanguage
     except ImportError:
         return
     
     try:
         Video.widget_views_counter.r.ping()
     except ConnectionError:
         if settings.DEBUG:
             return
         raise Exception('Redis server is unavailable. You can ignore this migration with: python manage.py migrate videos 0068 --fake, but all statistic data will be lost.')
     
     for obj in orm.Video.objects.all():
         Video.subtitles_fetched_counter(obj.video_id).val = obj.subtitles_fetched_count
         Video.widget_views_counter(obj.video_id).val = obj.widget_views_count
         
     for obj in orm.SubtitleLanguage.objects.all():
         SubtitleLanguage.subtitles_fetched_counter(obj.pk).val = obj.subtitles_fetched_count
开发者ID:MechanisM,项目名称:mirosubs,代码行数:24,代码来源:0068_migrate_counters.py


注:本文中的videos.models.Video.subtitles_fetched_counter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。