diff options
Diffstat (limited to 'module')
-rw-r--r-- | module/plugins/crypter/LinkCryptWs.py | 13 | ||||
-rw-r--r-- | module/plugins/crypter/MultiUpOrg.py | 8 | ||||
-rw-r--r-- | module/plugins/crypter/SexuriaCom.py | 61 | ||||
-rw-r--r-- | module/plugins/hooks/TransmissionRPC.py | 73 | ||||
-rw-r--r-- | module/plugins/hoster/OneFichierCom.py | 59 | ||||
-rw-r--r-- | module/plugins/hoster/YoutubeCom.py | 28 | ||||
-rw-r--r-- | module/plugins/internal/Captcha.py | 2 | ||||
-rw-r--r-- | module/plugins/internal/Plugin.py | 22 | ||||
-rw-r--r-- | module/plugins/internal/SimpleCrypter.py | 3 |
9 files changed, 204 insertions, 65 deletions
diff --git a/module/plugins/crypter/LinkCryptWs.py b/module/plugins/crypter/LinkCryptWs.py index af13f55f6..557a63cbd 100644 --- a/module/plugins/crypter/LinkCryptWs.py +++ b/module/plugins/crypter/LinkCryptWs.py @@ -31,7 +31,6 @@ class LinkCryptWs(Crypter): def setup(self): - self.captcha = False self.links = [] self.sources = ['cnl', 'web', 'dlc', 'rsdf', 'ccf'] @@ -60,7 +59,6 @@ class LinkCryptWs(Crypter): self.retry(8, 15, _("Can't handle Key-Captcha")) if self.is_captcha_protected(): - self.captcha = True self.unlock_captcha_protection() self.handle_captcha_errors() @@ -165,12 +163,11 @@ class LinkCryptWs(Crypter): def handle_captcha_errors(self): - if self.captcha: - if "Your choice was wrong!" in self.html: - self.captcha.invalid() - self.retry() - else: - self.captcha.correct() + if "Your choice was wrong!" in self.html: + self.captcha.invalid() + self.retry() + else: + self.captcha.correct() def handle_link_source(self, type): diff --git a/module/plugins/crypter/MultiUpOrg.py b/module/plugins/crypter/MultiUpOrg.py index 23e6dfa4a..fb228c3cd 100644 --- a/module/plugins/crypter/MultiUpOrg.py +++ b/module/plugins/crypter/MultiUpOrg.py @@ -9,10 +9,10 @@ from module.plugins.internal.SimpleCrypter import SimpleCrypter, create_getInfo class MultiUpOrg(SimpleCrypter): __name__ = "MultiUpOrg" __type__ = "crypter" - __version__ = "0.04" + __version__ = "0.05" __status__ = "testing" - __pattern__ = r'http://(?:www\.)?multiup\.org/(en|fr)/(?P<TYPE>project|download|miror)/\w+(/\w+)?' + __pattern__ = r'http://(?:www\.)?multiup\.org/(en|fr)/(?P<TYPE>project|download|mirror)/\w+(/\w+)?' __config__ = [("use_premium" , "bool", "Use premium account if available" , True), ("use_subfolder" , "bool", "Save package to subfolder" , True), ("subfolder_per_pack", "bool", "Create a subfolder for each package", True)] @@ -34,8 +34,8 @@ class MultiUpOrg(SimpleCrypter): pattern = r'style="width:97%;text-align:left".*\n.*href="(.*)"' if m_type == "download": dl_pattern = r'href="(.*)">.*\n.*<h5>DOWNLOAD</h5>' - miror_page = urlparse.urljoin("http://www.multiup.org/", re.search(dl_pattern, self.html).group(1)) - self.html = self.load(miror_page) + mirror_page = urlparse.urljoin("http://www.multiup.org/", re.search(dl_pattern, self.html).group(1)) + self.html = self.load(mirror_page) return re.findall(pattern, self.html) diff --git a/module/plugins/crypter/SexuriaCom.py b/module/plugins/crypter/SexuriaCom.py index 7942d5e42..24a5060b9 100644 --- a/module/plugins/crypter/SexuriaCom.py +++ b/module/plugins/crypter/SexuriaCom.py @@ -1,25 +1,23 @@ # -*- coding: utf-8 -*- import re - from module.plugins.internal.Crypter import Crypter - class SexuriaCom(Crypter): __name__ = "SexuriaCom" __type__ = "crypter" - __version__ = "0.04" + __version__ = "0.10" __status__ = "testing" __pattern__ = r'http://(?:www\.)?sexuria\.com/(v1/)?(Pornos_Kostenlos_.+?_(\d+)\.html|dl_links_\d+_\d+\.html|id=\d+\&part=\d+\&link=\d+)' - __config__ = [("use_subfolder" , "bool", "Save package to subfolder" , True), - ("subfolder_per_pack", "bool", "Create a subfolder for each package", True)] + __config__ = [("use_subfolder" , "bool", "Save package to subfolder" , True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] __description__ = """Sexuria.com decrypter plugin""" __license__ = "GPLv3" __authors__ = [("NETHead", "NETHead.AT.gmx.DOT.net")] - + #: Constants PATTERN_SUPPORTED_MAIN = r'http://(www\.)?sexuria\.com/(v1/)?Pornos_Kostenlos_.+?_(\d+)\.html' PATTERN_SUPPORTED_CRYPT = r'http://(www\.)?sexuria\.com/(v1/)?dl_links_\d+_(?P<ID>\d+)\.html' PATTERN_SUPPORTED_REDIRECT = r'http://(www\.)?sexuria\.com/out\.php\?id=(?P<ID>\d+)\&part=\d+\&link=\d+' @@ -27,15 +25,17 @@ class SexuriaCom(Crypter): PATTERN_PASSWORD = r'<strong>Passwort: </strong></div></td>.*?bgcolor="#EFEFEF">(?P<PWD>.*?)</td>' PATTERN_DL_LINK_PAGE = r'"(dl_links_\d+_\d+\.html)"' PATTERN_REDIRECT_LINKS = r'value="(http://sexuria\.com/out\.php\?id=\d+\&part=\d+\&link=\d+)" readonly' - + LIST_PWDIGNORE = ["Kein Passwort", "-"] def decrypt(self, pyfile): #: Init self.pyfile = pyfile self.package = pyfile.package() - #: Get package links + #: Decrypt and add links package_name, self.links, folder_name, package_pwd = self.decrypt_links(self.pyfile.url) + if package_pwd: + self.pyfile.package().password = package_pwd self.packages = [(package_name, self.links, folder_name)] @@ -62,34 +62,45 @@ class SexuriaCom(Crypter): #: Extract info from main file id = re.search(self.PATTERN_SUPPORTED_CRYPT, url, re.I).group('ID') html = self.load("http://sexuria.com/v1/Pornos_Kostenlos_info_%s.html" % id) + #: Webpage title / Package name + titledata = re.search(self.PATTERN_TITLE, html, re.I) + if not titledata: + self.log_warning("No title data found, has site changed?") + else: + title = titledata.group('TITLE').strip() + if title: + name = folder = title + self.log_debug("Package info found, name [%s] and folder [%s]" % (name, folder)) + #: Password + pwddata = re.search(self.PATTERN_PASSWORD, html, re.I | re.S) + if not pwddata: + self.log_warning("No password data found, has site changed?") + else: + pwd = pwddata.group('PWD').strip() + if pwd and not (pwd in self.LIST_PWDIGNORE): + password = pwd + self.log_debug("Package info found, password [%s]" % password) - title = re.search(self.PATTERN_TITLE, html, re.I).group('TITLE').strip() - if title: - name = folder = title - self.log_debug("Package info found, name [%s] and folder [%s]" % (name, folder)) - - pwd = re.search(self.PATTERN_PASSWORD, html, re.I | re.S).group('PWD') - if pwd and pwd not in ("Kein Passwort", "-"): - password = pwd.strip() - self.log_debug("Password info [%s] found" % password) - - #: Process link (dl_link) + #: Process links (dl_link) html = self.load(url) links = re.findall(self.PATTERN_REDIRECT_LINKS, html, re.I) - if len(links) == 0: + if not links: self.log_error(_("Broken for link: %s") % link) else: for link in links: link = link.replace("http://sexuria.com/", "http://www.sexuria.com/") finallink = self.load(link, just_header=True)['location'] - if not finallink or "sexuria.com/" in finallink: + if not finallink or ("sexuria.com/" in finallink): self.log_error(_("Broken for link: %s") % link) else: linklist.append(finallink) - #: Debug log - self.log_debug("%d supported links" % len(linklist)) - for i, link in enumerate(linklist): - self.log_debug("Supported link %d, %s" % (i + 1, link)) + #: Log result + if not linklist: + self.fail(_("Unable to extract links (maybe plugin out of date?)")) + else: + for i, link in enumerate(linklist): + self.log_debug("Supported link %d/%d: %s" % (i+1, len(linklist), link)) + #: All done, return to caller return name, linklist, folder, password diff --git a/module/plugins/hooks/TransmissionRPC.py b/module/plugins/hooks/TransmissionRPC.py new file mode 100644 index 000000000..3d10b90c4 --- /dev/null +++ b/module/plugins/hooks/TransmissionRPC.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- + +import re +import random +import pycurl + +from module.common.json_layer import json_loads, json_dumps +from module.network.HTTPRequest import BadHeader +from module.network.RequestFactory import getRequest as get_request +from module.plugins.internal.Addon import Addon + +class TransmissionRPC(Addon): + __name__ = "TransmissionRPC" + __type__ = "hook" + __status__ = "testing" + + __pattern__ = r"https?://.+\.torrent|magnet:\?.+" + __config__ = [("transmissionrpcurl" , "string" , "Transmission RPC URL" , "http://127.0.0.1:9091/transmission/rpc")] + + __version__ = "0.1" + __description__ = """Send torrent and magnet URLs to Transmission Bittorent daemon via RPC""" + __authors__ = [("GammaC0de", None)] + + + def init(self): + self.event_map = {'linksAdded': "links_added"} + + + def links_added(self, links, pid): + for link in links: + m = re.search(self.__pattern__, link) + if m: + self.log_debug("sending link: %s" % link) + self.SendToTransmission(link) + links.remove(link) + + + def SendToTransmission(self, url): + transmission_rpc_url = self.get_config('transmissionrpcurl') + client_request_id = self.__name__ + "".join(random.choice('0123456789ABCDEF') for _i in xrange(4)) + req = get_request() + + try: + response = self.load(transmission_rpc_url, + post=json_dumps({'arguments': {'filename': url}, + 'method' : 'torrent-add', + 'tag' : client_request_id}), + req=req) + + except BadHeader, e: + if e.code == 409: + headers = dict(re.findall(r"(?P<name>.+?): (?P<value>.+?)\r?\n", req.header)) + session_id = headers['X-Transmission-Session-Id'] + req.c.setopt(pycurl.HTTPHEADER, ["X-Transmission-Session-Id: %s" % session_id]) + response = self.load(transmission_rpc_url, + post=json_dumps({'arguments': {'filename': url}, + 'method' : 'torrent-add', + 'tag' : client_request_id}), + req=req) + + else: + self.log_error(e) + + except Exception, e: + self.log_error(e) + + try: + res = json_loads(response) + if "result" in res: + self.log_debug("result: %s" % res['result']) + + except Exception, e: + self.log_error(e) diff --git a/module/plugins/hoster/OneFichierCom.py b/module/plugins/hoster/OneFichierCom.py index cba67b26c..93f056377 100644 --- a/module/plugins/hoster/OneFichierCom.py +++ b/module/plugins/hoster/OneFichierCom.py @@ -2,13 +2,14 @@ import re +from module.network.RequestFactory import getURL as get_url from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class OneFichierCom(SimpleHoster): __name__ = "OneFichierCom" __type__ = "hoster" - __version__ = "0.88" + __version__ = "0.89" __status__ = "testing" __pattern__ = r'https?://(?:www\.)?(?:(?P<ID1>\w+)\.)?(?P<HOST>1fichier\.com|alterupload\.com|cjoint\.net|d(es)?fichiers\.com|dl4free\.com|megadl\.fr|mesfichiers\.org|piecejointe\.net|pjointe\.com|tenvoi\.com)(?:/\?(?P<ID2>\w+))?' @@ -28,6 +29,8 @@ class OneFichierCom(SimpleHoster): COOKIES = [("1fichier.com", "LG", "en")] + DIRECT_LINK = True + NAME_PATTERN = r'>File\s*Name :</td>\s*<td.*>(?P<N>.+?)<' SIZE_PATTERN = r'>Size :</td>\s*<td.*>(?P<S>[\d.,]+) (?P<U>[\w^_]+)' OFFLINE_PATTERN = r'File not found !\s*<' @@ -40,7 +43,61 @@ class OneFichierCom(SimpleHoster): self.resume_download = True + @classmethod + def get_info(cls, url="", html=""): + redirect = url + for i in xrange(10): + try: + headers = dict(re.findall(r"(?P<name>.+?): (?P<value>.+?)\r?\n", get_url(redirect, just_header=True).lower())) + if 'location' in headers and headers['location']: + redirect = headers['location'] + else: + if 'content-type' in headers and headers['content-type'] == "application/octet-stream": + if "filename=" in headers.get('content-disposition'): + name = dict(_i.split("=") for _i in map(str.strip, headers['content-disposition'].split(";"))[1:]['filename'].strip("\"'") + else: + name = url + + info = {'name' : name, + 'size' : long(headers.get('content-length')), + 'status': 3, + 'url' : url} + + else: + info = super(OneFichierCom, cls).get_info(url, html) + + break + + except Exception, e: + info = {'status' : 8, + 'error' : e.message} + + else: + info = {'status' : 8, + 'error' : _("Too many redirects")} + + return info + + + def handle_direct(self, pyfile): + redirect = pyfile.url + for i in xrange(self.get_config("maxredirs", plugin="UserAgentSwitcher")): + + headers = self.load(redirect, just_header=True) + if 'location' in headers and headers['location']: + self.log_debug("Redirect #%d to: %s" % (i, redirect)) + redirect = headers['location'] + else: + if 'content-type' in headers and headers['content-type'] == "application/octet-stream": + self.link = pyfile.url + break + else: + self.fail(_("Too many redirects")) + + def handle_free(self, pyfile): + self.check_errors() + id = self.info['pattern']['ID1'] or self.info['pattern']['ID2'] url, inputs = self.parse_html_form('action="https://1fichier.com/\?%s' % id) diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 86cca7cf1..5c7c13962 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -6,37 +6,17 @@ import subprocess import urllib from module.plugins.internal.Hoster import Hoster -from module.plugins.internal.Plugin import replace_patterns +from module.plugins.internal.Plugin import replace_patterns, which from module.utils import html_unescape -def which(program): - """ - Works exactly like the unix command which - Courtesy of http://stackoverflow.com/a/377028/675646 - """ - isExe = lambda x: os.path.isfile(x) and os.access(x, os.X_OK) - - fpath, fname = os.path.split(program) - - if fpath: - if isExe(program): - return program - else: - for path in os.environ['PATH'].split(os.pathsep): - path = path.strip('"') - exe_file = os.path.join(path, program) - if isExe(exe_file): - return exe_file - - class YoutubeCom(Hoster): __name__ = "YoutubeCom" __type__ = "hoster" - __version__ = "0.45" + __version__ = "0.46" __status__ = "testing" - __pattern__ = r'https?://(?:[^/]*\.)?(youtube\.com|youtu\.be)/watch\?(?:.*&)?v=.+' + __pattern__ = r'https?://(?:[^/]*\.)?(youtu\.be/|youtube\.com/watch\?(?:.*&)?v=)\w+' __config__ = [("quality", "sd;hd;fullhd;240p;360p;480p;720p;1080p;3072p", "Quality Setting" , "hd" ), ("fmt" , "int" , "FMT/ITAG Number (0 for auto)", 0 ), (".mp4" , "bool" , "Allow .mp4" , True ), @@ -51,7 +31,7 @@ class YoutubeCom(Hoster): ("zoidberg", "zoidberg@mujmail.cz")] - URL_REPLACEMENTS = [(r'youtu\.be/', 'youtube.com/')] + URL_REPLACEMENTS = [(r'youtu\.be/', 'youtube.com/watch?v=')] #: Invalid characters that must be removed from the file name invalid_chars = u'\u2605:?><"|\\' diff --git a/module/plugins/internal/Captcha.py b/module/plugins/internal/Captcha.py index c08050ee8..600fd1d34 100644 --- a/module/plugins/internal/Captcha.py +++ b/module/plugins/internal/Captcha.py @@ -120,7 +120,7 @@ class Captcha(Plugin): self.log_warning(_("Error removing: %s") % tmp_img.name, e) traceback.print_exc() - self.log_info(_("Captcha result: ") + result) #@TODO: Remove from here? + #self.log_info(_("Captcha result: ") + result) #@TODO: Remove from here? return result diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py index 7b45c40a8..1e04d388e 100644 --- a/module/plugins/internal/Plugin.py +++ b/module/plugins/internal/Plugin.py @@ -54,6 +54,26 @@ def fixurl(url): #@TODO: Move to utils in 0.4.10 def timestamp(): return int(time.time() * 1000) + + +#@TODO: Move to utils in 0.4.10 +def which(program): + """ + Works exactly like the unix command which + Courtesy of http://stackoverflow.com/a/377028/675646 + """ + isExe = lambda x: os.path.isfile(x) and os.access(x, os.X_OK) + + fpath, fname = os.path.split(program) + + if fpath: + if isExe(program): + return program + else: + for path in os.environ['PATH'].split(os.pathsep): + exe_file = os.path.join(path.strip('"'), program) + if isExe(exe_file): + return exe_file def seconds_to_midnight(gmt=0): @@ -146,7 +166,7 @@ def chunks(iterable, size): class Plugin(object): __name__ = "Plugin" __type__ = "hoster" - __version__ = "0.30" + __version__ = "0.31" __status__ = "testing" __pattern__ = r'^unmatchable$' diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 6a3f91a5b..9597116cc 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -10,7 +10,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter, SimpleHoster): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.60" + __version__ = "0.61" __status__ = "testing" __pattern__ = r'^unmatchable$' @@ -91,6 +91,7 @@ class SimpleCrypter(Crypter, SimpleHoster): def decrypt(self, pyfile): + self.links = [] #@TODO: Recheck in 0.4.10 self.prepare() self.check_info() #@TODO: Remove in 0.4.10 |