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


Python Podcast.view方法代码示例

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


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

示例1: for_podcast

# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import view [as 别名]
    def for_podcast(cls, podcast):
        """ all tags for the podcast, in decreasing order of importance """

        res = Podcast.view('tags/by_podcast',
                startkey    = [podcast.get_id(), None],
                endkey      = [podcast.get_id(), {}],
                reduce      = True,
                group       = True,
                group_level = 2,
                stale       = 'update_after',
            )

        tags = Counter(dict((x['key'][1], x['value']) for x in res))

        res = Podcast.view('usertags/by_podcast',
                startkey    = [podcast.get_id(), None],
                endkey      = [podcast.get_id(), {}],
                reduce      = True,
                group       = True,
                group_level = 2,
            )

        tags.update(Counter(dict( (x['key'][1], x['value']) for x in res)))

        get_tag = itemgetter(0)
        return map(get_tag, tags.most_common())
开发者ID:Mic92,项目名称:mygpo,代码行数:28,代码来源:tags.py

示例2: _get_existing_slugs

# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import view [as 别名]
    def _get_existing_slugs(self):
        from mygpo.core.models import Podcast

        res = Podcast.view(
            "podcasts/by_slug", startkey=[self.base_slug, None], endkey=[self.base_slug + "ZZZZZ", None], wrap_doc=False
        )
        return [r["key"][0] for r in res]
开发者ID:Mic92,项目名称:mygpo,代码行数:9,代码来源:slugs.py

示例3: podcast_slugs

# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import view [as 别名]
def podcast_slugs(base_slug):
    res = Podcast.view('podcasts/by_slug',
            startkey = [base_slug, None],
            endkey   = [base_slug + 'ZZZZZ', None],
            wrap_doc = False,
        )
    return [r['key'][0] for r in res]
开发者ID:fk-lx,项目名称:mygpo,代码行数:9,代码来源:podcast.py

示例4: podcasts_by_last_update

# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import view [as 别名]
def podcasts_by_last_update(limit=100):
    res = Podcast.view('podcasts/by_last_update',
            include_docs = True,
            stale        = 'update_after',
            wrap_doc     = False,
            limit        = limit,
        )

    # TODO: this method is only used for retrieving podcasts to update;
    #       should we really send 'incomplete_obj' signals here?

    return map(_wrap_podcast_group_key1, res)
开发者ID:fk-lx,项目名称:mygpo,代码行数:14,代码来源:podcast.py

示例5: for_user

# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import view [as 别名]
    def for_user(cls, user, podcast_id=None):
        """ mapping of all podcasts tagged by the user with a list of tags """

        res = Podcast.view('tags/by_user',
                startkey = [user._id, podcast_id],
                endkey   = [user._id, podcast_id or {}]
            )

        tags = defaultdict(list)
        for r in res:
            tags[r['key'][1]].append(r['value'])
        return tags
开发者ID:Mic92,项目名称:mygpo,代码行数:14,代码来源:tags.py

示例6: podcasts_by_next_update

# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import view [as 别名]
def podcasts_by_next_update(limit=100):
    """ Returns the podcasts that are due for an update next """

    res = Podcast.view('podcasts/by_next_update',
            include_docs = True,
            stale        = 'update_after',
            limit        = limit,
            classes      = [Podcast, PodcastGroup],
        )

    # TODO: this method is only used for retrieving podcasts to update;
    #       should we really send 'incomplete_obj' signals here?

    return list(res)
开发者ID:fk-lx,项目名称:mygpo,代码行数:16,代码来源:podcast.py

示例7: podcast_duplicates_for_url

# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import view [as 别名]
def podcast_duplicates_for_url(url):

    if not url:
        raise QueryParameterMissing('url')

    _view = 'podcasts/by_url'
    r = Podcast.view(_view,
            key          = url,
            classes      = [Podcast, PodcastGroup],
            include_docs = True,
        )

    for pg in r:
        yield pg.get_podcast_by_url(url)
开发者ID:fk-lx,项目名称:mygpo,代码行数:16,代码来源:podcast.py

