[videoob] add playlist play command
This commit is contained in:
parent
b36daee5b1
commit
9ca4784a27
1 changed files with 25 additions and 19 deletions
|
|
@ -114,7 +114,6 @@ class Videoob(ReplApplication):
|
||||||
elif len(args) >= 3:
|
elif len(args) >= 3:
|
||||||
return self.path_completer(args[2])
|
return self.path_completer(args[2])
|
||||||
|
|
||||||
|
|
||||||
def do_download(self, line):
|
def do_download(self, line):
|
||||||
"""
|
"""
|
||||||
download ID [FILENAME]
|
download ID [FILENAME]
|
||||||
|
|
@ -152,14 +151,19 @@ class Videoob(ReplApplication):
|
||||||
ret = 0
|
ret = 0
|
||||||
for _id in line.split(' '):
|
for _id in line.split(' '):
|
||||||
video = self.get_object(_id, 'get_video', ['url'])
|
video = self.get_object(_id, 'get_video', ['url'])
|
||||||
|
error = self.play(video, _id)
|
||||||
|
if error is not None:
|
||||||
|
ret = error
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def play(self, video, _id):
|
||||||
if not video:
|
if not video:
|
||||||
print >>sys.stderr, 'Video not found: %s' % _id
|
print >>sys.stderr, 'Video not found: %s' % _id
|
||||||
ret = 3
|
return 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.'
|
||||||
ret = 4
|
return 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')
|
||||||
|
|
@ -170,8 +174,6 @@ 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:
|
||||||
|
|
@ -199,7 +201,7 @@ class Videoob(ReplApplication):
|
||||||
def complete_playlist(self, text, line, *ignored):
|
def complete_playlist(self, text, line, *ignored):
|
||||||
args = line.split(' ')
|
args = line.split(' ')
|
||||||
if len(args) == 2:
|
if len(args) == 2:
|
||||||
return ['cmd', 'add', 'remove', 'export', 'display', 'download']
|
return ['play', 'add', 'remove', 'export', 'display', 'download']
|
||||||
if len(args) >= 3:
|
if len(args) >= 3:
|
||||||
if args[1] in ('export', 'download'):
|
if args[1] in ('export', 'download'):
|
||||||
return self.path_completer(args[2])
|
return self.path_completer(args[2])
|
||||||
|
|
@ -215,6 +217,7 @@ class Videoob(ReplApplication):
|
||||||
playlist export [FILENAME]
|
playlist export [FILENAME]
|
||||||
playlist display
|
playlist display
|
||||||
playlist download [PATH]
|
playlist download [PATH]
|
||||||
|
playlist play
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not self.interactive:
|
if not self.interactive:
|
||||||
|
|
@ -272,6 +275,9 @@ class Videoob(ReplApplication):
|
||||||
elif cmd == "download":
|
elif cmd == "download":
|
||||||
for i, video in enumerate(self.PLAYLIST):
|
for i, video in enumerate(self.PLAYLIST):
|
||||||
self.download(video, args, '%02d-{id}-{title}.{ext}' % (i+1))
|
self.download(video, args, '%02d-{id}-{title}.{ext}' % (i+1))
|
||||||
|
elif cmd == "play":
|
||||||
|
for video in self.PLAYLIST:
|
||||||
|
self.play(video, video.id)
|
||||||
else:
|
else:
|
||||||
print >>sys.stderr, 'Playlist command only support "add", "remove", "display", "download" and "export" arguments.'
|
print >>sys.stderr, 'Playlist command only support "add", "remove", "display", "download" and "export" arguments.'
|
||||||
return 2
|
return 2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue