From 0ed9a4701df16cfbc06330c51fcf049b32e6258a Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Fri, 26 Oct 2012 08:50:33 +0200 Subject: update youtube plugin - closed #686 --- module/plugins/hoster/YoutubeCom.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'module/plugins/hoster/YoutubeCom.py') diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 222e9bf84..c1812a8fb 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -10,8 +10,8 @@ from module.plugins.Hoster import Hoster class YoutubeCom(Hoster): __name__ = "YoutubeCom" __type__ = "hoster" - __pattern__ = r"http://(www\.)?(de\.)?\youtube\.com/watch\?v=.*" - __version__ = "0.25" + __pattern__ = r"(http|https)://(www\.)?(de\.)?\youtube\.com/watch\?v=.*" + __version__ = "0.26" __config__ = [("quality", "sd;hd;fullhd", "Quality Setting", "hd"), ("fmt", "int", "FMT Number 0-45", 0), (".mp4", "bool", "Allow .mp4", True), @@ -19,8 +19,8 @@ class YoutubeCom(Hoster): (".webm", "bool", "Allow .webm", False), (".3gp", "bool", "Allow .3gp", False)] __description__ = """Youtube.com Video Download Hoster""" - __author_name__ = ("spoob") - __author_mail__ = ("spoob@pyload.org") + __author_name__ = ("spoob", "zoidberg") + __author_mail__ = ("spoob@pyload.org", "zoidberg@mujmail.cz") # name, width, height, quality ranking formats = {17: (".3gp", 176, 144, 0), @@ -63,22 +63,20 @@ class YoutubeCom(Hoster): if self.getConfig("fmt"): desired_fmt = self.getConf("fmt") - - flashvars = re.search(r'flashvars=\\"(.*?)\\"', html) - flashvars = unquote(flashvars.group(1)) - - fmts = re.findall(r'url=(.*?)%3B.*?itag=(\d+)', flashvars) + + streams = unquote(re.search(r'url_encoded_fmt_stream_map=(.*?);', html).group(1)) + streams = [x.split('&') for x in streams.split(',')] + streams = [dict((y.split('=')) for y in x) for x in streams] fmt_dict = {} - for url, fmt in fmts: - fmt = int(fmt) - fmt_dict[fmt] = unquote(url) - + for x in streams: + x.update(itag=int(x['itag']), url=unquote(x['url']), type=unquote(x['type'])) + fmt_dict[x['itag']] = "%s&signature=%s" % (x['url'], x['sig']) self.logDebug("Found links: %s" % fmt_dict) for fmt in fmt_dict.keys(): if fmt not in self.formats: - self.logDebug("FMT not supported: %s" % fmt) - del fmt_dict[fmt] + self.logDebug("FMT not supported: %s" % fmt) + del fmt_dict[fmt] allowed = lambda x: self.getConfig(self.formats[x][0]) sel = lambda x: self.formats[x][3] #select quality index @@ -90,11 +88,13 @@ class YoutubeCom(Hoster): allowed(x) else y, fmt_dict.keys()) self.logDebug("Choose fmt: %s" % fmt) + url = fmt_dict[fmt] + self.logDebug("URL: %s" % url) 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 = html_unescape(name) - - self.download(fmt_dict[fmt]) + + self.download(url) \ No newline at end of file -- cgit v1.2.3 From e195f96d1a4d31a1e59d7f23971edd14a1edd220 Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Sat, 27 Oct 2012 01:57:45 +0200 Subject: youtube - add 3D formats, update playlist crypter --- module/plugins/hoster/YoutubeCom.py | 118 +++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 55 deletions(-) (limited to 'module/plugins/hoster/YoutubeCom.py') diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index c1812a8fb..c9e8a1c7a 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -11,29 +11,40 @@ class YoutubeCom(Hoster): __name__ = "YoutubeCom" __type__ = "hoster" __pattern__ = r"(http|https)://(www\.)?(de\.)?\youtube\.com/watch\?v=.*" - __version__ = "0.26" + __version__ = "0.27" __config__ = [("quality", "sd;hd;fullhd", "Quality Setting", "hd"), - ("fmt", "int", "FMT Number 0-45", 0), + ("fmt", "int", "FMT Number 0-102", 0), (".mp4", "bool", "Allow .mp4", True), (".flv", "bool", "Allow .flv", True), (".webm", "bool", "Allow .webm", False), - (".3gp", "bool", "Allow .3gp", False)] + (".3gp", "bool", "Allow .3gp", False), + ("3d", "bool", "Prefer 3D", False)] __description__ = """Youtube.com Video Download Hoster""" __author_name__ = ("spoob", "zoidberg") __author_mail__ = ("spoob@pyload.org", "zoidberg@mujmail.cz") - # name, width, height, quality ranking - formats = {17: (".3gp", 176, 144, 0), - 5: (".flv", 400, 240, 1), - 18: (".mp4", 480, 360, 2), - 43: (".webm", 640, 360, 3), - 34: (".flv", 640, 360, 4), - 44: (".webm", 854, 480, 5), - 35: (".flv", 854, 480, 6), - 45: (".webm", 1280, 720, 7), - 22: (".mp4", 1280, 720, 8), - 37: (".mp4", 1920, 1080, 9), - 38: (".mp4", 4096, 3072, 10), + # name, width, height, quality ranking, 3D + formats = {5: (".flv", 400, 240, 1, False), + 6: (".flv", 640, 400, 4, False), + 17: (".3gp", 176, 144, 0, False), + 18: (".mp4", 480, 360, 2, False), + 22: (".mp4", 1280, 720, 8, False), + 43: (".webm", 640, 360, 3, False), + 34: (".flv", 640, 360, 4, False), + 35: (".flv", 854, 480, 6, False), + 36: (".3gp", 400, 240, 1, False), + 37: (".mp4", 1920, 1080, 9, False), + 38: (".mp4", 4096, 3072, 10, False), + 44: (".webm", 854, 480, 5, False), + 45: (".webm", 1280, 720, 7, False), + 46: (".webm", 1920, 1080, 9, False), + 82: (".mp4", 640, 360, 3, True), + 83: (".mp4", 400, 240, 1, True), + 84: (".mp4", 1280, 720, 8, True), + 85: (".mp4", 1920, 1080, 9, True), + 100: (".webm", 640, 360, 3, True), + 101: (".webm", 640, 360, 4, True), + 102: (".webm", 1280, 720, 8, True) } @@ -45,55 +56,52 @@ class YoutubeCom(Hoster): if "We have been receiving a large volume of requests from your network." in html: self.tempOffline() - - #videoId = pyfile.url.split("v=")[1].split("&")[0] - #videoHash = re.search(r'&t=(.+?)&', html).group(1) - - file_name_pattern = '' - - quality = self.getConf("quality") - desired_fmt = 18 - - if quality == "sd": - desired_fmt = 18 - elif quality == "hd": - desired_fmt = 22 - elif quality == "fullhd": - desired_fmt = 37 - - if self.getConfig("fmt"): - desired_fmt = self.getConf("fmt") + #get config + use3d = self.getConf("3d") + quality = {"sd":82,"hd":84,"fullhd":85} if use3d else {"sd":18,"hd":22,"fullhd":37} + desired_fmt = self.getConf("fmt") or quality.get(self.getConf("quality"), 18) + + #parse available streams streams = unquote(re.search(r'url_encoded_fmt_stream_map=(.*?);', html).group(1)) streams = [x.split('&') for x in streams.split(',')] streams = [dict((y.split('=')) for y in x) for x in streams] - fmt_dict = {} - for x in streams: - x.update(itag=int(x['itag']), url=unquote(x['url']), type=unquote(x['type'])) - fmt_dict[x['itag']] = "%s&signature=%s" % (x['url'], x['sig']) + streams = [(int(x['itag']), "%s&signature=%s" % (unquote(x['url']), x['sig'])) for x in streams] + #self.logDebug("Found links: %s" % streams) + self.logDebug("AVAILABLE STREAMS: %s" % [x[0] for x in streams]) - self.logDebug("Found links: %s" % fmt_dict) - for fmt in fmt_dict.keys(): - if fmt not in self.formats: - self.logDebug("FMT not supported: %s" % fmt) - del fmt_dict[fmt] - - allowed = lambda x: self.getConfig(self.formats[x][0]) - sel = lambda x: self.formats[x][3] #select quality index - comp = lambda x, y: abs(sel(x) - sel(y)) - - #return fmt nearest to quali index - fmt = reduce(lambda x, y: x if comp(x, desired_fmt) <= comp(y, desired_fmt) and - sel(x) > sel(y) and - allowed(x) else y, fmt_dict.keys()) + #build dictionary of supported itags (3D/2D) + allowed = lambda x: self.getConfig(self.formats[x][0]) + streams = [x for x in streams if x[0] in self.formats and allowed(x[0])] + if not streams: + self.fail("No available stream meets your preferences") + fmt_dict = dict([x for x in streams if self.formats[x[0]][4] == use3d] or streams) + + self.logDebug("DESIRED STREAM: ITAG:%d (%s) %sfound, %sallowed" % + (desired_fmt, + "%s %dx%d Q:%d 3D:%s" % self.formats[desired_fmt], + "" if desired_fmt in fmt_dict else "NOT ", + "" if allowed(desired_fmt) else "NOT ") + ) + + #return fmt nearest to quality index + if desired_fmt in fmt_dict and allowed(desired_fmt): + fmt = desired_fmt + else: + sel = lambda x: self.formats[x][3] #select quality index + comp = lambda x, y: abs(sel(x) - sel(y)) + + self.logDebug("Choosing nearest fmt: %s" % [(x, allowed(x), comp(x, desired_fmt)) for x in fmt_dict.keys()]) + fmt = reduce(lambda x, y: x if comp(x, desired_fmt) <= comp(y, desired_fmt) and + sel(x) > sel(y) else y, fmt_dict.keys()) - self.logDebug("Choose fmt: %s" % fmt) + self.logDebug("Chosen fmt: %s" % fmt) url = fmt_dict[fmt] self.logDebug("URL: %s" % url) - file_suffix = ".flv" - if fmt in self.formats: - file_suffix = self.formats[fmt][0] + #set file name + file_suffix = self.formats[fmt][0] if fmt in self.formats else ".flv" + file_name_pattern = '' name = re.search(file_name_pattern, html).group(1).replace("/", "") + file_suffix pyfile.name = html_unescape(name) -- cgit v1.2.3 From 94966b3c2a093a79858dd9672ae2380bdc3ccf6e Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Tue, 13 Nov 2012 21:57:57 +0100 Subject: youtube config options, resume - closed #717, ul.to - closed #716, netload.in - fix some urls, linkdecrypter - fix crypter list --- module/plugins/hoster/YoutubeCom.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'module/plugins/hoster/YoutubeCom.py') diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index c9e8a1c7a..29cb3f60a 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -11,9 +11,9 @@ class YoutubeCom(Hoster): __name__ = "YoutubeCom" __type__ = "hoster" __pattern__ = r"(http|https)://(www\.)?(de\.)?\youtube\.com/watch\?v=.*" - __version__ = "0.27" - __config__ = [("quality", "sd;hd;fullhd", "Quality Setting", "hd"), - ("fmt", "int", "FMT Number 0-102", 0), + __version__ = "0.28" + __config__ = [("quality", "sd;hd;fullhd;240p;360p;480p;720p;1080p;3072p", "Quality Setting", "hd"), + ("fmt", "int", "FMT/ITAG Number (5-102, 0 for auto)", 0), (".mp4", "bool", "Allow .mp4", True), (".flv", "bool", "Allow .flv", True), (".webm", "bool", "Allow .webm", False), @@ -47,6 +47,8 @@ class YoutubeCom(Hoster): 102: (".webm", 1280, 720, 8, True) } + def setup(self): + self.resumeDownload = self.multiDL = True def process(self, pyfile): html = self.load(pyfile.url, decode=True) @@ -59,8 +61,16 @@ class YoutubeCom(Hoster): #get config use3d = self.getConf("3d") - quality = {"sd":82,"hd":84,"fullhd":85} if use3d else {"sd":18,"hd":22,"fullhd":37} - desired_fmt = self.getConf("fmt") or quality.get(self.getConf("quality"), 18) + if use3d: + quality = {"sd":82,"hd":84,"fullhd":85,"240p":83,"360p":82,"480p":82,"720p":84,"1080p":85,"3072p":85} + else: + quality = {"sd":18,"hd":22,"fullhd":37,"240p":5,"360p":18,"480p":35,"720p":22,"1080p":37,"3072p":38} + desired_fmt = self.getConf("fmt") + if desired_fmt and desired_fmt not in formats: + self.logWarning("FMT %d unknown - using default." % desired_fmt) + desired_fmt = 0 + if not desired_fmt: + desired_fmt = quality.get(self.getConf("quality"), 18) #parse available streams streams = unquote(re.search(r'url_encoded_fmt_stream_map=(.*?);', html).group(1)) -- cgit v1.2.3 From 82186ed3e95a1d795a94864bdd904393a1896825 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Fri, 15 Feb 2013 16:02:59 +0100 Subject: update for YouTube plugin --- module/plugins/hoster/YoutubeCom.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'module/plugins/hoster/YoutubeCom.py') diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 29cb3f60a..a9fed5638 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -11,7 +11,7 @@ class YoutubeCom(Hoster): __name__ = "YoutubeCom" __type__ = "hoster" __pattern__ = r"(http|https)://(www\.)?(de\.)?\youtube\.com/watch\?v=.*" - __version__ = "0.28" + __version__ = "0.29" __config__ = [("quality", "sd;hd;fullhd;240p;360p;480p;720p;1080p;3072p", "Quality Setting", "hd"), ("fmt", "int", "FMT/ITAG Number (5-102, 0 for auto)", 0), (".mp4", "bool", "Allow .mp4", True), @@ -66,17 +66,17 @@ class YoutubeCom(Hoster): else: quality = {"sd":18,"hd":22,"fullhd":37,"240p":5,"360p":18,"480p":35,"720p":22,"1080p":37,"3072p":38} desired_fmt = self.getConf("fmt") - if desired_fmt and desired_fmt not in formats: + if desired_fmt and desired_fmt not in self.formats: self.logWarning("FMT %d unknown - using default." % desired_fmt) desired_fmt = 0 if not desired_fmt: desired_fmt = quality.get(self.getConf("quality"), 18) #parse available streams - streams = unquote(re.search(r'url_encoded_fmt_stream_map=(.*?);', html).group(1)) - streams = [x.split('&') for x in streams.split(',')] - streams = [dict((y.split('=')) for y in x) for x in streams] - streams = [(int(x['itag']), "%s&signature=%s" % (unquote(x['url']), x['sig'])) for x in streams] + streams = re.search(r'"url_encoded_fmt_stream_map": "(.*?)",', html).group(1) + streams = [x.split('\u0026') for x in streams.split(',')] + streams = [dict((y.split('=',1)) for y in x) for x in streams] + streams = [(int(x['itag']), "%s&signature=%s" % (unquote(x['url']), x['sig'])) for x in streams] #self.logDebug("Found links: %s" % streams) self.logDebug("AVAILABLE STREAMS: %s" % [x[0] for x in streams]) -- cgit v1.2.3