本文整理汇总了Python中mygpo.core.models.Podcast.all_podcasts方法的典型用法代码示例。如果您正苦于以下问题:Python Podcast.all_podcasts方法的具体用法?Python Podcast.all_podcasts怎么用?Python Podcast.all_podcasts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mygpo.core.models.Podcast
的用法示例。
在下文中一共展示了Podcast.all_podcasts方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import all_podcasts [as 别名]
def handle(self, *args, **options):
silent = options.get('silent')
# couchdbkit doesn't preserve microseconds
started = datetime.utcnow().replace(microsecond=0)
podcasts = Podcast.all_podcasts()
total = Podcast.view('podcasts/by_oldid', limit=0).total_rows
for n, podcast in enumerate(podcasts):
subscriber_count = self.get_subscriber_count(podcast)
self.update(podcast=podcast, started=started, subscriber_count=subscriber_count)
if not silent:
progress(n, total)
示例2: handle
# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import all_podcasts [as 别名]
def handle(self, *args, **options):
total = Podcast.count()
podcasts = Podcast.all_podcasts()
actions = Counter()
for n, podcast in enumerate(podcasts):
psubscriber = PodcastSubscriberData.for_podcast(podcast.get_id())
res = self.update_subscriber_data(podcast, data=psubscriber)
self.update_podcast(podcast=podcast)
action = 'updated' if res else 'skipped'
actions[action] += 1
status_str = ', '.join('%s: %d' % x for x in actions.items())
progress(n+1, total, status_str)
示例3: handle
# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import all_podcasts [as 别名]
def handle(self, *args, **options):
get_podcast = itemgetter(0)
max_related = options.get('max')
podcasts = Podcast.all_podcasts()
total = Podcast.view('podcasts/by_id', limit=0).total_rows
for (n, podcast) in enumerate(podcasts):
l = calc_similar_podcasts(podcast)[:max_related]
related = map(get_podcast, l)
@repeat_on_conflict(['podcast'])
def _update(podcast, related):
podcast.related_podcasts = related
podcast.save()
_update(podcast=podcast, related=related)
progress(n+1, total)