remove gevent monkey-patch from feed-downloader
[mygpo.git] / mygpo / directory / search.py
blob71637876e37989703d1a8c2e2d7c8a3e2a913c45
1 from mygpo.utils import is_url
2 from mygpo.data.feeddownloader import PodcastUpdater, NoPodcastCreated
3 from mygpo.api.sanitizing import sanitize_url
4 from mygpo.cache import cache_result
5 from mygpo.db.couchdb.podcast import podcast_for_url, search
8 @cache_result(timeout=60*60)
9 def search_podcasts(q, limit=20, skip=0):
11 if is_url(q):
12 url = sanitize_url(q)
14 podcast = podcast_for_url(url, create=False)
16 if not podcast or not podcast.title:
18 updater = PodcastUpdater()
20 try:
21 updater.update(url)
22 except NoPodcastCreated as npc:
23 return [], 0
25 podcast = podcast_for_url(url)
26 if podcast:
27 return [podcast], 1
28 else:
29 return [], 0
32 return search(q, skip, limit)