simplify search command code
This commit is contained in:
parent
9d7d8692ba
commit
9fe8053052
2 changed files with 5 additions and 9 deletions
|
|
@ -39,6 +39,9 @@ class Video(object):
|
||||||
self.preview_url = preview_url
|
self.preview_url = preview_url
|
||||||
self.nsfw = nsfw
|
self.nsfw = nsfw
|
||||||
|
|
||||||
|
@property
|
||||||
|
def formatted_duration(self):
|
||||||
|
return '%d:%02d:%02d' % (self.duration / 3600, (self.duration % 3600 / 60), self.duration % 60)
|
||||||
class ICapVideoProvider(ICap):
|
class ICapVideoProvider(ICap):
|
||||||
def iter_page_urls(self, mozaic_url):
|
def iter_page_urls(self, mozaic_url):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
|
||||||
|
|
@ -67,15 +67,8 @@ class Videoob(ConsoleApplication):
|
||||||
results['BEFORE'] = u'Last videos'
|
results['BEFORE'] = u'Last videos'
|
||||||
results['HEADER'] = ('ID', 'Title', 'Duration')
|
results['HEADER'] = ('ID', 'Title', 'Duration')
|
||||||
for backend in self.weboob.iter_backends():
|
for backend in self.weboob.iter_backends():
|
||||||
try:
|
results[backend.name] = [(video.id, video.title, video.formatted_duration) for video in
|
||||||
iterator = backend.iter_search_results(pattern)
|
backend.iter_search_results(pattern=pattern)]
|
||||||
except NotImplementedError:
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
rows = []
|
|
||||||
for video in iterator:
|
|
||||||
rows.append((video.id, video.title, '%d:%02d:%02d' % (video.duration/3600, (video.duration%3600/60), video.duration%60)))
|
|
||||||
results[backend.name] = rows
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@ConsoleApplication.command('Get video file URL from page URL')
|
@ConsoleApplication.command('Get video file URL from page URL')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue