new parameter 'sortby' to searches (relevance, rating, views and date)
This commit is contained in:
parent
f1ee6d674a
commit
911cdc134b
5 changed files with 43 additions and 6 deletions
|
|
@ -53,8 +53,9 @@ class YoupornBackend(BaseBackend, ICapVideoProvider):
|
||||||
def get_video(self, _id):
|
def get_video(self, _id):
|
||||||
return self.browser.get_video(_id)
|
return self.browser.get_video(_id)
|
||||||
|
|
||||||
def iter_search_results(self, pattern=None):
|
SORTBY = ['relevance', 'rating', 'views', 'time']
|
||||||
return self.browser.iter_search_results(pattern)
|
def iter_search_results(self, pattern=None, sortby=ICapVideoProvider.SEARCH_RELEVANCE):
|
||||||
|
return self.browser.iter_search_results(pattern, self.SORTBY[sortby])
|
||||||
|
|
||||||
@need_url
|
@need_url
|
||||||
def iter_page_urls(self, mozaic_url):
|
def iter_page_urls(self, mozaic_url):
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,11 @@ class YoupornBrowser(BaseBrowser):
|
||||||
else:
|
else:
|
||||||
return str(_id)
|
return str(_id)
|
||||||
|
|
||||||
def iter_search_results(self, pattern):
|
def iter_search_results(self, pattern, sortby):
|
||||||
if not pattern:
|
if not pattern:
|
||||||
self.home()
|
self.home()
|
||||||
else:
|
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)
|
assert self.is_on_page(IndexPage)
|
||||||
return self.page.iter_videos()
|
return self.page.iter_videos()
|
||||||
|
|
|
||||||
|
|
@ -41,12 +41,18 @@ class ICapVideoProvider(ICap):
|
||||||
def iter_page_urls(self, mozaic_url):
|
def iter_page_urls(self, mozaic_url):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def iter_search_results(self, pattern=None):
|
(SEARCH_RELEVANCE,
|
||||||
|
SEARCH_RATING,
|
||||||
|
SEARCH_VIEWS,
|
||||||
|
SEARCH_DATE) = range(4)
|
||||||
|
|
||||||
|
def iter_search_results(self, pattern=None, sortby=SEARCH_RELEVANCE):
|
||||||
"""
|
"""
|
||||||
Iter results of a search on a pattern. Note that if pattern is None,
|
Iter results of a search on a pattern. Note that if pattern is None,
|
||||||
it get the latest videos.
|
it get the latest videos.
|
||||||
|
|
||||||
@param pattern [str] pattern to search on
|
@param pattern [str] pattern to search on
|
||||||
|
@param sortby [enum] sort by...
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ class MainWindow(QtMainWindow):
|
||||||
for backend in self.weboob.iter_backends():
|
for backend in self.weboob.iter_backends():
|
||||||
if backend_name and backend.name != backend_name:
|
if backend_name and backend.name != backend_name:
|
||||||
continue
|
continue
|
||||||
for video in backend.iter_search_results(pattern):
|
for video in backend.iter_search_results(pattern, self.ui.sortbyEdit.currentIndex()):
|
||||||
minivideo = MiniVideo(backend, video)
|
minivideo = MiniVideo(backend, video)
|
||||||
self.ui.scrollAreaContent.layout().addWidget(minivideo)
|
self.ui.scrollAreaContent.layout().addWidget(minivideo)
|
||||||
self.minivideos.append(minivideo)
|
self.minivideos.append(minivideo)
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,36 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="searchEdit"/>
|
<widget class="QLineEdit" name="searchEdit"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="sortbyEdit">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Relevance</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Rating</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Duration</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Date</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="backendEdit"/>
|
<widget class="QComboBox" name="backendEdit"/>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue