本文整理汇总了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())
示例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]
示例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]
示例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)
示例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
示例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)
示例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)
示例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)
示例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
示例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
示例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
示例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
示例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)
示例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)
示例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