enable backends with CLI option
This commit is contained in:
parent
d0f4ad7021
commit
44b57a775d
1 changed files with 20 additions and 17 deletions
|
|
@ -25,16 +25,27 @@ class Videoob(ConsoleApplication):
|
||||||
APPNAME = 'videoob'
|
APPNAME = 'videoob'
|
||||||
CONFIG = {}
|
CONFIG = {}
|
||||||
|
|
||||||
|
def configure_parser(self, parser):
|
||||||
|
parser.add_option('-b', '--backends', help='what backend(s) to enable (comma separated)')
|
||||||
|
|
||||||
def main(self, argv):
|
def main(self, argv):
|
||||||
self.weboob.load_modules(ICapVideoProvider)
|
self.weboob.load_modules(ICapVideoProvider)
|
||||||
|
self.enabled_backends = None
|
||||||
|
if self.options.backends:
|
||||||
|
self.enabled_backends = self.options.backends.split(',')
|
||||||
return self.process_command(*argv[1:])
|
return self.process_command(*argv[1:])
|
||||||
|
|
||||||
|
def iter_enabled_backends(self):
|
||||||
|
for backend in self.weboob.iter_backends(ICapVideoProvider):
|
||||||
|
if self.enabled_backends is not None and backend.NAME not in self.enabled_backends:
|
||||||
|
continue
|
||||||
|
yield backend
|
||||||
|
|
||||||
@ConsoleApplication.command('Get video information')
|
@ConsoleApplication.command('Get video information')
|
||||||
def command_info(self, _id):
|
def command_info(self, _id):
|
||||||
for backend in self.weboob.iter_backends(ICapVideoProvider):
|
for backend in self.iter_enabled_backends():
|
||||||
try:
|
video = backend.get_video(_id)
|
||||||
video = backend.get_video(_id)
|
if video is None:
|
||||||
except NotImplementedError:
|
|
||||||
continue
|
continue
|
||||||
print u'.------------------------------------------------------------------------------.'
|
print u'.------------------------------------------------------------------------------.'
|
||||||
print u'| %-76s |' % (u'%s: %s' % (backend.name, video.title))
|
print u'| %-76s |' % (u'%s: %s' % (backend.name, video.title))
|
||||||
|
|
@ -57,7 +68,7 @@ class Videoob(ConsoleApplication):
|
||||||
else:
|
else:
|
||||||
print u'| %-76s |' % 'Last videos'
|
print u'| %-76s |' % 'Last videos'
|
||||||
print u"+------------.-----------------------------------------------------------------'"
|
print u"+------------.-----------------------------------------------------------------'"
|
||||||
for backend in self.weboob.iter_backends():
|
for backend in self.iter_enabled_backends():
|
||||||
try:
|
try:
|
||||||
iterator = backend.iter_search_results(pattern)
|
iterator = backend.iter_search_results(pattern)
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
|
|
@ -69,16 +80,8 @@ class Videoob(ConsoleApplication):
|
||||||
|
|
||||||
@ConsoleApplication.command('Get video file URL from page URL')
|
@ConsoleApplication.command('Get video file URL from page URL')
|
||||||
def command_file_url(self, url):
|
def command_file_url(self, url):
|
||||||
for backend in self.weboob.iter_backends(ICapVideoProvider):
|
for backend in self.iter_enabled_backends():
|
||||||
video_url = backend.get_video_url(url)
|
video = backend.get_video(url)
|
||||||
if video_url:
|
if video:
|
||||||
print video_url
|
print video.url
|
||||||
break
|
|
||||||
|
|
||||||
@ConsoleApplication.command('Get video title from page URL')
|
|
||||||
def command_title(self, url):
|
|
||||||
for backend in self.weboob.iter_backends(ICapVideoProvider):
|
|
||||||
video_title = backend.get_video_title(url)
|
|
||||||
if video_title:
|
|
||||||
print video_title
|
|
||||||
break
|
break
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue