Commit 56691d7e authored by Romain Bignon's avatar Romain Bignon

rename iter_search_results to either search_videos and search_gallery (closes #779)

parent 46f94a1d
......@@ -101,7 +101,7 @@ class VideoobWeb(BaseApplication):
url=video.url if video.url else '/download?id=%s' % video.id,
thumbnail_url=video.thumbnail.url,
) \
for video in backend.iter_search_results(pattern=q, nsfw=nsfw)]
for video in backend.search_videos(pattern=q, nsfw=nsfw)]
if videos:
if merge:
c['results'].extend(videos)
......
......@@ -50,9 +50,9 @@ class ArteBackend(BaseBackend, ICapVideo):
with self.browser:
return self.browser.get_video(_id)
def iter_search_results(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
def search_videos(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
with self.browser:
return self.browser.iter_search_results(pattern)
return self.browser.search_videos(pattern)
def fill_video(self, video, fields):
if fields != ['thumbnail']:
......
......@@ -51,7 +51,7 @@ class ArteBrowser(BaseBrowser):
def home(self):
self.location('http://videos.arte.tv/fr/videos/arte7')
def iter_search_results(self, pattern):
def search_videos(self, pattern):
if not pattern:
self.home()
else:
......
......@@ -24,7 +24,7 @@ class ArteTest(BackendTest):
BACKEND = 'arte'
def test_arte(self):
l = list(self.backend.iter_search_results('arte'))
l = list(self.backend.search_videos('arte'))
if len(l) > 0:
v = l[0]
self.backend.fillobj(v, ('url',))
......
......@@ -48,9 +48,9 @@ class CanalplusBackend(BaseBackend, ICapVideo, ICapCollection):
def create_default_browser(self):
return self.create_browser(quality=self.config['quality'].get())
def iter_search_results(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
def search_videos(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
with self.browser:
return self.browser.iter_search_results(pattern)
return self.browser.search_videos(pattern)
def get_video(self, _id):
m = re.match('https?://www\.canal-?plus\.fr/.*\?vid=(\d+)', _id)
......
......@@ -69,7 +69,7 @@ class CanalplusBrowser(BaseBrowser):
def home(self):
self.location('http://service.canal-plus.com/video/rest/initPlayer/cplus/')
def iter_search_results(self, pattern):
def search_videos(self, pattern):
self.location('http://service.canal-plus.com/video/rest/search/cplus/' + urllib.quote_plus(pattern.replace('/', '').encode('utf-8')))
return self.page.iter_results()
......
......@@ -25,7 +25,7 @@ class CanalPlusTest(BackendTest):
BACKEND = 'canalplus'
def test_canalplus(self):
l = list(self.backend.iter_search_results('guignol'))
l = list(self.backend.search_videos('guignol'))
self.assertTrue(len(l) > 0)
v = l[0]
self.backend.fillobj(v, ('url',))
......
......@@ -30,9 +30,9 @@ class CappedBackend(BaseBackend, ICapVideo):
with self.browser:
return self.browser.get_video(_id)
def iter_search_results(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=None, max_results=None):
def search_videos(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=None, max_results=None):
with self.browser:
return self.browser.iter_search_results(pattern)
return self.browser.search_videos(pattern)
def fill_video(self, video, fields):
if fields != ['thumbnail']:
......
......@@ -118,7 +118,7 @@ class CappedBrowser(BaseBrowser):
assert self.is_on_page(VideoPage), 'Should be on video page.'
return self.page.get_video(video)
def iter_search_results(self,pattern):
def search_videos(self,pattern):
if not pattern:
self.home()
else:
......
......@@ -19,7 +19,7 @@ class CappedTest(BackendTest):
BACKEND = 'cappedtv'
def test_capped(self):
l = list(self.backend.iter_search_results('kewlers'))
l = list(self.backend.search_videos('kewlers'))
self.assertTrue(len(l) > 0)
v = l[0]
self.backend.fillobj(v, ('url',))
......
......@@ -44,9 +44,9 @@ class DailymotionBackend(BaseBackend, ICapVideo):
return self.browser.get_video(_id)
SORTBY = ['relevance', 'rated', 'visited', None]
def iter_search_results(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
def search_videos(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
with self.browser:
return self.browser.iter_search_results(pattern, self.SORTBY[sortby])
return self.browser.search_videos(pattern, self.SORTBY[sortby])
def fill_video(self, video, fields):
if fields != ['thumbnail']:
......
......@@ -42,7 +42,7 @@ class DailymotionBrowser(BaseBrowser):
self.location(url)
return self.page.get_video(video)
def iter_search_results(self, pattern, sortby):
def search_videos(self, pattern, sortby):
if not pattern:
self.home()
else:
......
......@@ -24,7 +24,7 @@ class DailymotionTest(BackendTest):
BACKEND = 'dailymotion'
def test_dailymotion(self):
l = list(self.backend.iter_search_results('chirac'))
l = list(self.backend.search_videos('chirac'))
self.assertTrue(len(l) > 0)
v = l[0]
self.backend.fillobj(v, ('url',))
......
......@@ -53,9 +53,9 @@ class EHentaiBackend(BaseBackend, ICapGallery):
password = None
return self.create_browser(self.config['domain'].get(), username, password)
def iter_search_results(self, pattern=None, sortby=None, max_results=None):
def search_gallery(self, pattern=None, sortby=None, max_results=None):
with self.browser:
return self.browser.iter_search_results(pattern)
return self.browser.search_gallery(pattern)
def iter_gallery_images(self, gallery):
self.fillobj(gallery, ('url',))
......@@ -74,7 +74,7 @@ class EHentaiBackend(BaseBackend, ICapGallery):
_id = match.group(0)
else:
return None
gallery = EHentaiGallery(_id)
with self.browser:
if self.browser.gallery_exists(gallery):
......
......@@ -51,7 +51,7 @@ class EHentaiBrowser(BaseBrowser):
def _gallery_page(self, gallery, n):
return gallery.url + ('?p=%d' % n)
def iter_search_results(self, pattern):
def search_gallery(self, pattern):
self.location(self.buildurl('/', f_search=pattern.encode('utf-8')))
assert self.is_on_page(IndexPage)
return self.page.iter_galleries()
......
......@@ -24,7 +24,7 @@ class EHentaiTest(BackendTest):
BACKEND = 'ehentai'
def test_ehentai(self):
l = list(self.backend.iter_search_results('lol'))
l = list(self.backend.search_gallery('lol'))
self.assertTrue(len(l) > 0)
v = l[0]
self.backend.fillobj(v, ('url',))
......
......@@ -43,9 +43,9 @@ class PluzzBackend(BaseBackend, ICapVideo):
with self.browser:
return self.browser.get_video(_id)
def iter_search_results(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
def search_videos(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
with self.browser:
return self.browser.iter_search_results(pattern)
return self.browser.search_videos(pattern)
def fill_video(self, video, fields):
if fields != ['thumbnail']:
......
......@@ -55,7 +55,7 @@ class PluzzBrowser(BaseBrowser):
return video
def iter_search_results(self, pattern):
def search_videos(self, pattern):
if not pattern:
self.home()
else:
......
......@@ -25,7 +25,7 @@ class PluzzTest(BackendTest):
def test_francetelevisions(self):
# If the test fails, it might be good news!
l = list(self.backend.iter_search_results('Plus belle la vie'))
l = list(self.backend.search_videos('Plus belle la vie'))
self.assertTrue(len(l) > 0)
v = l[0]
self.backend.fillobj(v, ('url',))
......
......@@ -42,9 +42,9 @@ class InaBackend(BaseBackend, ICapVideo):
def get_video(self, _id):
return self.browser.get_video(_id)
def iter_search_results(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
def search_videos(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
with self.browser:
return self.browser.iter_search_results(pattern)
return self.browser.search_videos(pattern)
def fill_video(self, video, fields):
return video
......
......@@ -41,7 +41,7 @@ class InaBrowser(BaseBrowser):
self.location(url)
return self.page.get_video(video)
def iter_search_results(self, pattern):
def search_videos(self, pattern):
self.location(self.buildurl('http://boutique.ina.fr/recherche/recherche', search=pattern.encode('utf-8')))
assert self.is_on_page(SearchPage)
return self.page.iter_videos()
......@@ -24,7 +24,7 @@ class INATest(BackendTest):
BACKEND = 'ina'
def test_ina(self):
l = list(self.backend.iter_search_results('chirac'))
l = list(self.backend.search_videos('chirac'))
self.assertTrue(len(l) > 0)
v = l[0]
self.backend.fillobj(v, ('url',))
......
......@@ -55,9 +55,9 @@ class NolifeTVBackend(BaseBackend, ICapVideo):
video = self.browser.get_video(_id)
return video
def iter_search_results(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
def search_videos(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
with self.browser:
return self.browser.iter_search_results(pattern)
return self.browser.search_videos(pattern)
def fill_video(self, video, fields):
if fields != ['thumbnail']:
......
......@@ -69,7 +69,7 @@ class NolifeTVBrowser(BaseBrowser):
assert self.is_on_page(VideoPage), 'Should be on video page.'
return self.page.get_video(video)
def iter_search_results(self, pattern):
def search_videos(self, pattern):
if not pattern:
self.home()
else:
......
......@@ -25,7 +25,7 @@ class NolifeTVTest(BackendTest):
BACKEND = 'nolifetv'
def test_nolife(self):
l = list(self.backend.iter_search_results('nolife'))
l = list(self.backend.search_videos('nolife'))
self.assertTrue(len(l) > 0)
for v in l:
try:
......
......@@ -175,7 +175,7 @@ class RadioFranceBackend(BaseBackend, ICapRadio, ICapCollection, ICapVideo):
# TODO
# http://www.franceculture.fr/recherche/key%3DYOURSEARCH%2526type%3Demission
# http://www.franceinter.fr/recherche/key%3DYOURSEARCH%2526tri%3Dpertinence%2526theme%3Ddefault%2526type%3Demission
#def iter_search_results(self, *args, **kwargs):
#def search_videos(self, *args, **kwargs):
# return []
def get_video(self, _id):
......
......@@ -44,11 +44,11 @@ class YoujizzBackend(BaseBackend, ICapVideo):
video = self.browser.get_video(_id)
return video
def iter_search_results(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
def search_videos(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
if not nsfw:
return set()
with self.browser:
return self.browser.iter_search_results(pattern)
return self.browser.search_videos(pattern)
def fill_video(self, video, fields):
if fields != ['thumbnail']:
......
......@@ -46,7 +46,7 @@ class YoujizzBrowser(BaseBrowser):
assert self.is_on_page(VideoPage), 'Should be on video page.'
return self.page.get_video(video)
def iter_search_results(self, pattern):
def search_videos(self, pattern):
if not pattern:
self.home()
else:
......
......@@ -24,9 +24,9 @@ class YoujizzTest(BackendTest):
BACKEND = 'youjizz'
def test_youjizz(self):
self.assertTrue(len(self.backend.iter_search_results('anus', nsfw=False)) == 0)
self.assertTrue(len(self.backend.search_videos('anus', nsfw=False)) == 0)
l = list(self.backend.iter_search_results('sex', nsfw=True))
l = list(self.backend.search_videos('sex', nsfw=True))
self.assertTrue(len(l) > 0)
v = l[0]
self.backend.fillobj(v, ('url',))
......
......@@ -44,11 +44,11 @@ class YoupornBackend(BaseBackend, ICapVideo):
return self.browser.get_video(_id)
SORTBY = ['relevance', 'rating', 'views', 'time']
def iter_search_results(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
def search_videos(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
if not nsfw:
return set()
with self.browser:
return self.browser.iter_search_results(pattern, self.SORTBY[sortby])
return self.browser.search_videos(pattern, self.SORTBY[sortby])
def fill_video(self, video, fields):
if fields != ['thumbnail']:
......
......@@ -43,7 +43,7 @@ class YoupornBrowser(BaseBrowser):
self.location(url)
return self.page.get_video(video)
def iter_search_results(self, pattern, sortby):
def search_videos(self, pattern, sortby):
if not pattern:
self.home()
else:
......
......@@ -24,9 +24,9 @@ class YoupornTest(BackendTest):
BACKEND = 'youporn'
def test_youporn(self):
self.assertTrue(len(self.backend.iter_search_results('penis', nsfw=False)) == 0)
self.assertTrue(len(self.backend.search_videos('penis', nsfw=False)) == 0)
l = list(self.backend.iter_search_results('ass to mouth', nsfw=True))
l = list(self.backend.search_videos('ass to mouth', nsfw=True))
self.assertTrue(len(l) > 0)
v = l[0]
self.backend.fillobj(v, ('url',))
......
......@@ -106,7 +106,7 @@ class YoutubeBackend(BaseBackend, ICapVideo):
self._set_video_url(video)
return video
def iter_search_results(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
def search_videos(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
YOUTUBE_MAX_RESULTS = 50
YOUTUBE_MAX_START_INDEX = 1000
yt_service = gdata.youtube.service.YouTubeService()
......
......@@ -24,7 +24,7 @@ class YoutubeTest(BackendTest):
BACKEND = 'youtube'
def test_youtube(self):
l = list(self.backend.iter_search_results('lol'))
l = list(self.backend.search_videos('lol'))
self.assertTrue(len(l) > 0)
v = l[0]
self.backend.fillobj(v, ('url',))
......
......@@ -74,7 +74,7 @@ class Galleroob(ReplApplication):
self.set_formatter_header(u'Search pattern: %s' %
pattern if pattern else u'Latest galleries')
for backend, gallery in self.do('iter_search_results',
for backend, gallery in self.do('search_gallery',
pattern=pattern, max_results=self.options.count):
self.add_object(gallery)
self.format(gallery)
......
......@@ -108,7 +108,7 @@ class MainWindow(QtMainWindow):
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
self.process = QtDo(self.weboob, self.addVideo)
self.process.do('iter_search_results', pattern, self.ui.sortbyEdit.currentIndex(), nsfw=True, max_results=20, backends=backend_name)
self.process.do('search_videos', pattern, self.ui.sortbyEdit.currentIndex(), nsfw=True, max_results=20, backends=backend_name)
def addVideo(self, backend, video):
if not backend:
......
......@@ -224,7 +224,7 @@ class Videoob(ReplApplication):
self.set_formatter_header(u'Search pattern: %s' % pattern if pattern else u'Latest videos')
self.change_path('/search')
for backend, video in self.do('iter_search_results', pattern=pattern, nsfw=self.nsfw,
for backend, video in self.do('search_videos', pattern=pattern, nsfw=self.nsfw,
max_results=self.options.count):
self.add_object(video)
self.format(video)
......
......@@ -86,7 +86,7 @@ class ICapGallery(IBaseCap):
SEARCH_VIEWS,
SEARCH_DATE) = range(4)
def iter_search_results(self, pattern=None, sortby=SEARCH_RELEVANCE, max_results=None):
def search_gallery(self, pattern=None, sortby=SEARCH_RELEVANCE, max_results=None):
"""
Iter results of a search on a pattern. Note that if pattern is None,
it get the latest videos.
......
......@@ -70,7 +70,7 @@ class ICapVideo(IBaseCap):
SEARCH_VIEWS,
SEARCH_DATE) = range(4)
def iter_search_results(self, pattern=None, sortby=SEARCH_RELEVANCE, nsfw=False, max_results=None):
def search_videos(self, pattern=None, sortby=SEARCH_RELEVANCE, nsfw=False, max_results=None):
"""
Iter results of a search on a pattern. Note that if pattern is None,
it get the latest videos.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment