From cb411f4c54bd0e916871ea77a7934a3060964261 Mon Sep 17 00:00:00 2001 From: Noe Rubinstein Date: Thu, 16 Jan 2014 22:52:57 +0100 Subject: [PATCH] Videoob: download: replace data fields in video filename --- weboob/applications/videoob/videoob.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/weboob/applications/videoob/videoob.py b/weboob/applications/videoob/videoob.py index 4fddfe98..fa281239 100644 --- a/weboob/applications/videoob/videoob.py +++ b/weboob/applications/videoob/videoob.py @@ -87,6 +87,11 @@ class Videoob(ReplApplication): download ID [FILENAME] Download a video + + Braces-enclosed tags are replaced with data fields. Use the 'info' + command to see what fields are available on a given video. + + Example: download KdRRge4XYIo@youtube '{title}.{ext}' """ _id, dest = self.parse_command_args(line, 2, 1) video = self.get_object(_id, 'get_video', ['url']) @@ -117,6 +122,16 @@ class Videoob(ReplApplication): if dest is None: dest = video_to_file(video) + else: + fields = video.to_dict() + def repl(m): + field = m.group(1) + if field in fields: + return fields[field] + else: + return m.group(0) + + dest = re.sub(r'\{(.+?)\}', repl, dest) if video.url.startswith('rtmp'): if not check_exec('rtmpdump'):