summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Paul King <devnull@localhost> 2011-06-05 20:53:44 +0200
committerGravatar Paul King <devnull@localhost> 2011-06-05 20:53:44 +0200
commit3c222f07a62e77fa77f3133b752a33bd7c7dfd31 (patch)
tree0a989ba568be3924ff3d5a9d7bd60381fd8317e1
parentyoutube fix (diff)
downloadpyload-3c222f07a62e77fa77f3133b752a33bd7c7dfd31.tar.xz
youtube - file extension based on fmt
-rw-r--r--module/plugins/hoster/YoutubeCom.py37
1 files changed, 25 insertions, 12 deletions
diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py
index 048e1ab70..ccd98606e 100644
--- a/module/plugins/hoster/YoutubeCom.py
+++ b/module/plugins/hoster/YoutubeCom.py
@@ -16,6 +16,19 @@ class YoutubeCom(Hoster):
__author_name__ = ("spoob")
__author_mail__ = ("spoob@pyload.org")
+ formats = { 5 : (".flv", 400, 240),
+ 34 : (".flv", 640, 360),
+ 35 : (".flv", 854, 480),
+ 18 : (".mp4", 480, 360),
+ 22 : (".mp4", 1280, 720),
+ 37 : (".mp4", 1920, 1080),
+ 38 : (".mp4", 4096, 3072),
+ 43 : (".webm", 640, 360),
+ 45 : (".webm", 1280, 720),
+ 17 : (".3gp", 176, 144)
+ }
+
+
def process(self, pyfile):
html = self.load(pyfile.url, decode=True)
@@ -27,24 +40,17 @@ class YoutubeCom(Hoster):
file_name_pattern = '<meta name="title" content="(.+?)">'
is_hd_pattern = r"'IS_HD_AVAILABLE': (false|true)"
- file_suffix = ".flv"
is_hd = re.search(is_hd_pattern, html).group(1)
hd_available = (is_hd == "true")
- quality = self.getConf("quality")
-
- if quality in ("hd", "fullhd"):
- file_suffix = ".mp4"
-
- name = re.search(file_name_pattern, html).group(1).replace("/", "") + file_suffix
- pyfile.name = name #.replace("&amp;", "&").replace("ö", "oe").replace("ä", "ae").replace("ü", "ue")
+ quality = self.getConf("quality")
desired_fmt = 18
- if self.getConf("quality") == "sd":
- desired_fmt = 6
- elif self.getConf("quality") == "hd" and hd_available:
+ if quality == "sd":
+ desired_fmt = 5
+ elif quality == "hd" and hd_available:
desired_fmt = 22
- elif self.getConf("quality") == "fullhd" and hd_available:
+ elif quality == "fullhd" and hd_available:
desired_fmt = 37
if self.getConfig("fmt"):
@@ -70,4 +76,11 @@ class YoutubeCom(Hoster):
fmt = reduce(lambda x,y: x if abs(x-desired_fmt) <= abs(y-desired_fmt) else y, fmt_dict.keys())
self.logDebug("Choose fmt: %s" % fmt)
+
+ file_suffix = ".flv"
+ if fmt in self.formats:
+ file_suffix = self.formats[fmt][0]
+ name = re.search(file_name_pattern, html).group(1).replace("/", "") + file_suffix
+ pyfile.name = name #.replace("&amp;", "&").replace("ö", "oe").replace("ä", "ae").replace("ü", "ue")
+
self.download(fmt_dict[fmt])