diff options
-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/YoutubeCom.py | 4 | ||||
-rw-r--r-- | module/plugins/internal/Captcha.py | 2 | ||||
-rw-r--r-- | module/plugins/internal/SimpleCrypter.py | 3 |
7 files changed, 123 insertions, 41 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/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 86cca7cf1..9c7421be1 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -36,7 +36,7 @@ class YoutubeCom(Hoster): __version__ = "0.45" __status__ = "testing" - __pattern__ = r'https?://(?:[^/]*\.)?(youtube\.com|youtu\.be)/watch\?(?:.*&)?v=.+' + __pattern__ = r'https?://(?:[^/]*\.)?(youtube\.com/watch\?v=|youtu\.be)(?:.*)' __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 +51,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/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 |