give parent logger to MediaPlayer

This commit is contained in:
Romain Bignon 2010-11-09 23:07:25 +01:00
commit ecdd6582e5
2 changed files with 11 additions and 7 deletions

View file

@ -16,6 +16,8 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import sys
from weboob.capabilities.radio import ICapRadio from weboob.capabilities.radio import ICapRadio
from weboob.capabilities.base import NotLoaded from weboob.capabilities.base import NotLoaded
from weboob.tools.application.repl import ReplApplication from weboob.tools.application.repl import ReplApplication
@ -58,7 +60,7 @@ class Radioob(ReplApplication):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
ReplApplication.__init__(self, *args, **kwargs) ReplApplication.__init__(self, *args, **kwargs)
try: try:
self.player = MediaPlayer() self.player = MediaPlayer(self.logger)
except OSError: except OSError:
self.player = None self.player = None
@ -98,7 +100,7 @@ class Radioob(ReplApplication):
radio = self._get_radio(_id, ['streams']) radio = self._get_radio(_id, ['streams'])
if not radio: if not radio:
print 'Radio not found: ', _id print >>sys.stderr, 'Radio not found: ' % _id
return return
if self.player: if self.player:
@ -125,7 +127,7 @@ class Radioob(ReplApplication):
radio = self._get_radio(_id) radio = self._get_radio(_id)
if not radio: if not radio:
print 'radio not found:', _id print 'Radio not found:', _id
return return
self.format(radio) self.format(radio)
self.flush() self.flush()

View file

@ -16,6 +16,8 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import sys
from weboob.capabilities.video import ICapVideo from weboob.capabilities.video import ICapVideo
from weboob.capabilities.base import NotLoaded from weboob.capabilities.base import NotLoaded
from weboob.tools.application.repl import ReplApplication from weboob.tools.application.repl import ReplApplication
@ -40,7 +42,7 @@ class VideoListFormatter(IFormatter):
result = u'%s* (%d) %s (%s)%s\n' % (ReplApplication.BOLD, self.count, item['title'], backend, ReplApplication.NC) result = u'%s* (%d) %s (%s)%s\n' % (ReplApplication.BOLD, self.count, item['title'], backend, ReplApplication.NC)
else: else:
result = u'%s* (%s) %s%s\n' % (ReplApplication.BOLD, item['id'], item['title'], ReplApplication.NC) result = u'%s* (%s) %s%s\n' % (ReplApplication.BOLD, item['id'], item['title'], ReplApplication.NC)
result += ' %s' % item['duration'] result += ' %s' % (item['duration'] if item['duration'] else item['date'])
if item['author'] is not NotLoaded: if item['author'] is not NotLoaded:
result += ' - %s' % item['author'] result += ' - %s' % item['author']
if item['rating'] is not NotLoaded: if item['rating'] is not NotLoaded:
@ -61,7 +63,7 @@ class Videoob(ReplApplication):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
ReplApplication.__init__(self, *args, **kwargs) ReplApplication.__init__(self, *args, **kwargs)
try: try:
self.player = MediaPlayer() self.player = MediaPlayer(self.logger)
except OSError: except OSError:
self.player = None self.player = None
@ -101,7 +103,7 @@ class Videoob(ReplApplication):
video = self._get_video(_id, ['url']) video = self._get_video(_id, ['url'])
if not video: if not video:
print 'Video not found: ', _id print 'Video not found: %s' % _id
return return
if self.player: if self.player:
@ -128,7 +130,7 @@ class Videoob(ReplApplication):
video = self._get_video(_id) video = self._get_video(_id)
if not video: if not video:
print 'Video not found:', _id print >>sys.stderr, 'Video not found: %s' % _id
return return
self.format(video) self.format(video)
self.flush() self.flush()