diff options
author | Stefano <l.stickell@yahoo.it> | 2013-05-12 00:31:23 +0200 |
---|---|---|
committer | Stefano <l.stickell@yahoo.it> | 2013-05-12 00:31:23 +0200 |
commit | ac94c1e73cae76877632bee17f7f4e345fd13188 (patch) | |
tree | 4b6bfc5b7f9b56c51297748cc647122b7e38637f | |
parent | Merge pull request #112 from Vuolter/plugin/DeleteFinished (diff) | |
parent | YoutubeBatch.py, YoutubeCom.py: Synced regulare expression. (diff) | |
download | pyload-ac94c1e73cae76877632bee17f7f4e345fd13188.tar.xz |
Merge pull request #113 from 4Christopher/stable
YoutubeCom.py: Fixed regular expression.
-rw-r--r-- | module/plugins/crypter/YoutubeBatch.py | 6 | ||||
-rw-r--r-- | module/plugins/hoster/YoutubeCom.py | 50 |
2 files changed, 28 insertions, 28 deletions
diff --git a/module/plugins/crypter/YoutubeBatch.py b/module/plugins/crypter/YoutubeBatch.py index 567191bb9..72b72aab7 100644 --- a/module/plugins/crypter/YoutubeBatch.py +++ b/module/plugins/crypter/YoutubeBatch.py @@ -11,8 +11,8 @@ API_KEY = "AIzaSyCKnWLNlkX-L4oD1aEzqqhRw1zczeD6_k0" class YoutubeBatch(Crypter): __name__ = "YoutubeBatch" __type__ = "container" - __pattern__ = r"http://(?:[^/]*?)youtube\.com/((?:view_play_list|playlist|.*?feature=PlayList).*?[\?&](?:list|p)=)([a-zA-Z0-9-_]+)" - __version__ = "0.92" + __pattern__ = r"https?://(?:[^/]*?)youtube\.com/(?:(?:view_play_list|playlist|.*?feature=PlayList).*?[?&](?:list|p)=)([a-zA-Z0-9-_]+)" + __version__ = "0.93" __description__ = """Youtube.com Channel Download Plugin""" __author_name__ = ("RaNaN", "Spoob", "zoidberg", "roland") __author_mail__ = ("RaNaN@pyload.org", "spoob@pyload.org", "zoidberg@mujmail.cz", "roland@enkore.de") @@ -35,7 +35,7 @@ class YoutubeBatch(Crypter): def decrypt(self, pyfile): match_id = re.match(self.__pattern__, self.pyfile.url) new_links = [] - playlist_id = match_id.group(2) + playlist_id = match_id.group(1) new_links.extend(self.get_videos(playlist_id)) diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 304cffd69..70db597cf 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -33,8 +33,8 @@ def which(program): class YoutubeCom(Hoster): __name__ = "YoutubeCom" __type__ = "hoster" - __pattern__ = r"(http|https)://(www\.)?(de\.)?\youtube\.com/watch\?v=.*" - __version__ = "0.31" + __pattern__ = r"https?://(?:[^/]*?)youtube\.com/watch.*?[?&]v=.*" + __version__ = "0.32" __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), @@ -47,9 +47,9 @@ class YoutubeCom(Hoster): __author_mail__ = ("spoob@pyload.org", "zoidberg@mujmail.cz") # name, width, height, quality ranking, 3D - formats = {5: (".flv", 400, 240, 1, False), + formats = {5: (".flv", 400, 240, 1, False), 6: (".flv", 640, 400, 4, False), - 17: (".3gp", 176, 144, 0, 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), @@ -59,7 +59,7 @@ class YoutubeCom(Hoster): 37: (".mp4", 1920, 1080, 9, False), 38: (".mp4", 4096, 3072, 10, False), 44: (".webm", 854, 480, 5, False), - 45: (".webm", 1280, 720, 7, 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), @@ -81,49 +81,49 @@ class YoutubeCom(Hoster): if "We have been receiving a large volume of requests from your network." in html: self.tempOffline() - + #get config use3d = self.getConf("3d") if use3d: - quality = {"sd":82,"hd":84,"fullhd":85,"240p":83,"360p":82,"480p":82,"720p":84,"1080p":85,"3072p":85} + 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} + 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 self.formats: - self.logWarning("FMT %d unknown - using default." % desired_fmt) - desired_fmt = 0 + self.logWarning("FMT %d unknown - using default." % desired_fmt) + desired_fmt = 0 if not desired_fmt: - desired_fmt = quality.get(self.getConf("quality"), 18) - + desired_fmt = quality.get(self.getConf("quality"), 18) + #parse available 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]) - + #self.logDebug("Found links: %s" % streams) + self.logDebug("AVAILABLE STREAMS: %s" % [x[0] for x in streams]) + #build dictionary of supported itags (3D/2D) - allowed = lambda x: self.getConfig(self.formats[x][0]) + 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, + 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 desired_fmt in fmt_dict else "NOT ", "" if allowed(desired_fmt) else "NOT ") - ) + ) - #return fmt nearest to quality index + #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()) @@ -132,7 +132,7 @@ class YoutubeCom(Hoster): url = fmt_dict[fmt] self.logDebug("URL: %s" % url) - #set file name + #set file name file_suffix = self.formats[fmt][0] if fmt in self.formats else ".flv" file_name_pattern = '<meta name="title" content="(.+?)">' name = re.search(file_name_pattern, html).group(1).replace("/", "") |