diff options
| author | 2013-03-26 01:00:15 +0100 | |
|---|---|---|
| committer | 2013-03-26 01:00:15 +0100 | |
| commit | 8c655c6835e864c81d71a0e15a4d79bdb3cdfa1d (patch) | |
| tree | 87d01b5f72bbb243747782387f2749e7538fb717 /module/plugins | |
| parent | Add module.utils.which (diff) | |
| download | pyload-8c655c6835e864c81d71a0e15a4d79bdb3cdfa1d.tar.xz | |
YoutubeCom: Add support for time specification, if ffmpeg is installed and in PATH
Diffstat (limited to 'module/plugins')
| -rw-r--r-- | module/plugins/hoster/YoutubeCom.py | 28 | 
1 files changed, 25 insertions, 3 deletions
| diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index a9fed5638..9f21ddf79 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -2,9 +2,11 @@  # -*- coding: utf-8 -*-  import re +import subprocess +import os  from urllib import unquote -from module.utils import html_unescape +from module.utils import html_unescape, which  from module.plugins.Hoster import Hoster  class YoutubeCom(Hoster): @@ -114,5 +116,25 @@ class YoutubeCom(Hoster):          file_name_pattern = '<meta name="title" content="(.+?)">'          name = re.search(file_name_pattern, html).group(1).replace("/", "") + file_suffix          pyfile.name = html_unescape(name) -         -        self.download(url)
\ No newline at end of file + +        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) | 