示例8: handle

# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import view [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)
开发者ID:Mic92,项目名称:mygpo,代码行数:18,代码来源:update-toplist.py

示例9: get_podcast_languages

# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import view [as 别名]
def get_podcast_languages():
    """ Returns all 2-letter language codes that are used by podcasts.

    It filters obviously invalid strings, but does not check if any
    of these codes is contained in ISO 639. """

    from mygpo.web.utils import sanitize_language_codes

    res = Podcast.view('podcasts/by_language',
            group_level = 1,
            stale       = 'ok',
        )

    langs = [r['key'][0] for r in res]
    sane_lang = sanitize_language_codes(langs)
    sane_lang.sort()
    return sane_lang
开发者ID:fk-lx,项目名称:mygpo,代码行数:19,代码来源:podcast.py

示例10: get_flattr_podcasts

# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import view [as 别名]
def get_flattr_podcasts(offset=0, limit=20):
    """ returns all podcasts that contain Flattr payment URLs """

    r = Podcast.view('podcasts/flattr',
            skip         = offset,
            limit        = limit,
            classes      = [Podcast, PodcastGroup],
            include_docs = True,
            reduce       = False,
        )

    podcasts = list(r)

    for podcast in podcasts:
        if podcast.needs_update:
            incomplete_obj.send_robust(sender=podcast)

    return podcasts
开发者ID:fk-lx,项目名称:mygpo,代码行数:20,代码来源:podcast.py

示例11: podcasts_by_id

# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import view [as 别名]
def podcasts_by_id(ids):

    if ids is None:
        raise QueryParameterMissing('ids')

    if not ids:
        return []

    r = Podcast.view('podcasts/by_id',
            keys         = ids,
            include_docs = True,
            wrap_doc     = False
        )

    podcasts = map(_wrap_podcast_group, r)

    for podcast in podcasts:
        if podcast.needs_update:
            incomplete_obj.send_robust(sender=podcast)

    return podcasts
开发者ID:fk-lx,项目名称:mygpo,代码行数:23,代码来源:podcast.py

示例12: get_license_podcasts

# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import view [as 别名]
def get_license_podcasts(offset=0, limit=20, license_url=None):
    """ returns a page of podcasts w/ license information """

    kwargs = {}
    if license_url:
        kwargs['key'] = license_url

    r = Podcast.view('podcasts/license',
            skip = offset,
            limit = limit,
            classes = [Podcast, PodcastGroup],
            include_docs = True,
            reduce = False,
            **kwargs
    )

    podcasts = list(r)

    for podcast in podcasts:
        if podcast.needs_update:
            incomplete_obj.send_robust(sender=podcast)

    return podcasts
开发者ID:fk-lx,项目名称:mygpo,代码行数:25,代码来源:podcast.py

示例13: handle

# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import view [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)
开发者ID:Mic92,项目名称:mygpo,代码行数:25,代码来源:update-related-podcasts.py

示例14: random_podcasts

# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import view [as 别名]
def random_podcasts(language='', chunk_size=5):
    """ Returns an iterator of random podcasts

    optionaly a language code can be specified. If given the podcasts will
    be restricted to this language. chunk_size determines how many podcasts
    will be fetched at once """

    while True:
        rnd = random()
        res = Podcast.view('podcasts/random',
                startkey     = [language, rnd],
                include_docs = True,
                limit        = chunk_size,
                stale        = 'ok',
                wrap_doc     = False,
            )

        if not res:
            break

        for r in res:
            # The view podcasts/random does not include incomplete podcasts,
            # so we don't need to send any 'incomplete_obj' signals here
            yield _wrap_pg(r)
开发者ID:fk-lx,项目名称:mygpo,代码行数:26,代码来源:podcast.py

示例15: podcast_count

# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import view [as 别名]
def podcast_count():
    return Podcast.view('podcasts/by_id',
            limit = 0,
            stale = 'update_after',
        ).total_rows
开发者ID:fk-lx,项目名称:mygpo,代码行数:7,代码来源:podcast.py


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