videoob [play|info]: ability to give several videos
This commit is contained in:
parent
cb411f4c54
commit
69d392e0c0
1 changed files with 36 additions and 29 deletions
|
|
@ -153,58 +153,65 @@ 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
|
||||||
|
|
||||||
video = self.get_object(_id, 'get_video', ['url'])
|
ret = 0
|
||||||
if not video:
|
for _id in line.split(' '):
|
||||||
print >>sys.stderr, 'Video not found: %s' % _id
|
video = self.get_object(_id, 'get_video', ['url'])
|
||||||
return 3
|
if not video:
|
||||||
if not video.url:
|
print >>sys.stderr, 'Video not found: %s' % _id
|
||||||
print >>sys.stderr, 'Error: the direct URL is not available.'
|
ret = 3
|
||||||
return 4
|
continue
|
||||||
try:
|
if not video.url:
|
||||||
player_name = self.config.get('media_player')
|
print >>sys.stderr, 'Error: the direct URL is not available.'
|
||||||
media_player_args = self.config.get('media_player_args')
|
ret = 4
|
||||||
if not player_name:
|
continue
|
||||||
self.logger.info(u'You can set the media_player key to the player you prefer in the videoob '
|
try:
|
||||||
'configuration file.')
|
player_name = self.config.get('media_player')
|
||||||
self.player.play(video, player_name=player_name, player_args=media_player_args)
|
media_player_args = self.config.get('media_player_args')
|
||||||
except (InvalidMediaPlayer, MediaPlayerNotFound) as e:
|
if not player_name:
|
||||||
print '%s\nVideo URL: %s' % (e, video.url)
|
self.logger.info(u'You can set the media_player key to the player you prefer in the videoob '
|
||||||
|
'configuration file.')
|
||||||
|
self.player.play(video, player_name=player_name, player_args=media_player_args)
|
||||||
|
except (InvalidMediaPlayer, MediaPlayerNotFound) as e:
|
||||||
|
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
|
||||||
|
|
||||||
video = self.get_object(_id, 'get_video')
|
|
||||||
if not video:
|
|
||||||
print >>sys.stderr, 'Video not found: %s' % _id
|
|
||||||
return 3
|
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
self.format(video)
|
for _id in line.split(' '):
|
||||||
|
video = self.get_object(_id, 'get_video')
|
||||||
|
if not video:
|
||||||
|
print >>sys.stderr, 'Video not found: %s' % _id
|
||||||
|
return 3
|
||||||
|
|
||||||
|
self.format(video)
|
||||||
|
|
||||||
def do_playlist(self, line):
|
def do_playlist(self, line):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue