new parameter 'sortby' to searches (relevance, rating, views and date)

This commit is contained in:
Romain Bignon 2010-04-17 17:28:29 +02:00
commit 911cdc134b
5 changed files with 43 additions and 6 deletions

View file

@ -53,8 +53,9 @@ class YoupornBackend(BaseBackend, ICapVideoProvider):
def get_video(self, _id):
return self.browser.get_video(_id)
def iter_search_results(self, pattern=None):
return self.browser.iter_search_results(pattern)
SORTBY = ['relevance', 'rating', 'views', 'time']
def iter_search_results(self, pattern=None, sortby=ICapVideoProvider.SEARCH_RELEVANCE):
return self.browser.iter_search_results(pattern, self.SORTBY[sortby])
@need_url
def iter_page_urls(self, mozaic_url):

View file

@ -43,11 +43,11 @@ class YoupornBrowser(BaseBrowser):
else:
return str(_id)
def iter_search_results(self, pattern):
def iter_search_results(self, pattern, sortby):
if not pattern:
self.home()
else:
self.location('/search?query=%s' % urllib.quote_plus(pattern))
self.location('/search/%s?query=%s' % (sortby, urllib.quote_plus(pattern)))
assert self.is_on_page(IndexPage)
return self.page.iter_videos()