From fafd901d97eaa80f3d67c92cd95074fa61ed3262 Mon Sep 17 00:00:00 2001 From: enkore Date: Tue, 26 Mar 2013 13:45:29 +0100 Subject: YoutubeCom: Show start time in package name --- module/plugins/hoster/YoutubeCom.py | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 4bc608b05..f01094c7d 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -138,24 +138,26 @@ class YoutubeCom(Hoster): name = re.search(file_name_pattern, html).group(1).replace("/", "") + file_suffix pyfile.name = html_unescape(name) + time = re.search(r"t=((\d+)m)?(\d+)s", pyfile.url) + if time: + m, s = time.groups()[1:] + if not m: + m = "0" + + pyfile.name += " (starting at %s:%s)" % (m, s) + filename = self.download(url) ffmpeg = which("ffmpeg") if ffmpeg: - time = re.search(r"t=((\d+)m)?(\d+)s", pyfile.url) - if time: - m, s = time.groups()[1:] - if not m: - m = "0" - - inputfile = filename + "_" - os.rename(filename, inputfile) - - subprocess.call([ - which("ffmpeg"), - "-ss", "00:%s:%s" % (m, s), - "-i", inputfile, - "-vcodec", "copy", - "-acodec", "copy", - filename]) - os.remove(inputfile) + inputfile = filename + "_" + os.rename(filename, inputfile) + + subprocess.call([ + ffmpeg, + "-ss", "00:%s:%s" % (m, s), + "-i", inputfile, + "-vcodec", "copy", + "-acodec", "copy", + filename]) + os.remove(inputfile) -- cgit v1.2.3