diff options
author | Stefano <l.stickell@yahoo.it> | 2014-06-24 16:48:20 +0200 |
---|---|---|
committer | Stefano <l.stickell@yahoo.it> | 2014-06-24 16:48:20 +0200 |
commit | bfb0134f75b1faed65de0d415c57bc296c7a37d7 (patch) | |
tree | 4fc9b8f87c2fc57cba9862c9eb07c67af4caf9e9 /module/plugins/hoster/YoutubeCom.py | |
parent | [Oboom] new hoster and account (diff) | |
download | pyload-bfb0134f75b1faed65de0d415c57bc296c7a37d7.tar.xz |
[YouTube] Support shortened "youtu.be" links.
+ Improved bad chars sanitation in filename.
See #656
Diffstat (limited to 'module/plugins/hoster/YoutubeCom.py')
-rw-r--r-- | module/plugins/hoster/YoutubeCom.py | 13 |
1 files changed, 11 insertions, 2 deletions
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'<div id="player-unavailable" class="\s*player-width player-height\s*">', 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) |