diff --git a/weboob/applications/videoob/videoob.py b/weboob/applications/videoob/videoob.py index 5730e38b..32e4807d 100644 --- a/weboob/applications/videoob/videoob.py +++ b/weboob/applications/videoob/videoob.py @@ -15,8 +15,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - +import subprocess import sys +import os from weboob.capabilities.video import ICapVideo from weboob.capabilities.base import NotLoaded @@ -92,6 +93,36 @@ class Videoob(ReplApplication): def _complete_id(self): return ['%s@%s' % (video.id, video.backend) for video in self.videos] + def complete_download(self, text, line, *ignored): + args = line.split(' ') + if len(args) == 2: + return self._complete_id() + elif len(args) >= 3: + return self.path_completer(args[2]) + + def do_download(self, line): + """ + download ID [FILENAME] + + Download a video + """ + _id, dest = self.parse_command_args(line, 2, 1) + video = self._get_video(_id, ['url']) + if not video: + print 'Video not found: %s' % _id + return 1 + + with open('/dev/null', 'w') as devnull: + process = subprocess.Popen(['which', 'wget'], stdout=devnull) + if process.wait() != 0: + print >>sys.stderr, 'Please install "wget"' + return 1 + + if dest is not None: + os.system('wget %s -O %s' % (video.url, dest)) + else: + os.system('wget %s' % (video.url)) + def complete_play(self, text, line, *ignored): args = line.split(' ') if len(args) == 2: