use Weboob.do insteal of deprecated iter_backends in some frontends
This commit is contained in:
parent
ad240e7aed
commit
7c502ca236
3 changed files with 9 additions and 14 deletions
|
|
@ -106,9 +106,8 @@ class Monboob(ConsoleApplication):
|
||||||
self.weboob.loop()
|
self.weboob.loop()
|
||||||
|
|
||||||
def process(self):
|
def process(self):
|
||||||
for backend in self.weboob.iter_backends():
|
for backend, message in self.weboob.do('iter_new_messages'):
|
||||||
for message in backend.iter_new_messages():
|
self.send_email(backend, message)
|
||||||
self.send_email(backend, message)
|
|
||||||
|
|
||||||
def send_email(self, backend, mail):
|
def send_email(self, backend, mail):
|
||||||
domain = self.config.get('domain')
|
domain = self.config.get('domain')
|
||||||
|
|
|
||||||
|
|
@ -66,22 +66,17 @@ class Videoob(ConsoleApplication):
|
||||||
else:
|
else:
|
||||||
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, video in self.weboob.do('iter_search_results', pattern):
|
||||||
|
row = (video.id, video.title, '%d:%02d:%02d' % (video.duration/3600, (video.duration%3600/60), video.duration%60))
|
||||||
try:
|
try:
|
||||||
iterator = backend.iter_search_results(pattern)
|
results[backend.name].append(row)
|
||||||
except NotImplementedError:
|
except KeyError:
|
||||||
continue
|
results[backend.name] = [row]
|
||||||
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')
|
||||||
def command_file_url(self, url):
|
def command_file_url(self, url):
|
||||||
for backend in self.weboob.iter_backends():
|
for backend, video in self.weboob.do('get_video', url):
|
||||||
video = backend.get_video(url)
|
|
||||||
if video:
|
if video:
|
||||||
print video.url
|
print video.url
|
||||||
break
|
break
|
||||||
|
|
|
||||||
|
|
@ -162,3 +162,4 @@ class BaseApplication(object):
|
||||||
print 'Program killed by SIGINT'
|
print 'Program killed by SIGINT'
|
||||||
except ConfigError, e:
|
except ConfigError, e:
|
||||||
print 'Configuration error: %s' % e
|
print 'Configuration error: %s' % e
|
||||||
|
sys.exit(1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue