本文整理汇总了Python中mygpo.core.models.Podcast.random方法的典型用法代码示例。如果您正苦于以下问题:Python Podcast.random方法的具体用法?Python Podcast.random怎么用?Python Podcast.random使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mygpo.core.models.Podcast
的用法示例。
在下文中一共展示了Podcast.random方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_podcasts
# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import random [as 别名]
def _get_podcasts(self, *args, **options):
if options.get('toplist'):
yield self.get_toplist()
if options.get('new'):
yield self.get_podcast_with_new_episodes()
if options.get('random'):
yield Podcast.random()
get_podcast = lambda url: Podcast.for_url(url, create=True)
yield map(get_podcast, args)
if not args and not options.get('toplist') and not options.get('new') \
and not options.get('random'):
yield Podcast.by_last_update()
示例2: get_random_picks
# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import random [as 别名]
def get_random_picks(languages=None):
""" Returns random podcasts for the given language """
languages = languages or [""]
# get one iterator for each language
rand_iters = [Podcast.random(lang) for lang in languages]
# cycle through them, removing those that don't yield any more results
while rand_iters:
rand_iter = rand_iters.pop(0)
try:
podcast = next(rand_iter)
rand_iters.append(rand_iter)
yield podcast
except StopIteration:
# don't re-add rand_iter
pass