コード例 #1
0
ファイル: podcastcmd.py プロジェクト: Mic92/mygpo
    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
0
ファイル: backend.py プロジェクト: Mic92/mygpo
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