videoob [play|info]: ability to give several videos

This commit is contained in:
Romain Bignon 2014-01-16 22:41:57 +01:00
commit 69d392e0c0

View file

@ -153,26 +153,30 @@ class Videoob(ReplApplication):
def complete_play(self, text, line, *ignored): def complete_play(self, text, line, *ignored):
args = line.split(' ') args = line.split(' ')
if len(args) == 2: if len(args) >= 2:
return self._complete_object() return self._complete_object()
def do_play(self, _id): def do_play(self, line):
""" """
play ID play ID
Play a video with a found player. Play a video with a found player.
""" """
if not _id: if not line:
print >>sys.stderr, 'This command takes an argument: %s' % self.get_command_help('play', short=True) print >>sys.stderr, 'This command takes an argument: %s' % self.get_command_help('play', short=True)
return 2 return 2
ret = 0
for _id in line.split(' '):
video = self.get_object(_id, 'get_video', ['url']) video = self.get_object(_id, 'get_video', ['url'])
if not video: if not video:
print >>sys.stderr, 'Video not found: %s' % _id print >>sys.stderr, 'Video not found: %s' % _id
return 3 ret = 3
continue
if not video.url: if not video.url:
print >>sys.stderr, 'Error: the direct URL is not available.' print >>sys.stderr, 'Error: the direct URL is not available.'
return 4 ret = 4
continue
try: try:
player_name = self.config.get('media_player') player_name = self.config.get('media_player')
media_player_args = self.config.get('media_player_args') media_player_args = self.config.get('media_player_args')
@ -183,27 +187,30 @@ class Videoob(ReplApplication):
except (InvalidMediaPlayer, MediaPlayerNotFound) as e: except (InvalidMediaPlayer, MediaPlayerNotFound) as e:
print '%s\nVideo URL: %s' % (e, video.url) print '%s\nVideo URL: %s' % (e, video.url)
return ret
def complete_info(self, text, line, *ignored): def complete_info(self, text, line, *ignored):
args = line.split(' ') args = line.split(' ')
if len(args) == 2: if len(args) >= 2:
return self._complete_object() return self._complete_object()
def do_info(self, _id): def do_info(self, line):
""" """
info ID info ID [ID2 [...]]
Get information about a video. Get information about a video.
""" """
if not _id: if not line:
print >>sys.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True) print >>sys.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
return 2 return 2
self.start_format()
for _id in line.split(' '):
video = self.get_object(_id, 'get_video') video = self.get_object(_id, 'get_video')
if not video: if not video:
print >>sys.stderr, 'Video not found: %s' % _id print >>sys.stderr, 'Video not found: %s' % _id
return 3 return 3
self.start_format()
self.format(video) self.format(video)
def do_playlist(self, line): def do_playlist(self, line):