remove parameter max_results from all capabilities
This commit is contained in:
parent
c108ca3fc5
commit
b99d599aa9
30 changed files with 84 additions and 80 deletions
|
|
@ -43,7 +43,7 @@ class ArretSurImagesBackend(BaseBackend, ICapVideo, ICapCollection):
|
||||||
def create_default_browser(self):
|
def create_default_browser(self):
|
||||||
return self.create_browser(self.config['login'].get(), self.config['password'].get())
|
return self.create_browser(self.config['login'].get(), self.config['password'].get())
|
||||||
|
|
||||||
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
|
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.search_videos(pattern)
|
return self.browser.search_videos(pattern)
|
||||||
# raise UserError('Search does not work on ASI website, use ls latest command')
|
# raise UserError('Search does not work on ASI website, use ls latest command')
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ class ArteBackend(BaseBackend, ICapVideo, ICapCollection):
|
||||||
else:
|
else:
|
||||||
return self.browser.get_video(_id)
|
return self.browser.get_video(_id)
|
||||||
|
|
||||||
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
|
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.search_videos(pattern)
|
return self.browser.search_videos(pattern)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ class CanalplusBackend(BaseBackend, ICapVideo, ICapCollection):
|
||||||
def create_default_browser(self):
|
def create_default_browser(self):
|
||||||
return self.create_browser(quality=self.config['quality'].get())
|
return self.create_browser(quality=self.config['quality'].get())
|
||||||
|
|
||||||
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
|
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.search_videos(pattern)
|
return self.browser.search_videos(pattern)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class CappedBackend(BaseBackend, ICapVideo, ICapCollection):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.get_video(_id)
|
return self.browser.get_video(_id)
|
||||||
|
|
||||||
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=None, max_results=None):
|
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=None):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.search_videos(pattern)
|
return self.browser.search_videos(pattern)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class DailymotionBackend(BaseBackend, ICapVideo, ICapCollection):
|
||||||
|
|
||||||
SORTBY = ['relevance', 'rated', 'visited', None]
|
SORTBY = ['relevance', 'rated', 'visited', None]
|
||||||
|
|
||||||
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
|
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.search_videos(pattern, self.SORTBY[sortby])
|
return self.browser.search_videos(pattern, self.SORTBY[sortby])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ class EHentaiBackend(BaseBackend, ICapGallery, ICapCollection):
|
||||||
password = None
|
password = None
|
||||||
return self.create_browser(self.config['domain'].get(), username, password)
|
return self.create_browser(self.config['domain'].get(), username, password)
|
||||||
|
|
||||||
def search_gallery(self, pattern, sortby=None, max_results=None):
|
def search_gallery(self, pattern, sortby=None):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.search_gallery(pattern)
|
return self.browser.search_gallery(pattern)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class EuroparlBackend(BaseBackend, ICapVideo, ICapCollection):
|
||||||
|
|
||||||
SORTBY = ['relevance', 'rating', 'views', 'time']
|
SORTBY = ['relevance', 'rating', 'views', 'time']
|
||||||
|
|
||||||
# def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
|
# def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||||
# with self.browser:
|
# with self.browser:
|
||||||
# return self.browser.search_videos(pattern, self.SORTBY[sortby])
|
# return self.browser.search_videos(pattern, self.SORTBY[sortby])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class PluzzBackend(BaseBackend, ICapVideo, ICapCollection):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.get_video(_id)
|
return self.browser.get_video(_id)
|
||||||
|
|
||||||
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
|
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.search_videos(pattern)
|
return self.browser.search_videos(pattern)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ class GDCVaultBackend(BaseBackend, ICapVideo, ICapCollection):
|
||||||
|
|
||||||
SORTBY = ['relevance', 'rating', 'views', 'time']
|
SORTBY = ['relevance', 'rating', 'views', 'time']
|
||||||
|
|
||||||
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
|
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.search_videos(pattern, self.SORTBY[sortby])
|
return self.browser.search_videos(pattern, self.SORTBY[sortby])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,10 +42,9 @@ class GroovesharkBackend(BaseBackend, ICapVideo):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
video.thumbnail.data = self.browser.readurl(video.thumbnail.url)
|
video.thumbnail.data = self.browser.readurl(video.thumbnail.url)
|
||||||
|
|
||||||
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=10):
|
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
for video in self.browser.search_videos(pattern, max_results):
|
return self.browser.search_videos(pattern)
|
||||||
yield video
|
|
||||||
|
|
||||||
def get_video(self, _id):
|
def get_video(self, _id):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ class GroovesharkBrowser(BaseBrowser):
|
||||||
def home(self):
|
def home(self):
|
||||||
self.get_communication_token()
|
self.get_communication_token()
|
||||||
|
|
||||||
def search_videos(self, pattern, max_results):
|
def search_videos(self, pattern):
|
||||||
method = 'getResultsFromSearch'
|
method = 'getResultsFromSearch'
|
||||||
|
|
||||||
parameters = {}
|
parameters = {}
|
||||||
|
|
@ -75,16 +75,14 @@ class GroovesharkBrowser(BaseBrowser):
|
||||||
|
|
||||||
response = self.API_post(method, parameters, self.create_token(method))
|
response = self.API_post(method, parameters, self.create_token(method))
|
||||||
|
|
||||||
songs = self.create_video_from_songs_result(response['result']['result']['Songs'], max_results)
|
songs = self.create_video_from_songs_result(response['result']['result']['Songs'])
|
||||||
#playlists = self.create_video_from_playlist_result(response['result']['result']['Playlists'])
|
#playlists = self.create_video_from_playlist_result(response['result']['result']['Playlists'])
|
||||||
#albums = self.create_video_from_albums_result(response['result']['result']['Albums'])
|
#albums = self.create_video_from_albums_result(response['result']['result']['Albums'])
|
||||||
|
|
||||||
return songs
|
return songs
|
||||||
|
|
||||||
def create_video_from_songs_result(self, songs, max_results):
|
def create_video_from_songs_result(self, songs):
|
||||||
self.VIDEOS_FROM_SONG_RESULTS = []
|
self.VIDEOS_FROM_SONG_RESULTS = []
|
||||||
if max_results:
|
|
||||||
songs = songs[0:max_results]
|
|
||||||
|
|
||||||
for song in songs:
|
for song in songs:
|
||||||
video = BaseVideo(song['SongID'])
|
video = BaseVideo(song['SongID'])
|
||||||
|
|
@ -99,7 +97,8 @@ class GroovesharkBrowser(BaseBrowser):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
video.date = NotAvailable
|
video.date = NotAvailable
|
||||||
self.VIDEOS_FROM_SONG_RESULTS.append(video)
|
self.VIDEOS_FROM_SONG_RESULTS.append(video)
|
||||||
return self.VIDEOS_FROM_SONG_RESULTS
|
|
||||||
|
yield video
|
||||||
|
|
||||||
def create_video_from_playlist_result(self, playlists):
|
def create_video_from_playlist_result(self, playlists):
|
||||||
videos = []
|
videos = []
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ class InaBackend(BaseBackend, ICapVideo):
|
||||||
def get_video(self, _id):
|
def get_video(self, _id):
|
||||||
return self.browser.get_video(_id)
|
return self.browser.get_video(_id)
|
||||||
|
|
||||||
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
|
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.search_videos(pattern)
|
return self.browser.search_videos(pattern)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,9 +65,8 @@ class MediawikiBackend(BaseBackend, ICapContent):
|
||||||
content.content = data
|
content.content = data
|
||||||
return content
|
return content
|
||||||
|
|
||||||
def iter_revisions(self, _id, max_results=10):
|
def iter_revisions(self, _id):
|
||||||
for rev in self.browser.iter_wiki_revisions(_id, max_results):
|
return self.browser.iter_wiki_revisions(_id)
|
||||||
yield rev
|
|
||||||
|
|
||||||
def push_content(self, content, message=None, minor=False):
|
def push_content(self, content, message=None, minor=False):
|
||||||
self.browser.set_wiki_source(content, message, minor)
|
self.browser.set_wiki_source(content, message, minor)
|
||||||
|
|
|
||||||
|
|
@ -148,30 +148,43 @@ class MediawikiBrowser(BaseBrowser):
|
||||||
data['lgtoken'] = result['login']['token']
|
data['lgtoken'] = result['login']['token']
|
||||||
self.API_post(data)
|
self.API_post(data)
|
||||||
|
|
||||||
def iter_wiki_revisions(self, page, nb_entries):
|
def iter_wiki_revisions(self, page):
|
||||||
"""
|
"""
|
||||||
Yield 'Revision' objects for the last <nb_entries> revisions of the specified page.
|
Yield 'Revision' objects.
|
||||||
"""
|
"""
|
||||||
if len(self.username) > 0 and not self.is_logged():
|
if len(self.username) > 0 and not self.is_logged():
|
||||||
self.login()
|
self.login()
|
||||||
data = {'action': 'query',
|
|
||||||
'titles': page,
|
|
||||||
'prop': 'revisions',
|
|
||||||
'rvprop': 'ids|timestamp|comment|user|flags',
|
|
||||||
'rvlimit': str(nb_entries),
|
|
||||||
}
|
|
||||||
|
|
||||||
result = self.API_get(data)
|
MAX_RESULTS = 50
|
||||||
pageid = str(result['query']['pages'].keys()[0])
|
results = MAX_RESULTS
|
||||||
|
last_id = None
|
||||||
|
|
||||||
if pageid != "-1":
|
while results == MAX_RESULTS:
|
||||||
for rev in result['query']['pages'][pageid]['revisions']:
|
data = {'action': 'query',
|
||||||
rev_content = Revision(str(rev['revid']))
|
'titles': page,
|
||||||
rev_content.comment = rev['comment']
|
'prop': 'revisions',
|
||||||
rev_content.author = rev['user']
|
'rvprop': 'ids|timestamp|comment|user|flags',
|
||||||
rev_content.timestamp = datetime.datetime.strptime(rev['timestamp'], '%Y-%m-%dT%H:%M:%SZ')
|
'rvlimit': str(MAX_RESULTS),
|
||||||
rev_content.minor = 'minor' in rev
|
}
|
||||||
yield rev_content
|
|
||||||
|
if last_id is not None:
|
||||||
|
data['rvstartid'] = last_id
|
||||||
|
|
||||||
|
result = self.API_get(data)
|
||||||
|
pageid = str(result['query']['pages'].keys()[0])
|
||||||
|
|
||||||
|
results = 0
|
||||||
|
if pageid != "-1":
|
||||||
|
for rev in result['query']['pages'][pageid]['revisions']:
|
||||||
|
rev_content = Revision(str(rev['revid']))
|
||||||
|
rev_content.comment = rev['comment']
|
||||||
|
rev_content.author = rev['user']
|
||||||
|
rev_content.timestamp = datetime.datetime.strptime(rev['timestamp'], '%Y-%m-%dT%H:%M:%SZ')
|
||||||
|
rev_content.minor = 'minor' in rev
|
||||||
|
yield rev_content
|
||||||
|
|
||||||
|
last_id = rev_content.id
|
||||||
|
results += 1
|
||||||
|
|
||||||
def home(self):
|
def home(self):
|
||||||
# We don't need to change location, we're using the JSON API here.
|
# We don't need to change location, we're using the JSON API here.
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class NolifeTVBackend(BaseBackend, ICapVideo, ICapCollection):
|
||||||
video = self.browser.get_video(_id)
|
video = self.browser.get_video(_id)
|
||||||
return video
|
return video
|
||||||
|
|
||||||
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
|
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.search_videos(pattern)
|
return self.browser.search_videos(pattern)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class TricTracTVBackend(BaseBackend, ICapVideo):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.get_video(_id)
|
return self.browser.get_video(_id)
|
||||||
|
|
||||||
def search_videos(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
|
def search_videos(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.search_videos(pattern)
|
return self.browser.search_videos(pattern)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class VimeoBackend(BaseBackend, ICapVideo, ICapCollection):
|
||||||
|
|
||||||
SORTBY = ['relevance', 'rating', 'views', 'time']
|
SORTBY = ['relevance', 'rating', 'views', 'time']
|
||||||
|
|
||||||
# def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
|
# def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||||
# with self.browser:
|
# with self.browser:
|
||||||
# return self.browser.search_videos(pattern, self.SORTBY[sortby])
|
# return self.browser.search_videos(pattern, self.SORTBY[sortby])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ class YoujizzBackend(BaseBackend, ICapVideo, ICapCollection):
|
||||||
video = self.browser.get_video(_id)
|
video = self.browser.get_video(_id)
|
||||||
return video
|
return video
|
||||||
|
|
||||||
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
|
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||||
if not nsfw:
|
if not nsfw:
|
||||||
return set()
|
return set()
|
||||||
with self.browser:
|
with self.browser:
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class YoupornBackend(BaseBackend, ICapVideo, ICapCollection):
|
||||||
|
|
||||||
SORTBY = ['relevance', 'rating', 'views', 'time']
|
SORTBY = ['relevance', 'rating', 'views', 'time']
|
||||||
|
|
||||||
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
|
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||||
if not nsfw:
|
if not nsfw:
|
||||||
return set()
|
return set()
|
||||||
with self.browser:
|
with self.browser:
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ class YoutubeBackend(BaseBackend, ICapVideo, ICapCollection):
|
||||||
video.set_empty_fields(NotAvailable)
|
video.set_empty_fields(NotAvailable)
|
||||||
return video
|
return video
|
||||||
|
|
||||||
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
|
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||||
YOUTUBE_MAX_RESULTS = 50
|
YOUTUBE_MAX_RESULTS = 50
|
||||||
YOUTUBE_MAX_START_INDEX = 1000
|
YOUTUBE_MAX_START_INDEX = 1000
|
||||||
yt_service = gdata.youtube.service.YouTubeService()
|
yt_service = gdata.youtube.service.YouTubeService()
|
||||||
|
|
@ -133,27 +133,22 @@ class YoutubeBackend(BaseBackend, ICapVideo, ICapCollection):
|
||||||
query.orderby = ('relevance', 'rating', 'viewCount', 'published')[sortby]
|
query.orderby = ('relevance', 'rating', 'viewCount', 'published')[sortby]
|
||||||
query.racy = 'include' if nsfw else 'exclude'
|
query.racy = 'include' if nsfw else 'exclude'
|
||||||
|
|
||||||
if max_results is None or max_results > YOUTUBE_MAX_RESULTS:
|
query.max_results = YOUTUBE_MAX_RESULTS
|
||||||
query_max_results = YOUTUBE_MAX_RESULTS
|
|
||||||
else:
|
|
||||||
query_max_results = max_results
|
|
||||||
query.max_results = query_max_results
|
|
||||||
|
|
||||||
if start_index > YOUTUBE_MAX_START_INDEX:
|
if start_index > YOUTUBE_MAX_START_INDEX:
|
||||||
return
|
return
|
||||||
query.start_index = start_index
|
query.start_index = start_index
|
||||||
start_index += query_max_results
|
start_index += YOUTUBE_MAX_RESULTS
|
||||||
|
|
||||||
feed = yt_service.YouTubeQuery(query)
|
feed = yt_service.YouTubeQuery(query)
|
||||||
for entry in feed.entry:
|
for entry in feed.entry:
|
||||||
yield self._entry2video(entry)
|
yield self._entry2video(entry)
|
||||||
nb_yielded += 1
|
nb_yielded += 1
|
||||||
if nb_yielded == max_results:
|
|
||||||
return
|
|
||||||
|
|
||||||
if nb_yielded < query_max_results:
|
if nb_yielded < YOUTUBE_MAX_RESULTS:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def latest_videos(self):
|
def latest_videos(self):
|
||||||
return self.search_videos(None, ICapVideo.SEARCH_DATE)
|
return self.search_videos(None, ICapVideo.SEARCH_DATE)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,7 @@ class Galleroob(ReplApplication):
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
self.start_format(pattern=pattern)
|
self.start_format(pattern=pattern)
|
||||||
for backend, gallery in self.do('search_gallery', pattern=pattern,
|
for backend, gallery in self.do('search_gallery', pattern=pattern):
|
||||||
max_results=self.options.count):
|
|
||||||
self.cached_format(gallery)
|
self.cached_format(gallery)
|
||||||
|
|
||||||
def do_download(self, line):
|
def do_download(self, line):
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ from .minivideo import MiniVideo
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QtMainWindow):
|
class MainWindow(QtMainWindow):
|
||||||
def __init__(self, config, weboob, parent=None):
|
def __init__(self, config, weboob, app, parent=None):
|
||||||
QtMainWindow.__init__(self, parent)
|
QtMainWindow.__init__(self, parent)
|
||||||
self.ui = Ui_MainWindow()
|
self.ui = Ui_MainWindow()
|
||||||
self.ui.setupUi(self)
|
self.ui.setupUi(self)
|
||||||
|
|
@ -39,6 +39,7 @@ class MainWindow(QtMainWindow):
|
||||||
self.config = config
|
self.config = config
|
||||||
self.weboob = weboob
|
self.weboob = weboob
|
||||||
self.minivideos = []
|
self.minivideos = []
|
||||||
|
self.app = app
|
||||||
|
|
||||||
self.ui.sortbyEdit.setCurrentIndex(int(self.config.get('settings', 'sortby')))
|
self.ui.sortbyEdit.setCurrentIndex(int(self.config.get('settings', 'sortby')))
|
||||||
self.ui.nsfwCheckBox.setChecked(int(self.config.get('settings', 'nsfw')))
|
self.ui.nsfwCheckBox.setChecked(int(self.config.get('settings', 'nsfw')))
|
||||||
|
|
@ -109,7 +110,7 @@ class MainWindow(QtMainWindow):
|
||||||
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
|
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
|
||||||
|
|
||||||
self.process = QtDo(self.weboob, self.addVideo)
|
self.process = QtDo(self.weboob, self.addVideo)
|
||||||
self.process.do('search_videos', pattern, self.ui.sortbyEdit.currentIndex(), nsfw=True, max_results=20, backends=backend_name)
|
self.process.do(self.app._do_complete, 20, (), 'search_videos', pattern, self.ui.sortbyEdit.currentIndex(), nsfw=True, backends=backend_name)
|
||||||
|
|
||||||
def addVideo(self, backend, video):
|
def addVideo(self, backend, video):
|
||||||
if not backend:
|
if not backend:
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,6 @@ class QVideoob(QtApplication):
|
||||||
self.load_backends(ICapVideo)
|
self.load_backends(ICapVideo)
|
||||||
self.load_config()
|
self.load_config()
|
||||||
|
|
||||||
self.main_window = MainWindow(self.config, self.weboob)
|
self.main_window = MainWindow(self.config, self.weboob, self)
|
||||||
self.main_window.show()
|
self.main_window.show()
|
||||||
return self.weboob.loop()
|
return self.weboob.loop()
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ from PyQt4.QtCore import SIGNAL
|
||||||
from PyQt4.QtGui import QMessageBox, QTableWidgetItem
|
from PyQt4.QtGui import QMessageBox, QTableWidgetItem
|
||||||
from PyQt4.QtCore import Qt
|
from PyQt4.QtCore import Qt
|
||||||
|
|
||||||
|
from weboob.tools.application.base import MoreResultsAvailable
|
||||||
from weboob.tools.application.qt import QtMainWindow, QtDo
|
from weboob.tools.application.qt import QtMainWindow, QtDo
|
||||||
from weboob.tools.application.qt.backendcfg import BackendCfg
|
from weboob.tools.application.qt.backendcfg import BackendCfg
|
||||||
from weboob.capabilities.content import ICapContent
|
from weboob.capabilities.content import ICapContent
|
||||||
|
|
@ -32,7 +33,7 @@ from .ui.main_window_ui import Ui_MainWindow
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QtMainWindow):
|
class MainWindow(QtMainWindow):
|
||||||
def __init__(self, config, weboob, parent=None):
|
def __init__(self, config, weboob, app, parent=None):
|
||||||
QtMainWindow.__init__(self, parent)
|
QtMainWindow.__init__(self, parent)
|
||||||
self.ui = Ui_MainWindow()
|
self.ui = Ui_MainWindow()
|
||||||
self.ui.setupUi(self)
|
self.ui.setupUi(self)
|
||||||
|
|
@ -40,6 +41,7 @@ class MainWindow(QtMainWindow):
|
||||||
self.config = config
|
self.config = config
|
||||||
self.weboob = weboob
|
self.weboob = weboob
|
||||||
self.backend = None
|
self.backend = None
|
||||||
|
self.app = app
|
||||||
|
|
||||||
self.connect(self.ui.idEdit,
|
self.connect(self.ui.idEdit,
|
||||||
SIGNAL("returnPressed()"),
|
SIGNAL("returnPressed()"),
|
||||||
|
|
@ -217,9 +219,11 @@ class MainWindow(QtMainWindow):
|
||||||
self.process = QtDo(self.weboob,
|
self.process = QtDo(self.weboob,
|
||||||
self._gotRevision,
|
self._gotRevision,
|
||||||
self._errorHistory)
|
self._errorHistory)
|
||||||
self.process.do('iter_revisions',
|
self.process.do(self.app._do_complete,
|
||||||
|
self.ui.nbRevBox.value(),
|
||||||
|
(),
|
||||||
|
'iter_revisions',
|
||||||
self.content.id,
|
self.content.id,
|
||||||
max_results=self.ui.nbRevBox.value(),
|
|
||||||
backends=(self.backend,))
|
backends=(self.backend,))
|
||||||
|
|
||||||
def _gotRevision(self, backend, revision):
|
def _gotRevision(self, backend, revision):
|
||||||
|
|
@ -256,6 +260,9 @@ class MainWindow(QtMainWindow):
|
||||||
|
|
||||||
def _errorHistory(self, backend, error, backtrace):
|
def _errorHistory(self, backend, error, backtrace):
|
||||||
""" Loading the history has failed """
|
""" Loading the history has failed """
|
||||||
|
if isinstance(error, MoreResultsAvailable):
|
||||||
|
return
|
||||||
|
|
||||||
content = unicode(self.tr('Unable to load history:\n%s\n')) % to_unicode(error)
|
content = unicode(self.tr('Unable to load history:\n%s\n')) % to_unicode(error)
|
||||||
if logging.root.level == logging.DEBUG:
|
if logging.root.level == logging.DEBUG:
|
||||||
content += '\n%s\n' % to_unicode(backtrace)
|
content += '\n%s\n' % to_unicode(backtrace)
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,6 @@ class QWebContentEdit(QtApplication):
|
||||||
|
|
||||||
def main(self, argv):
|
def main(self, argv):
|
||||||
self.load_backends(ICapContent, storage=self.create_storage())
|
self.load_backends(ICapContent, storage=self.create_storage())
|
||||||
self.main_window = MainWindow(self.config, self.weboob)
|
self.main_window = MainWindow(self.config, self.weboob, self)
|
||||||
self.main_window.show()
|
self.main_window.show()
|
||||||
return self.weboob.loop()
|
return self.weboob.loop()
|
||||||
|
|
|
||||||
|
|
@ -216,6 +216,5 @@ class Videoob(ReplApplication):
|
||||||
|
|
||||||
self.change_path([u'search'])
|
self.change_path([u'search'])
|
||||||
self.start_format(pattern=pattern)
|
self.start_format(pattern=pattern)
|
||||||
for backend, video in self.do('search_videos', pattern=pattern, nsfw=self.nsfw,
|
for backend, video in self.do('search_videos', pattern=pattern, nsfw=self.nsfw):
|
||||||
max_results=self.options.count):
|
|
||||||
self.cached_format(video)
|
self.cached_format(video)
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import codecs
|
||||||
|
|
||||||
from weboob.core.bcall import CallErrors
|
from weboob.core.bcall import CallErrors
|
||||||
from weboob.capabilities.content import ICapContent, Revision
|
from weboob.capabilities.content import ICapContent, Revision
|
||||||
from weboob.tools.application.repl import ReplApplication
|
from weboob.tools.application.repl import ReplApplication, defaultcount
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['WebContentEdit']
|
__all__ = ['WebContentEdit']
|
||||||
|
|
@ -144,6 +144,7 @@ class WebContentEdit(ReplApplication):
|
||||||
if len(errors.errors) > 0:
|
if len(errors.errors) > 0:
|
||||||
raise errors
|
raise errors
|
||||||
|
|
||||||
|
@defaultcount(10)
|
||||||
def do_log(self, line):
|
def do_log(self, line):
|
||||||
"""
|
"""
|
||||||
log ID
|
log ID
|
||||||
|
|
@ -160,7 +161,7 @@ class WebContentEdit(ReplApplication):
|
||||||
_id = _id.encode('utf-8')
|
_id = _id.encode('utf-8')
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
for backend, revision in self.do('iter_revisions', _id, max_results=self.options.count, backends=backend_names):
|
for backend, revision in self.do('iter_revisions', _id, backends=backend_names):
|
||||||
self.format(revision)
|
self.format(revision)
|
||||||
|
|
||||||
def do_get(self, line):
|
def do_get(self, line):
|
||||||
|
|
|
||||||
|
|
@ -57,14 +57,12 @@ class ICapContent(IBaseCap):
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def iter_revisions(self, id, max_results=10):
|
def iter_revisions(self, id):
|
||||||
"""
|
"""
|
||||||
Iter revisions of a content.
|
Iter revisions of a content.
|
||||||
|
|
||||||
:param id: id of content
|
:param id: id of content
|
||||||
:type id: str
|
:type id: str
|
||||||
:param max_results: maximum results
|
|
||||||
:type max_results: int
|
|
||||||
:rtype: iter[:class:`Revision`]
|
:rtype: iter[:class:`Revision`]
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ class ICapGallery(IBaseCap):
|
||||||
SEARCH_VIEWS,
|
SEARCH_VIEWS,
|
||||||
SEARCH_DATE) = range(4)
|
SEARCH_DATE) = range(4)
|
||||||
|
|
||||||
def search_gallery(self, pattern, sortby=SEARCH_RELEVANCE, max_results=None):
|
def search_gallery(self, pattern, sortby=SEARCH_RELEVANCE):
|
||||||
"""
|
"""
|
||||||
Iter results of a search on a pattern.
|
Iter results of a search on a pattern.
|
||||||
|
|
||||||
|
|
@ -119,10 +119,6 @@ class ICapGallery(IBaseCap):
|
||||||
:type pattern: str
|
:type pattern: str
|
||||||
:param sortby: sort by...
|
:param sortby: sort by...
|
||||||
:type sortby: SEARCH_*
|
:type sortby: SEARCH_*
|
||||||
:param nsfw: include non-suitable for work videos if True
|
|
||||||
:type nsfw: bool
|
|
||||||
:param max_results: maximum number of results to return
|
|
||||||
:type max_results: int
|
|
||||||
:rtype: :class:`BaseGallery`
|
:rtype: :class:`BaseGallery`
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ class ICapVideo(IBaseCap):
|
||||||
SEARCH_VIEWS,
|
SEARCH_VIEWS,
|
||||||
SEARCH_DATE) = range(4)
|
SEARCH_DATE) = range(4)
|
||||||
|
|
||||||
def search_videos(self, pattern, sortby=SEARCH_RELEVANCE, nsfw=False, max_results=None):
|
def search_videos(self, pattern, sortby=SEARCH_RELEVANCE, nsfw=False):
|
||||||
"""
|
"""
|
||||||
Iter results of a search on a pattern.
|
Iter results of a search on a pattern.
|
||||||
|
|
||||||
|
|
@ -77,8 +77,6 @@ class ICapVideo(IBaseCap):
|
||||||
:param sortby: sort by... (use SEARCH_* constants)
|
:param sortby: sort by... (use SEARCH_* constants)
|
||||||
:param nsfw: include non-suitable for work videos if True
|
:param nsfw: include non-suitable for work videos if True
|
||||||
:type nsfw: bool
|
:type nsfw: bool
|
||||||
:param max_results: maximum number of results to return
|
|
||||||
:type max_results: int
|
|
||||||
:rtype: iter[:class:`BaseVideo`]
|
:rtype: iter[:class:`BaseVideo`]
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue