From bfb0134f75b1faed65de0d415c57bc296c7a37d7 Mon Sep 17 00:00:00 2001 From: Stefano Date: Tue, 24 Jun 2014 16:48:20 +0200 Subject: [YouTube] Support shortened "youtu.be" links. + Improved bad chars sanitation in filename. See #656 --- module/plugins/hoster/YoutubeCom.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/YoutubeCom.py') diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 330aae190..6505eac1a 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -7,6 +7,7 @@ from urllib import unquote from module.utils import html_unescape from module.plugins.Hoster import Hoster +from module.plugins.internal.SimpleHoster import replace_patterns def which(program): @@ -34,8 +35,8 @@ def which(program): class YoutubeCom(Hoster): __name__ = "YoutubeCom" __type__ = "hoster" - __pattern__ = r'https?://(?:[^/]*\.)?youtube\.com/watch.*?[?&]v=.*' - __version__ = "0.39" + __pattern__ = r'https?://(?:[^/]*\.)?(?:youtube\.com|youtu\.be)/watch.*?[?&]v=.*' + __version__ = "0.40" __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,6 +48,11 @@ class YoutubeCom(Hoster): __author_name__ = ("spoob", "zoidberg") __author_mail__ = ("spoob@pyload.org", "zoidberg@mujmail.cz") + FILE_URL_REPLACEMENTS = [(r'youtu\.be/', 'youtube.com/')] + + # Invalid characters that must be removed from the file name + invalidChars = u'\u2605:?><"|\\' + # name, width, height, quality ranking, 3D formats = {5: (".flv", 400, 240, 1, False), 6: (".flv", 640, 400, 4, False), @@ -74,6 +80,7 @@ class YoutubeCom(Hoster): self.resumeDownload = self.multiDL = True def process(self, pyfile): + pyfile.url = replace_patterns(pyfile.url, self.FILE_URL_REPLACEMENTS) html = self.load(pyfile.url, decode=True) if re.search(r'
', html): @@ -138,6 +145,8 @@ class YoutubeCom(Hoster): # Cleaning invalid characters from the file name name = name.encode('ascii', 'replace') + for c in self.invalidChars: + name = name.replace(c, '_') pyfile.name = html_unescape(name) -- cgit v1.2.3 From 7b8c458cca7d21a029620f98e453f746fce69cd1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 16:10:01 +0200 Subject: Prefer single quote for dict key name --- module/plugins/hoster/YoutubeCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/YoutubeCom.py') diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 6505eac1a..eb260298b 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -23,7 +23,7 @@ def which(program): if is_exe(program): return program else: - for path in os.environ["PATH"].split(os.pathsep): + for path in os.environ['PATH'].split(os.pathsep): path = path.strip('"') exe_file = os.path.join(path, program) if is_exe(exe_file): -- cgit v1.2.3 From 05d258d98dd8c2faf0b769840fa1e3c4acccdce8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 20 Jul 2014 03:25:14 +0200 Subject: Fix and improve 5060e4c6374a5116d0d8b02528f910f8c5f8bcf9 --- module/plugins/hoster/YoutubeCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/YoutubeCom.py') diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index eb260298b..d9dc5e0ef 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -154,7 +154,7 @@ class YoutubeCom(Hoster): ffmpeg = which("ffmpeg") if ffmpeg and time: m, s = time.groups()[1:] - if not m: + if m is None: m = "0" pyfile.name += " (starting at %s:%s)" % (m, s) -- cgit v1.2.3 From ba916633f2bedb04c7358000b91aed69f52e8e43 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 1 Aug 2014 19:35:59 +0200 Subject: Remove trailing whitespaces + remove license headers + import urllib methods directly + sort and fix key attributes + use save_join instead join + sort some import declarations + other minor code cosmetics --- module/plugins/hoster/YoutubeCom.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'module/plugins/hoster/YoutubeCom.py') diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index d9dc5e0ef..5ffef5531 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- +import os import re import subprocess -import os + from urllib import unquote -from module.utils import html_unescape from module.plugins.Hoster import Hoster from module.plugins.internal.SimpleHoster import replace_patterns +from module.utils import html_unescape def which(program): @@ -35,8 +36,9 @@ def which(program): class YoutubeCom(Hoster): __name__ = "YoutubeCom" __type__ = "hoster" - __pattern__ = r'https?://(?:[^/]*\.)?(?:youtube\.com|youtu\.be)/watch.*?[?&]v=.*' __version__ = "0.40" + + __pattern__ = r'https?://(?:[^/]*\.)?(?:youtube\.com|youtu\.be)/watch.*?[?&]v=.*' __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), @@ -44,6 +46,7 @@ class YoutubeCom(Hoster): (".webm", "bool", "Allow .webm", False), (".3gp", "bool", "Allow .3gp", False), ("3d", "bool", "Prefer 3D", False)] + __description__ = """Youtube.com hoster plugin""" __author_name__ = ("spoob", "zoidberg") __author_mail__ = ("spoob@pyload.org", "zoidberg@mujmail.cz") @@ -76,6 +79,7 @@ class YoutubeCom(Hoster): 101: (".webm", 640, 360, 4, True), 102: (".webm", 1280, 720, 8, True)} + def setup(self): self.resumeDownload = self.multiDL = True -- cgit v1.2.3 From b0868ae6446078bacf1635dde5e4ab316b4a94cb Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 7 Oct 2014 18:57:59 +0200 Subject: New __authors__ key replaces __author_name__ and __author_mail__ + Whitespaces and EOF fixup --- module/plugins/hoster/YoutubeCom.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/YoutubeCom.py') diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 5ffef5531..90cb88b18 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -48,8 +48,9 @@ class YoutubeCom(Hoster): ("3d", "bool", "Prefer 3D", False)] __description__ = """Youtube.com hoster plugin""" - __author_name__ = ("spoob", "zoidberg") - __author_mail__ = ("spoob@pyload.org", "zoidberg@mujmail.cz") + __authors__ = [("spoob", "spoob@pyload.org"), + ("zoidberg", "zoidberg@mujmail.cz")] + FILE_URL_REPLACEMENTS = [(r'youtu\.be/', 'youtube.com/')] -- cgit v1.2.3 From ae7a7e66981456e5bbe2b54006d79b6f907be7a4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 8 Oct 2014 20:18:13 +0200 Subject: Add __license__ key attribute to plugins --- module/plugins/hoster/YoutubeCom.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/hoster/YoutubeCom.py') diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 90cb88b18..5eacdc738 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -48,6 +48,7 @@ class YoutubeCom(Hoster): ("3d", "bool", "Prefer 3D", False)] __description__ = """Youtube.com hoster plugin""" + __license__ = "GPLv3" __authors__ = [("spoob", "spoob@pyload.org"), ("zoidberg", "zoidberg@mujmail.cz")] -- cgit v1.2.3 From 0eb6e7ec4a1144dcca824d8add049787d3da1762 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 22 Oct 2014 19:44:59 +0200 Subject: Two space before function declaration --- module/plugins/hoster/YoutubeCom.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'module/plugins/hoster/YoutubeCom.py') diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 5eacdc738..f16e9ae43 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -16,6 +16,7 @@ def which(program): Courtesy of http://stackoverflow.com/a/377028/675646""" + def is_exe(fpath): return os.path.isfile(fpath) and os.access(fpath, os.X_OK) @@ -85,6 +86,7 @@ class YoutubeCom(Hoster): def setup(self): self.resumeDownload = self.multiDL = True + def process(self, pyfile): pyfile.url = replace_patterns(pyfile.url, self.FILE_URL_REPLACEMENTS) html = self.load(pyfile.url, decode=True) -- cgit v1.2.3 From 9f2ebe486a3e155fb6a60e07cccb77ab6a772eb2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 26 Oct 2014 02:31:54 +0200 Subject: Extend translation support in plugins + a lot of code cosmetics and typo fixes --- module/plugins/hoster/YoutubeCom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/YoutubeCom.py') diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index f16e9ae43..7198b6a82 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -107,7 +107,7 @@ class YoutubeCom(Hoster): "480p": 35, "720p": 22, "1080p": 37, "3072p": 38} desired_fmt = self.getConfig("fmt") if desired_fmt and desired_fmt not in self.formats: - self.logWarning("FMT %d unknown - using default." % desired_fmt) + self.logWarning(_("FMT %d unknown, using default") % desired_fmt) desired_fmt = 0 if not desired_fmt: desired_fmt = quality.get(self.getConfig("quality"), 18) @@ -124,7 +124,7 @@ class YoutubeCom(Hoster): 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") + 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" % -- cgit v1.2.3 From 34984dae733c3f3d47b41a0acfba3724d53c65a1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 16:52:10 +0100 Subject: Code cosmetics: plugin class attributes --- module/plugins/hoster/YoutubeCom.py | 10 +++++----- 1 file changed, 5 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 7198b6a82..3dca83d7f 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -35,8 +35,8 @@ def which(program): class YoutubeCom(Hoster): - __name__ = "YoutubeCom" - __type__ = "hoster" + __name__ = "YoutubeCom" + __type__ = "hoster" __version__ = "0.40" __pattern__ = r'https?://(?:[^/]*\.)?(?:youtube\.com|youtu\.be)/watch.*?[?&]v=.*' @@ -49,9 +49,9 @@ class YoutubeCom(Hoster): ("3d", "bool", "Prefer 3D", False)] __description__ = """Youtube.com hoster plugin""" - __license__ = "GPLv3" - __authors__ = [("spoob", "spoob@pyload.org"), - ("zoidberg", "zoidberg@mujmail.cz")] + __license__ = "GPLv3" + __authors__ = [("spoob", "spoob@pyload.org"), + ("zoidberg", "zoidberg@mujmail.cz")] FILE_URL_REPLACEMENTS = [(r'youtu\.be/', 'youtube.com/')] -- cgit v1.2.3 From 772e47ef806d18fd209e910be0535bce7c07dc7b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 2 Nov 2014 22:47:07 +0100 Subject: Update all other plugins --- module/plugins/hoster/YoutubeCom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/YoutubeCom.py') diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 3dca83d7f..565aa63f0 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -54,7 +54,7 @@ class YoutubeCom(Hoster): ("zoidberg", "zoidberg@mujmail.cz")] - FILE_URL_REPLACEMENTS = [(r'youtu\.be/', 'youtube.com/')] + URL_REPLACEMENTS = [(r'youtu\.be/', 'youtube.com/')] # Invalid characters that must be removed from the file name invalidChars = u'\u2605:?><"|\\' @@ -88,7 +88,7 @@ class YoutubeCom(Hoster): def process(self, pyfile): - pyfile.url = replace_patterns(pyfile.url, self.FILE_URL_REPLACEMENTS) + pyfile.url = replace_patterns(pyfile.url, self.URL_REPLACEMENTS) html = self.load(pyfile.url, decode=True) if re.search(r'
', html): -- cgit v1.2.3 From f4db1a3ce2692b9f310dac1548c1966bcea319a2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 6 Dec 2014 22:47:56 +0100 Subject: Plugin code cosmetics (2) --- module/plugins/hoster/YoutubeCom.py | 44 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'module/plugins/hoster/YoutubeCom.py') diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 565aa63f0..617a30867 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -16,11 +16,11 @@ def which(program): Courtesy of http://stackoverflow.com/a/377028/675646""" - def is_exe(fpath): return os.path.isfile(fpath) and os.access(fpath, os.X_OK) fpath, fname = os.path.split(program) + if fpath: if is_exe(program): return program @@ -60,27 +60,27 @@ class YoutubeCom(Hoster): invalidChars = u'\u2605:?><"|\\' # 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)} + 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 )} def setup(self): -- cgit v1.2.3 From 67587fbe0335cacfde28a86ba729b9d567ce1da7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 7 Dec 2014 00:27:18 +0100 Subject: Plugin code cosmetics (3) --- module/plugins/hoster/YoutubeCom.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'module/plugins/hoster/YoutubeCom.py') diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 617a30867..bb0737440 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -84,7 +84,8 @@ class YoutubeCom(Hoster): def setup(self): - self.resumeDownload = self.multiDL = True + self.resumeDownload = True + self.multiDL = True def process(self, pyfile): -- cgit v1.2.3 From cdb06469a640c1875229903a2dbdfa8be469b5bc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 27 Dec 2014 13:52:30 +0100 Subject: Improve a lot of plugin __pattern__ --- module/plugins/hoster/YoutubeCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/YoutubeCom.py') diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index bb0737440..90c6df3c2 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -39,7 +39,7 @@ class YoutubeCom(Hoster): __type__ = "hoster" __version__ = "0.40" - __pattern__ = r'https?://(?:[^/]*\.)?(?:youtube\.com|youtu\.be)/watch.*?[?&]v=.*' + __pattern__ = r'https?://(?:[^/]*\.)?(?:youtube\.com|youtu\.be)/watch.*?[?&]v=.+' __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), -- cgit v1.2.3