def search_podcasts(q, limit=20, skip=0): if is_url(q): url = sanitize_url(q) podcast = Podcast.for_url(url, create=True) if not podcast.title: update_podcasts([podcast]) podcast = Podcast.for_url(url) return [podcast], 1 db = get_main_database() #FIXME current couchdbkit can't parse responses for multi-query searches q = q.replace(',', '') res = db.search('podcasts/search', wrapper=search_wrapper, include_docs=True, limit=limit, skip=skip, q=q, sort='\\subscribers<int>') #FIXME: return empty results in case of search backend error try: return list(res), res.total_rows except: return [], 0
def search_podcasts(q): if is_url(q): url = normalize_feed_url(q) try: podcast = Podcast.objects.get(urls__url=url) except Podcast.DoesNotExist: podcast = None updater = PodcastUpdater(url) if not podcast or not podcast.title: try: updater.update_podcast() except NoPodcastCreated as npc: return [] try: podcast = Podcast.objects.get(urls__url=url) return [podcast] except Podcast.DoesNotExist: return [] return search(q)
def search_podcasts(q, limit=20, skip=0): if is_url(q): url = normalize_feed_url(q) podcast = podcast_for_url(url, create=False) if not podcast or not podcast.title: updater = PodcastUpdater() try: updater.update(url) except NoPodcastCreated as npc: return [], 0 podcast = podcast_for_url(url) if podcast: return [podcast], 1 else: return [], 0 return search(q, skip, limit)