diff options
Diffstat (limited to 'module/plugins/hoster')
207 files changed, 6600 insertions, 6954 deletions
diff --git a/module/plugins/hoster/AlldebridCom.py b/module/plugins/hoster/AlldebridCom.py index 11ee8b7d3..d7dbe31a6 100644 --- a/module/plugins/hoster/AlldebridCom.py +++ b/module/plugins/hoster/AlldebridCom.py @@ -1,83 +1,82 @@ # -*- coding: utf-8 -*- import re -from urllib import unquote + from random import randrange -from module.plugins.Hoster import Hoster +from urllib import unquote + from module.common.json_layer import json_loads +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo from module.utils import parseFileSize -class AlldebridCom(Hoster): - __name__ = "AlldebridCom" - __version__ = "0.34" - __type__ = "hoster" +class AlldebridCom(MultiHoster): + __name__ = "AlldebridCom" + __type__ = "hoster" + __version__ = "0.42" + + __pattern__ = r'https?://(?:www\.|s\d+\.)?alldebrid\.com/dl/[\w^_]+' - __pattern__ = r'https?://(?:[^/]*\.)?alldebrid\..*' __description__ = """Alldebrid.com hoster plugin""" - __author_name__ = "Andy Voigt" - __author_mail__ = "spamsales@online.de" + __license__ = "GPLv3" + __authors__ = [("Andy Voigt", "spamsales@online.de")] + def getFilename(self, url): try: name = unquote(url.rsplit("/", 1)[1]) except IndexError: name = "Unknown_Filename..." + if name.endswith("..."): # incomplete filename, append random stuff name += "%s.tmp" % randrange(100, 999) + return name + def setup(self): - self.chunkLimit = 16 + self.chunkLimit = 16 self.resumeDownload = True - def process(self, pyfile): - if re.match(self.__pattern__, pyfile.url): - new_url = pyfile.url - elif not self.account: - self.logError(_("Please enter your %s account or deactivate this plugin") % "AllDebrid") - self.fail("No AllDebrid account provided") - else: - self.logDebug("Old URL: %s" % pyfile.url) - password = self.getPassword().splitlines() - password = "" if not password else password[0] - - url = "http://www.alldebrid.com/service.php?link=%s&json=true&pw=%s" % (pyfile.url, password) - page = self.load(url) - data = json_loads(page) - - self.logDebug("Json data: %s" % str(data)) - - if data["error"]: - if data["error"] == "This link isn't available on the hoster website.": - self.offline() - else: - self.logWarning(data["error"]) - self.tempOffline() + + def handlePremium(self): + password = self.getPassword() + + data = json_loads(self.load("http://www.alldebrid.com/service.php", + get={'link': self.pyfile.url, 'json': "true", 'pw': password})) + + self.logDebug("Json data", data) + + if data['error']: + if data['error'] == "This link isn't available on the hoster website.": + self.offline() else: - if pyfile.name and not pyfile.name.endswith('.tmp'): - pyfile.name = data["filename"] - pyfile.size = parseFileSize(data["filesize"]) - new_url = data["link"] + self.logWarning(data['error']) + self.tempOffline() + else: + if self.pyfile.name and not self.pyfile.name.endswith('.tmp'): + self.pyfile.name = data['filename'] + self.pyfile.size = parseFileSize(data['filesize']) + self.link = data['link'] if self.getConfig("https"): - new_url = new_url.replace("http://", "https://") + self.link = self.link.replace("http://", "https://") else: - new_url = new_url.replace("https://", "http://") + self.link = self.link.replace("https://", "http://") - if new_url != pyfile.url: - self.logDebug("New URL: %s" % new_url) + if self.link != self.pyfile.url: + self.logDebug("New URL: %s" % self.link) - if pyfile.name.startswith("http") or pyfile.name.startswith("Unknown"): + if self.pyfile.name.startswith("http") or self.pyfile.name.startswith("Unknown"): #only use when name wasnt already set - pyfile.name = self.getFilename(new_url) + self.pyfile.name = self.getFilename(self.link) + + + def checkFile(self): + super(AlldebridCom, self).checkFile() - self.download(new_url, disposition=True) + if self.checkDownload({'error': "<title>An error occured while processing your request</title>"}) is "error": + self.retry(wait_time=60, reason=_("An error occured while generating link")) - check = self.checkDownload({"error": "<title>An error occured while processing your request</title>", - "empty": re.compile(r"^$")}) - if check == "error": - self.retry(wait_time=60, reason="An error occured while generating link.") - elif check == "empty": - self.retry(wait_time=60, reason="Downloaded File was empty.") +getInfo = create_getInfo(AlldebridCom) diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py index 970ac8081..d0d8e7cc8 100644 --- a/module/plugins/hoster/BasePlugin.py +++ b/module/plugins/hoster/BasePlugin.py @@ -1,113 +1,108 @@ # -*- coding: utf-8 -*- -from urlparse import urlparse -from re import match, search +import re + from urllib import unquote +from urlparse import urljoin, urlparse from module.network.HTTPRequest import BadHeader +from module.plugins.internal.SimpleHoster import create_getInfo from module.plugins.Hoster import Hoster -from module.utils import html_unescape, remove_chars class BasePlugin(Hoster): - __name__ = "BasePlugin" - __type__ = "hoster" + __name__ = "BasePlugin" + __type__ = "hoster" + __version__ = "0.26" + __pattern__ = r'^unmatchable$' - __version__ = "0.19" + __description__ = """Base Plugin when any other didnt fit""" - __author_name__ = "RaNaN" - __author_mail__ = "RaNaN@pyload.org" + __license__ = "GPLv3" + __authors__ = [("RaNaN", "RaNaN@pyload.org"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + @classmethod + def getInfo(cls, url="", html=""): #@TODO: Move to hoster class in 0.4.10 + return {'name': urlparse(unquote(url)).path.split('/')[-1] or _("Unknown"), 'size': 0, 'status': 3 if url else 1, 'url': unquote(url) or ""} + def setup(self): self.chunkLimit = -1 self.resumeDownload = True + def process(self, pyfile): """main function""" - #debug part, for api exerciser - if pyfile.url.startswith("DEBUG_API"): - self.multiDL = False - return - - # self.__name__ = "NetloadIn" - # pyfile.name = "test" - # self.html = self.load("http://localhost:9000/short") - # self.download("http://localhost:9000/short") - # self.api = self.load("http://localhost:9000/short") - # self.decryptCaptcha("http://localhost:9000/captcha") - # - # if pyfile.url == "79": - # self.core.api.addPackage("test", [str(i) for i in xrange(80)], 1) - # - # return - if pyfile.url.startswith("http"): + pyfile.name = self.getInfo(pyfile.url)['name'] + + if not pyfile.url.startswith("http"): + self.fail(_("No plugin matched")) + for _i in xrange(5): try: self.downloadFile(pyfile) + except BadHeader, e: - if e.code in (401, 403): - self.logDebug("Auth required") + if e.code is 404: + self.offline() + + elif e.code in (401, 403): + self.logDebug("Auth required", "Received HTTP status code: %d" % e.code) account = self.core.accountManager.getAccountPlugin('Http') servers = [x['login'] for x in account.getAllAccounts()] - server = urlparse(pyfile.url).netloc + server = urlparse(pyfile.url).netloc if server in servers: self.logDebug("Logging on to %s" % server) - self.req.addAuth(account.accounts[server]["password"]) + self.req.addAuth(account.accounts[server]['password']) else: - for pwd in pyfile.package().password.splitlines(): - if ":" in pwd: - self.req.addAuth(pwd.strip()) - break + pwd = self.getPassword() + if ':' in pwd: + self.req.addAuth(pwd) else: - self.fail(_("Authorization required (username:password)")) - - self.downloadFile(pyfile) + self.fail(_("Authorization required")) else: - raise - + self.fail(e) + else: + break else: - self.fail("No Plugin matched and not a downloadable url.") + self.fail(_("No file downloaded")) #@TODO: Move to hoster class in 0.4.10 + + if self.checkDownload({'empty': re.compile(r"^$")}) is "empty": #@TODO: Move to hoster in 0.4.10 + self.fail(_("Empty file")) + def downloadFile(self, pyfile): url = pyfile.url - for _ in xrange(5): - header = self.load(url, just_header=True) - - # self.load does not raise a BadHeader on 404 responses, do it here - if 'code' in header and header['code'] == 404: - raise BadHeader(404) + for i in xrange(1, 7): #@TODO: retrieve the pycurl.MAXREDIRS value set by req + header = self.load(url, ref=True, cookies=True, just_header=True, decode=True) - if 'location' in header: - self.logDebug("Location: " + header['location']) - base = match(r'https?://[^/]+', url).group(0) - if header['location'].startswith("http"): - url = unquote(header['location']) - elif header['location'].startswith("/"): - url = base + unquote(header['location']) + if 'location' not in header or not header['location']: + if 'code' in header and header['code'] not in (200, 201, 203, 206): + self.logDebug("Received HTTP status code: %d" % header['code']) + self.fail(_("File not found")) else: - url = '%s/%s' % (base, unquote(header['location'])) + break + + location = header['location'] + + self.logDebug("Redirect #%d to: %s" % (i, location)) + + if urlparse(location).scheme: + url = location else: - break + p = urlparse(url) + base = "%s://%s" % (p.scheme, p.netloc) + url = urljoin(base, location) + else: + self.fail(_("Too many redirects")) + + self.download(unquote(url), disposition=True) + - name = html_unescape(unquote(urlparse(url).path.split("/")[-1])) - - if 'content-disposition' in header: - self.logDebug("Content-Disposition: " + header['content-disposition']) - m = search("filename(?P<type>=|\*=(?P<enc>.+)'')(?P<name>.*)", header['content-disposition']) - if m: - disp = m.groupdict() - self.logDebug(disp) - if not disp['enc']: - disp['enc'] = 'utf-8' - name = remove_chars(disp['name'], "\"';").strip() - name = unicode(unquote(name), disp['enc']) - - if not name: - name = url - pyfile.name = name - self.logDebug("Filename: %s" % pyfile.name) - self.download(url, disposition=True) +getInfo = create_getInfo(BasePlugin) diff --git a/module/plugins/hoster/BayfilesCom.py b/module/plugins/hoster/BayfilesCom.py index b080eb386..0929ece01 100644 --- a/module/plugins/hoster/BayfilesCom.py +++ b/module/plugins/hoster/BayfilesCom.py @@ -1,97 +1,18 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. +class BayfilesCom(DeadHoster): + __name__ = "BayfilesCom" + __type__ = "hoster" + __version__ = "0.09" - @author: zoidberg -""" + __pattern__ = r'https?://(?:www\.)?bayfiles\.(com|net)/file/(?P<ID>\w+/\w+/[^/]+)' -import re -from time import time - -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.common.json_layer import json_loads - - -class BayfilesCom(SimpleHoster): - __name__ = "BayfilesCom" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?bayfiles\.(com|net)/file/(?P<ID>[a-zA-Z0-9]+/[a-zA-Z0-9]+/[^/]+)' - __version__ = "0.06" __description__ = """Bayfiles.com hoster plugin""" - __author_name__ = ("zoidberg", "Walter Purcaro") - __author_mail__ = ("zoidberg@mujmail.cz", "vuolter@gmail.com") - - FILE_INFO_PATTERN = r'<p title="(?P<N>[^"]+)">[^<]*<strong>(?P<S>[0-9., ]+)(?P<U>[kKMG])i?B</strong></p>' - FILE_OFFLINE_PATTERN = r'(<p>The requested file could not be found.</p>|<title>404 Not Found</title>)' - - WAIT_PATTERN = r'>Your IP [0-9.]* has recently downloaded a file\. Upgrade to premium or wait (\d+) minutes\.<' - VARS_PATTERN = r'var vfid = (\d+);\s*var delay = (\d+);' - LINK_PATTERN = r"javascript:window.location.href = '([^']+)';" - PREMIUM_LINK_PATTERN = r'(?:<a class="highlighted-btn" href="|(?=http://s\d+\.baycdn\.com/dl/))(.*?)"' - - def handleFree(self): - found = re.search(self.WAIT_PATTERN, self.html) - if found: - self.wait(int(found.group(1)) * 60) - self.retry() - - # Get download token - found = re.search(self.VARS_PATTERN, self.html) - if not found: - self.parseError('VARS') - vfid, delay = found.groups() - - response = json_loads(self.load('https://bayfiles.com/ajax_download', get={ - "_": time() * 1000, - "action": "startTimer", - "vfid": vfid}, decode=True)) - - if not "token" in response or not response['token']: - self.fail('No token') - - self.wait(int(delay)) - - self.html = self.load('https://bayfiles.com/ajax_download', get={ - "token": response['token'], - "action": "getLink", - "vfid": vfid}) - - # Get final link and download - found = re.search(self.LINK_PATTERN, self.html) - if not found: - self.parseError("Free link") - self.startDownload(found.group(1)) - - def handlePremium(self): - found = re.search(self.PREMIUM_LINK_PATTERN, self.html) - if not found: - self.parseError("Premium link") - self.startDownload(found.group(1)) - - def startDownload(self, url): - self.logDebug("%s URL: %s" % ("Premium" if self.premium else "Free", url)) - self.download(url) - # check download - check = self.checkDownload({ - "waitforfreeslots": re.compile(r"<title>BayFiles</title>"), - "notfound": re.compile(r"<title>404 Not Found</title>") - }) - if check == "waitforfreeslots": - self.retry(30, 5 * 60, "Wait for free slot") - elif check == "notfound": - self.retry(30, 5 * 60, "404 Not found") + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] getInfo = create_getInfo(BayfilesCom) diff --git a/module/plugins/hoster/BezvadataCz.py b/module/plugins/hoster/BezvadataCz.py index 55f3f33b9..9ca4b4b1a 100644 --- a/module/plugins/hoster/BezvadataCz.py +++ b/module/plugins/hoster/BezvadataCz.py @@ -1,65 +1,55 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class BezvadataCz(SimpleHoster): - __name__ = "BezvadataCz" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?bezvadata.cz/stahnout/.*' - __version__ = "0.24" + __name__ = "BezvadataCz" + __type__ = "hoster" + __version__ = "0.25" + + __pattern__ = r'http://(?:www\.)?bezvadata\.cz/stahnout/.+' + __description__ = """BezvaData.cz hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + + NAME_PATTERN = r'<p><b>Soubor: (?P<N>[^<]+)</b></p>' + SIZE_PATTERN = r'<li><strong>Velikost:</strong> (?P<S>[^<]+)</li>' + OFFLINE_PATTERN = r'<title>BezvaData \| Soubor nenalezen</title>' - FILE_NAME_PATTERN = r'<p><b>Soubor: (?P<N>[^<]+)</b></p>' - FILE_SIZE_PATTERN = r'<li><strong>Velikost:</strong> (?P<S>[^<]+)</li>' - FILE_OFFLINE_PATTERN = r'<title>BezvaData \| Soubor nenalezen</title>' def setup(self): - self.multiDL = self.resumeDownload = True + self.resumeDownload = True + self.multiDL = True + def handleFree(self): #download button - found = re.search(r'<a class="stahnoutSoubor".*?href="(.*?)"', self.html) - if not found: - self.parseError("page1 URL") - url = "http://bezvadata.cz%s" % found.group(1) + m = re.search(r'<a class="stahnoutSoubor".*?href="(.*?)"', self.html) + if m is None: + self.error(_("Page 1 URL not found")) + url = "http://bezvadata.cz%s" % m.group(1) #captcha form self.html = self.load(url) self.checkErrors() - for _ in xrange(5): + for _i in xrange(5): action, inputs = self.parseHtmlForm('frm-stahnoutFreeForm') if not inputs: - self.parseError("FreeForm") + self.error(_("FreeForm")) - found = re.search(r'<img src="data:image/png;base64,(.*?)"', self.html) - if not found: - self.parseError("captcha img") + m = re.search(r'<img src="data:image/png;base64,(.*?)"', self.html) + if m is None: + self.error(_("Wrong captcha image")) #captcha image is contained in html page as base64encoded data but decryptCaptcha() expects image url self.load, proper_load = self.loadcaptcha, self.load try: - inputs['captcha'] = self.decryptCaptcha(found.group(1), imgtype='png') + inputs['captcha'] = self.decryptCaptcha(m.group(1), imgtype='png') finally: self.load = proper_load @@ -69,30 +59,34 @@ class BezvadataCz(SimpleHoster): self.correctCaptcha() break else: - self.fail("No valid captcha code entered") + self.fail(_("No valid captcha code entered")) #download url self.html = self.load("http://bezvadata.cz%s" % action, post=inputs) self.checkErrors() - found = re.search(r'<a class="stahnoutSoubor2" href="(.*?)">', self.html) - if not found: - self.parseError("page2 URL") - url = "http://bezvadata.cz%s" % found.group(1) + m = re.search(r'<a class="stahnoutSoubor2" href="(.*?)">', self.html) + if m is None: + self.error(_("Page 2 URL not found")) + url = "http://bezvadata.cz%s" % m.group(1) self.logDebug("DL URL %s" % url) #countdown - found = re.search(r'id="countdown">(\d\d):(\d\d)<', self.html) - wait_time = (int(found.group(1)) * 60 + int(found.group(2)) + 1) if found else 120 + m = re.search(r'id="countdown">(\d\d):(\d\d)<', self.html) + wait_time = (int(m.group(1)) * 60 + int(m.group(2))) if m else 120 self.wait(wait_time, False) self.download(url) + def checkErrors(self): if 'images/button-download-disable.png' in self.html: - self.longWait(5 * 60, 24) # parallel dl limit + self.longWait(5 * 60, 24) #: parallel dl limit elif '<div class="infobox' in self.html: self.tempOffline() + self.info.pop('error', None) + + def loadcaptcha(self, data, *args, **kwargs): return data.decode("base64") diff --git a/module/plugins/hoster/BillionuploadsCom.py b/module/plugins/hoster/BillionuploadsCom.py index ab2634c91..b20ace0f1 100644 --- a/module/plugins/hoster/BillionuploadsCom.py +++ b/module/plugins/hoster/BillionuploadsCom.py @@ -1,21 +1,24 @@ # -*- coding: utf-8 -*- -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo -class BillionuploadsCom(XFileSharingPro): - __name__ = "BillionuploadsCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?billionuploads.com/\w{12}' - __version__ = "0.01" +class BillionuploadsCom(XFSHoster): + __name__ = "BillionuploadsCom" + __type__ = "hoster" + __version__ = "0.04" + + __pattern__ = r'http://(?:www\.)?billionuploads\.com/\w{12}' + __description__ = """Billionuploads.com hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + - HOSTER_NAME = "billionuploads.com" + HOSTER_DOMAIN = "billionuploads.com" - FILE_NAME_PATTERN = r'<b>Filename:</b>(?P<N>.*?)<br>' - FILE_SIZE_PATTERN = r'<b>Size:</b>(?P<S>.*?)<br>' + NAME_PATTERN = r'<td class="dofir" title="(?P<N>.+?)"' + SIZE_PATTERN = r'<td class="dofir">(?P<S>[\d.,]+) (?P<U>[\w^_]+)' getInfo = create_getInfo(BillionuploadsCom) diff --git a/module/plugins/hoster/BitshareCom.py b/module/plugins/hoster/BitshareCom.py index d4b0668c0..1c5c53f55 100644 --- a/module/plugins/hoster/BitshareCom.py +++ b/module/plugins/hoster/BitshareCom.py @@ -4,71 +4,83 @@ from __future__ import with_statement import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class BitshareCom(SimpleHoster): - __name__ = "BitshareCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?bitshare\.com/(files/(?P<id1>[a-zA-Z0-9]+)(/(?P<name>.*?)\.html)?|\?f=(?P<id2>[a-zA-Z0-9]+))' - __version__ = "0.49" + __name__ = "BitshareCom" + __type__ = "hoster" + __version__ = "0.51" + + __pattern__ = r'http://(?:www\.)?bitshare\.com/(files/)?(?(1)|\?f=)(?P<ID>\w+)(?(1)/(?P<NAME>.+?)\.html)' + __description__ = """Bitshare.com hoster plugin""" - __author_name__ = ("Paul King", "fragonib") - __author_mail__ = ("", "fragonib[AT]yahoo[DOT]es") + __license__ = "GPLv3" + __authors__ = [("Paul King", None), + ("fragonib", "fragonib[AT]yahoo[DOT]es")] + + + COOKIES = [("bitshare.com", "language_selection", "EN")] + + INFO_PATTERN = r'Downloading (?P<N>.+) - (?P<S>[\d.,]+) (?P<U>[\w^_]+)</h1>' + OFFLINE_PATTERN = r'[Ff]ile (not available|was deleted|was not found)' + + AJAXID_PATTERN = r'var ajaxdl = "(.*?)";' + TRAFFIC_USED_UP = r'Your Traffic is used up for today' - HOSTER_DOMAIN = "bitshare.com" - FILE_OFFLINE_PATTERN = r'(>We are sorry, but the requested file was not found in our database|>Error - File not available<|The file was deleted either by the uploader, inactivity or due to copyright claim)' - FILE_INFO_PATTERN = r'Downloading (?P<N>.+) - (?P<S>[\d.]+) (?P<U>\w+)</h1>' - FILE_AJAXID_PATTERN = r'var ajaxdl = "(.*?)";' - CAPTCHA_KEY_PATTERN = r"http://api\.recaptcha\.net/challenge\?k=(.*?) " - TRAFFIC_USED_UP = r"Your Traffic is used up for today. Upgrade to premium to continue!" def setup(self): - self.req.cj.setCookie(self.HOSTER_DOMAIN, "language_selection", "EN") - self.multiDL = self.premium + self.multiDL = self.premium self.chunkLimit = 1 + def process(self, pyfile): if self.premium: self.account.relogin(self.user) - self.pyfile = pyfile - # File id m = re.match(self.__pattern__, pyfile.url) - self.file_id = max(m.group('id1'), m.group('id2')) + self.file_id = max(m.group('ID1'), m.group('ID2')) self.logDebug("File id is [%s]" % self.file_id) # Load main page self.html = self.load(pyfile.url, ref=False, decode=True) # Check offline - if re.search(self.FILE_OFFLINE_PATTERN, self.html): + if re.search(self.OFFLINE_PATTERN, self.html): self.offline() # Check Traffic used up if re.search(self.TRAFFIC_USED_UP, self.html): - self.logInfo("Your Traffic is used up for today. Wait 1800 seconds or reconnect!") - self.logDebug("Waiting %d seconds." % 1800) + self.logInfo(_("Your Traffic is used up for today")) self.wait(30 * 60, True) self.retry() # File name - m = re.match(self.__pattern__, pyfile.url) - name1 = m.group('name') if m else None - m = re.search(self.FILE_INFO_PATTERN, self.html) + m = re.match(self.__pattern__, pyfile.url) + name1 = m.group('NAME') if m else None + + m = re.search(self.INFO_PATTERN, self.html) name2 = m.group('N') if m else None + pyfile.name = max(name1, name2) # Ajax file id - self.ajaxid = re.search(self.FILE_AJAXID_PATTERN, self.html).group(1) + self.ajaxid = re.search(self.AJAXID_PATTERN, self.html).group(1) self.logDebug("File ajax id is [%s]" % self.ajaxid) # This may either download our file or forward us to an error page - url = self.getDownloadUrl() - self.logDebug("Downloading file with url [%s]" % url) - self.download(url) + self.download(self.getDownloadUrl()) + + check = self.checkDownload({"404": ">404 Not Found<", "Error": ">Error occured<"}) + + if check == "404": + self.retry(3, 60, 'Error 404') + + elif check == "error": + self.retry(5, 5 * 60, "Bitshare host : Error occured") + def getDownloadUrl(self): # Return location if direct download is active @@ -79,13 +91,16 @@ class BitshareCom(SimpleHoster): # Get download info self.logDebug("Getting download info") - response = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html", - post={"request": "generateID", "ajaxid": self.ajaxid}) - self.handleErrors(response, ':') - parts = response.split(":") + res = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html", + post={"request": "generateID", "ajaxid": self.ajaxid}) + + self.handleErrors(res, ':') + + parts = res.split(":") filetype = parts[0] - wait = int(parts[1]) - captcha = int(parts[2]) + wait = int(parts[1]) + captcha = int(parts[2]) + self.logDebug("Download info [type: '%s', waiting: %d, captcha: %d]" % (filetype, wait, captcha)) # Waiting @@ -100,43 +115,48 @@ class BitshareCom(SimpleHoster): # Resolve captcha if captcha == 1: self.logDebug("File is captcha protected") - id = re.search(self.CAPTCHA_KEY_PATTERN, self.html).group(1) + recaptcha = ReCaptcha(self) + # Try up to 3 times for i in xrange(3): - self.logDebug("Resolving ReCaptcha with key [%s], round %d" % (id, i + 1)) - recaptcha = ReCaptcha(self) - challenge, code = recaptcha.challenge(id) - response = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html", - post={"request": "validateCaptcha", "ajaxid": self.ajaxid, - "recaptcha_challenge_field": challenge, "recaptcha_response_field": code}) - if self.handleCaptchaErrors(response): + challenge, response = recaptcha.challenge() + res = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html", + post={"request" : "validateCaptcha", + "ajaxid" : self.ajaxid, + "recaptcha_challenge_field": challenge, + "recaptcha_response_field" : response}) + if self.handleCaptchaErrors(res): break # Get download URL self.logDebug("Getting download url") - response = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html", - post={"request": "getDownloadURL", "ajaxid": self.ajaxid}) - self.handleErrors(response, '#') - url = response.split("#")[-1] + res = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html", + post={"request": "getDownloadURL", "ajaxid": self.ajaxid}) + + self.handleErrors(res, '#') + + url = res.split("#")[-1] return url - def handleErrors(self, response, separator): - self.logDebug("Checking response [%s]" % response) - if "ERROR:Session timed out" in response: + + def handleErrors(self, res, separator): + self.logDebug("Checking response [%s]" % res) + if "ERROR:Session timed out" in res: self.retry() - elif "ERROR" in response: - msg = response.split(separator)[-1] + elif "ERROR" in res: + msg = res.split(separator)[-1] self.fail(msg) - def handleCaptchaErrors(self, response): - self.logDebug("Result of captcha resolving [%s]" % response) - if "SUCCESS" in response: + + def handleCaptchaErrors(self, res): + self.logDebug("Result of captcha resolving [%s]" % res) + if "SUCCESS" in res: self.correctCaptcha() return True - elif "ERROR:SESSION ERROR" in response: + elif "ERROR:SESSION ERROR" in res: self.retry() - self.logDebug("Wrong captcha") + self.invalidCaptcha() diff --git a/module/plugins/hoster/BoltsharingCom.py b/module/plugins/hoster/BoltsharingCom.py index a1672dc22..924545a29 100644 --- a/module/plugins/hoster/BoltsharingCom.py +++ b/module/plugins/hoster/BoltsharingCom.py @@ -4,13 +4,15 @@ from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo class BoltsharingCom(DeadHoster): - __name__ = "BoltsharingCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?boltsharing.com/\w{12}' + __name__ = "BoltsharingCom" + __type__ = "hoster" __version__ = "0.02" + + __pattern__ = r'http://(?:www\.)?boltsharing\.com/\w{12}' + __description__ = """Boltsharing.com hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] getInfo = create_getInfo(BoltsharingCom) diff --git a/module/plugins/hoster/CatShareNet.py b/module/plugins/hoster/CatShareNet.py index efaf8e5f7..949a021dd 100644 --- a/module/plugins/hoster/CatShareNet.py +++ b/module/plugins/hoster/CatShareNet.py @@ -1,38 +1,67 @@ # -*- coding: utf-8 -*- import re + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo from module.plugins.internal.CaptchaService import ReCaptcha class CatShareNet(SimpleHoster): - __name__ = "CatShareNet" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?catshare.net/\w{16}.*' - __version__ = "0.01" + __name__ = "CatShareNet" + __type__ = "hoster" + __version__ = "0.08" + + __pattern__ = r'http://(?:www\.)?catshare\.net/\w{16}' + __description__ = """CatShare.net hoster plugin""" - __author_name__ = "z00nx" - __author_mail__ = "z00nx0@gmail.com" + __license__ = "GPLv3" + __authors__ = [("z00nx", "z00nx0@gmail.com"), + ("prOq", None), + ("Walter Purcaro", "vuolter@gmail.com")] + + + TEXT_ENCODING = True + + INFO_PATTERN = r'<title>(?P<N>.+) \((?P<S>[\d.,]+) (?P<U>[\w^_]+)\)<' + OFFLINE_PATTERN = ur'Podany plik został usunięty\s*</div>' + + IP_BLOCKED_PATTERN = ur'>Nasz serwis wykrył że Twój adres IP nie pochodzi z Polski.<' + SECONDS_PATTERN = 'var\scount\s=\s(\d+);' + LINK_PATTERN = r'<form action="(.+?)" method="GET">' + + + def setup(self): + self.multiDL = self.premium + self.resumeDownload = True + + + def getFileInfo(self): + m = re.search(self.IP_BLOCKED_PATTERN, self.html) + if m: + self.fail(_("Only connections from Polish IP address are allowed")) + return super(CatShareNet, self).getFileInfo() - FILE_INFO_PATTERN = r'<h3 class="pull-left"[^>]+>(?P<N>.*)</h3>\s+<h3 class="pull-right"[^>]+>(?P<S>.*)</h3>' - FILE_OFFLINE_PATTERN = r'Podany plik zosta' - SECONDS_PATTERN = 'var\s+count\s+=\s+(\d+);' - RECAPTCHA_KEY = "6Lfln9kSAAAAANZ9JtHSOgxUPB9qfDFeLUI_QMEy" def handleFree(self): - found = re.search(self.SECONDS_PATTERN, self.html) - seconds = int(found.group(1)) - self.logDebug("Seconds found", seconds) - self.wait(seconds + 1) + m = re.search(self.SECONDS_PATTERN, self.html) + if m: + wait_time = int(m.group(1)) + self.wait(wait_time, True) + recaptcha = ReCaptcha(self) - challenge, code = recaptcha.challenge(self.RECAPTCHA_KEY) - post_data = {"recaptcha_challenge_field": challenge, "recaptcha_response_field": code} - self.download(self.pyfile.url, post=post_data) - check = self.checkDownload({"html": re.compile("\A<!DOCTYPE html PUBLIC")}) - if check == "html": - self.logDebug("Wrong captcha entered") + + challenge, response = recaptcha.challenge() + self.html = self.load(self.pyfile.url, + post={'recaptcha_challenge_field': challenge, + 'recaptcha_response_field' : response}) + + m = re.search(self.LINK_PATTERN, self.html) + if m is None: self.invalidCaptcha() - self.retry() + self.retry(reason=_("Wrong captcha entered")) + + dl_link = m.group(1) + self.download(dl_link, disposition=True) getInfo = create_getInfo(CatShareNet) diff --git a/module/plugins/hoster/CloudzerNet.py b/module/plugins/hoster/CloudzerNet.py index 6e47ce53f..c5440391f 100644 --- a/module/plugins/hoster/CloudzerNet.py +++ b/module/plugins/hoster/CloudzerNet.py @@ -4,13 +4,17 @@ from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo class CloudzerNet(DeadHoster): - __name__ = "CloudzerNet" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?(cloudzer\.net/file/|clz\.to/(file/)?)\w+' + __name__ = "CloudzerNet" + __type__ = "hoster" __version__ = "0.05" + + __pattern__ = r'https?://(?:www\.)?(cloudzer\.net/file/|clz\.to/(file/)?)\w+' + __description__ = """Cloudzer.net hoster plugin""" - __author_name__ = ("gs", "z00nx", "stickell") - __author_mail__ = ("I-_-I-_-I@web.de", "z00nx0@gmail.com", "l.stickell@yahoo.it") + __license__ = "GPLv3" + __authors__ = [("gs", "I-_-I-_-I@web.de"), + ("z00nx", "z00nx0@gmail.com"), + ("stickell", "l.stickell@yahoo.it")] getInfo = create_getInfo(CloudzerNet) diff --git a/module/plugins/hoster/CloudzillaTo.py b/module/plugins/hoster/CloudzillaTo.py new file mode 100644 index 000000000..d8b5e8b5d --- /dev/null +++ b/module/plugins/hoster/CloudzillaTo.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + + +class CloudzillaTo(SimpleHoster): + __name__ = "CloudzillaTo" + __type__ = "hoster" + __version__ = "0.05" + + __pattern__ = r'http://(?:www\.)?cloudzilla\.to/share/file/(?P<ID>[\w^_]+)' + + __description__ = """Cloudzilla.to hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + INFO_PATTERN = r'title="(?P<N>.+?)">\1</span> <span class="size">\((?P<S>[\d.]+) (?P<U>[\w^_]+)' + OFFLINE_PATTERN = r'>File not found...<' + + PASSWORD_PATTERN = r'<div id="pwd_protected">' + + + def checkErrors(self): + m = re.search(self.PASSWORD_PATTERN, self.html) + if m: + self.html = self.load(self.pyfile.url, get={'key': self.getPassword()}) + + if re.search(self.PASSWORD_PATTERN, self.html): + self.retry(reason="Wrong password") + + + def handleFree(self): + self.html = self.load("http://www.cloudzilla.to/generateticket/", + post={'file_id': self.info['pattern']['ID'], 'key': self.getPassword()}) + + ticket = dict(re.findall(r'<(.+?)>([^<>]+?)</', self.html)) + + self.logDebug(ticket) + + if 'error' in ticket: + if "File is password protected" in ticket['error']: + self.retry(reason="Wrong password") + else: + self.fail(ticket['error']) + + if 'wait' in ticket: + self.wait(int(ticket['wait']), int(ticket['wait']) > 5) + + self.link = "http://%(server)s/download/%(file_id)s/%(ticket_id)s" % {'server' : ticket['server'], + 'file_id' : self.info['pattern']['ID'], + 'ticket_id': ticket['ticket_id']} + + + def handlePremium(self): + return self.handleFree() + + +getInfo = create_getInfo(CloudzillaTo) diff --git a/module/plugins/hoster/CramitIn.py b/module/plugins/hoster/CramitIn.py index e882f5cea..f444718bc 100644 --- a/module/plugins/hoster/CramitIn.py +++ b/module/plugins/hoster/CramitIn.py @@ -1,24 +1,25 @@ # -*- coding: utf-8 -*- -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo -class CramitIn(XFileSharingPro): - __name__ = "CramitIn" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?cramit.in/\w{12}' - __version__ = "0.04" +class CramitIn(XFSHoster): + __name__ = "CramitIn" + __type__ = "hoster" + __version__ = "0.07" + + __pattern__ = r'http://(?:www\.)?cramit\.in/\w{12}' + __description__ = """Cramit.in hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + - HOSTER_NAME = "cramit.in" + HOSTER_DOMAIN = "cramit.in" - FILE_INFO_PATTERN = r'<span class=t2>\s*(?P<N>.*?)</span>.*?<small>\s*\((?P<S>.*?)\)' - DIRECT_LINK_PATTERN = r'href="(http://cramit.in/file_download/.*?)"' + INFO_PATTERN = r'<span class=t2>\s*(?P<N>.*?)</span>.*?<small>\s*\((?P<S>.*?)\)' - def setup(self): - self.resumeDownload = self.multiDL = self.premium + LINK_PATTERN = r'href="(http://cramit\.in/file_download/.*?)"' getInfo = create_getInfo(CramitIn) diff --git a/module/plugins/hoster/CrockoCom.py b/module/plugins/hoster/CrockoCom.py index 3cd2be59d..e5f94800b 100644 --- a/module/plugins/hoster/CrockoCom.py +++ b/module/plugins/hoster/CrockoCom.py @@ -2,63 +2,61 @@ import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class CrockoCom(SimpleHoster): - __name__ = "CrockoCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?(crocko|easy-share).com/\w+' - __version__ = "0.16" + __name__ = "CrockoCom" + __type__ = "hoster" + __version__ = "0.17" + + __pattern__ = r'http://(?:www\.)?(crocko|easy-share)\.com/\w+' + __description__ = """Crocko hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - FILE_NAME_PATTERN = r'<span class="fz24">Download:\s*<strong>(?P<N>.*)' - FILE_SIZE_PATTERN = r'<span class="tip1"><span class="inner">(?P<S>[^<]+)</span></span>' - FILE_OFFLINE_PATTERN = r"<h1>Sorry,<br />the page you're looking for <br />isn't here.</h1>|File not found" - DOWNLOAD_URL_PATTERN = r"window.location ='([^']+)';" - CAPTCHA_URL_PATTERN = re.compile(r"u='(/file_contents/captcha/\w+)';\s*w='(\d+)';") - CAPTCHA_KEY_PATTERN = re.compile(r'Recaptcha.create\("([^"]+)"') + + NAME_PATTERN = r'<span class="fz24">Download:\s*<strong>(?P<N>.*)' + SIZE_PATTERN = r'<span class="tip1"><span class="inner">(?P<S>[^<]+)</span></span>' + OFFLINE_PATTERN = r'<h1>Sorry,<br />the page you\'re looking for <br />isn\'t here.</h1>|File not found' + + CAPTCHA_PATTERN = re.compile(r"u='(/file_contents/captcha/\w+)';\s*w='(\d+)';") FORM_PATTERN = r'<form method="post" action="([^"]+)">(.*?)</form>' FORM_INPUT_PATTERN = r'<input[^>]* name="?([^" ]+)"? value="?([^" ]+)"?[^>]*>' - FILE_NAME_REPLACEMENTS = [(r'<[^>]*>', '')] + NAME_REPLACEMENTS = [(r'<[^>]*>', '')] + def handleFree(self): if "You need Premium membership to download this file." in self.html: - self.fail("You need Premium membership to download this file.") + self.fail(_("You need Premium membership to download this file")) - for _ in xrange(5): - found = re.search(self.CAPTCHA_URL_PATTERN, self.html) - if found: - url, wait_time = 'http://crocko.com' + found.group(1), found.group(2) + for _i in xrange(5): + m = re.search(self.CAPTCHA_PATTERN, self.html) + if m: + url, wait_time = 'http://crocko.com' + m.group(1), int(m.group(2)) self.wait(wait_time) self.html = self.load(url) else: break - found = re.search(self.CAPTCHA_KEY_PATTERN, self.html) - if not found: - self.parseError('Captcha KEY') - captcha_key = found.group(1) + m = re.search(self.FORM_PATTERN, self.html, re.S) + if m is None: + self.error(_("FORM_PATTERN not found")) - found = re.search(self.FORM_PATTERN, self.html, re.DOTALL) - if not found: - self.parseError('ACTION') - action, form = found.groups() + action, form = m.groups() inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form)) - recaptcha = ReCaptcha(self) - for _ in xrange(5): - inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge(captcha_key) + for _i in xrange(5): + inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge() self.download(action, post=inputs) check = self.checkDownload({ - "captcha_err": self.CAPTCHA_KEY_PATTERN + "captcha_err": recaptcha.KEY_AJAX_PATTERN }) if check == "captcha_err": @@ -66,7 +64,7 @@ class CrockoCom(SimpleHoster): else: break else: - self.fail('No valid captcha solution received') + self.fail(_("No valid captcha solution received")) getInfo = create_getInfo(CrockoCom) diff --git a/module/plugins/hoster/CyberlockerCh.py b/module/plugins/hoster/CyberlockerCh.py index a08bf8518..b26909096 100644 --- a/module/plugins/hoster/CyberlockerCh.py +++ b/module/plugins/hoster/CyberlockerCh.py @@ -4,13 +4,15 @@ from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo class CyberlockerCh(DeadHoster): - __name__ = "CyberlockerCh" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?cyberlocker\.ch/\w+' + __name__ = "CyberlockerCh" + __type__ = "hoster" __version__ = "0.02" + + __pattern__ = r'http://(?:www\.)?cyberlocker\.ch/\w+' + __description__ = """Cyberlocker.ch hoster plugin""" - __author_name__ = "stickell" - __author_mail__ = "l.stickell@yahoo.it" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it")] getInfo = create_getInfo(CyberlockerCh) diff --git a/module/plugins/hoster/CzshareCom.py b/module/plugins/hoster/CzshareCom.py index a462deaff..aa381d712 100644 --- a/module/plugins/hoster/CzshareCom.py +++ b/module/plugins/hoster/CzshareCom.py @@ -1,97 +1,88 @@ # -*- coding: utf-8 -*- - -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - -# Test links (random.bin): +# +# Test links: # http://czshare.com/5278880/random.bin import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, PluginParseError + +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo from module.utils import parseFileSize class CzshareCom(SimpleHoster): - __name__ = "CzshareCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?(czshare|sdilej)\.(com|cz)/(\d+/|download.php\?).*' - __version__ = "0.94" + __name__ = "CzshareCom" + __type__ = "hoster" + __version__ = "0.96" + + __pattern__ = r'http://(?:www\.)?(czshare|sdilej)\.(com|cz)/(\d+/|download\.php\?).+' + __description__ = """CZshare.com hoster plugin, now Sdilej.cz""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - FILE_NAME_PATTERN = r'<div class="tab" id="parameters">\s*<p>\s*Cel. n.zev: <a href=[^>]*>(?P<N>[^<]+)</a>' - FILE_SIZE_PATTERN = r'<div class="tab" id="category">(?:\s*<p>[^\n]*</p>)*\s*Velikost:\s*(?P<S>[0-9., ]+)(?P<U>[kKMG])i?B\s*</div>' - FILE_OFFLINE_PATTERN = r'<div class="header clearfix">\s*<h2 class="red">' - FILE_SIZE_REPLACEMENTS = [(' ', '')] - FILE_URL_REPLACEMENTS = [(r'http://[^/]*/download.php\?.*?id=(\w+).*', r'http://sdilej.cz/\1/x/')] - SH_CHECK_TRAFFIC = True + NAME_PATTERN = r'<div class="tab" id="parameters">\s*<p>\s*Cel. n.zev: <a href=[^>]*>(?P<N>[^<]+)</a>' + SIZE_PATTERN = r'<div class="tab" id="category">(?:\s*<p>[^\n]*</p>)*\s*Velikost:\s*(?P<S>[\d .,]+)(?P<U>[\w^_]+)\s*</div>' + OFFLINE_PATTERN = r'<div class="header clearfix">\s*<h2 class="red">' + + SIZE_REPLACEMENTS = [(' ', '')] + URL_REPLACEMENTS = [(r'http://[^/]*/download.php\?.*?id=(\w+).*', r'http://sdilej.cz/\1/x/')] + + CHECK_TRAFFIC = True + + FREE_URL_PATTERN = r'<a href="([^"]+)" class="page-download">[^>]*alt="([^"]+)" /></a>' + FREE_FORM_PATTERN = r'<form action="download\.php" method="post">\s*<img src="captcha\.php" id="captcha" />(.*?)</form>' + PREMIUM_FORM_PATTERN = r'<form action="/profi_down\.php" method="post">(.*?)</form>' + FORM_INPUT_PATTERN = r'<input[^>]* name="([^"]+)" value="([^"]+)"[^>]*/>' + MULTIDL_PATTERN = r'<p><font color=\'red\'>Z[^<]*PROFI.</font></p>' + USER_CREDIT_PATTERN = r'<div class="credit">\s*kredit: <strong>([\d .,]+)(\w+)</strong>\s*</div><!-- .credit -->' - FREE_URL_PATTERN = r'<a href="([^"]+)" class="page-download">[^>]*alt="([^"]+)" /></a>' - FREE_FORM_PATTERN = r'<form action="download.php" method="post">\s*<img src="captcha.php" id="captcha" />(.*?)</form>' - PREMIUM_FORM_PATTERN = r'<form action="/profi_down.php" method="post">(.*?)</form>' - FORM_INPUT_PATTERN = r'<input[^>]* name="([^"]+)" value="([^"]+)"[^>]*/>' - MULTIDL_PATTERN = r"<p><font color='red'>Z[^<]*PROFI.</font></p>" - USER_CREDIT_PATTERN = r'<div class="credit">\s*kredit: <strong>([0-9., ]+)([kKMG]i?B)</strong>\s*</div><!-- .credit -->' def checkTrafficLeft(self): # check if user logged in - found = re.search(self.USER_CREDIT_PATTERN, self.html) - if not found: + m = re.search(self.USER_CREDIT_PATTERN, self.html) + if m is None: self.account.relogin(self.user) self.html = self.load(self.pyfile.url, cookies=True, decode=True) - found = re.search(self.USER_CREDIT_PATTERN, self.html) - if not found: + m = re.search(self.USER_CREDIT_PATTERN, self.html) + if m is None: return False # check user credit try: - credit = parseFileSize(found.group(1).replace(' ', ''), found.group(2)) - self.logInfo("Premium download for %i KiB of Credit" % (self.pyfile.size / 1024)) - self.logInfo("User %s has %i KiB left" % (self.user, credit / 1024)) + credit = parseFileSize(m.group(1).replace(' ', ''), m.group(2)) + self.logInfo(_("Premium download for %i KiB of Credit") % (self.pyfile.size / 1024)) + self.logInfo(_("User %s has %i KiB left") % (self.user, credit / 1024)) if credit < self.pyfile.size: - self.logInfo("Not enough credit to download file %s" % self.pyfile.name) + self.logInfo(_("Not enough credit to download file: %s") % self.pyfile.name) return False except Exception, e: # let's continue and see what happens... - self.logError('Parse error (CREDIT): %s' % e) + self.logError(e) return True + def handlePremium(self): # parse download link try: - form = re.search(self.PREMIUM_FORM_PATTERN, self.html, re.DOTALL).group(1) + form = re.search(self.PREMIUM_FORM_PATTERN, self.html, re.S).group(1) inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form)) except Exception, e: - self.logError("Parse error (FORM): %s" % e) + self.logError(e) self.resetAccount() # download the file, destination is determined by pyLoad self.download("http://sdilej.cz/profi_down.php", post=inputs, disposition=True) self.checkDownloadedFile() + def handleFree(self): # get free url - found = re.search(self.FREE_URL_PATTERN, self.html) - if found is None: - raise PluginParseError('Free URL') - parsed_url = "http://sdilej.cz" + found.group(1) + m = re.search(self.FREE_URL_PATTERN, self.html) + if m is None: + self.error(_("FREE_URL_PATTERN not found")) + parsed_url = "http://sdilej.cz" + m.group(1) self.logDebug("PARSED_URL:" + parsed_url) # get download ticket and parse html @@ -100,16 +91,16 @@ class CzshareCom(SimpleHoster): self.longWait(5 * 60, 12) try: - form = re.search(self.FREE_FORM_PATTERN, self.html, re.DOTALL).group(1) + form = re.search(self.FREE_FORM_PATTERN, self.html, re.S).group(1) inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form)) self.pyfile.size = int(inputs['size']) except Exception, e: self.logError(e) - raise PluginParseError('Form') + self.error(_("Form")) - # get and decrypt captcha + # get and decrypt captcha captcha_url = 'http://sdilej.cz/captcha.php' - for _ in xrange(5): + for _i in xrange(5): inputs['captchastring2'] = self.decryptCaptcha(captcha_url) self.html = self.load(parsed_url, cookies=True, post=inputs, decode=True) if u"<li>Zadaný ověřovací kód nesouhlasí!</li>" in self.html: @@ -120,34 +111,35 @@ class CzshareCom(SimpleHoster): self.correctCaptcha() break else: - self.fail("No valid captcha code entered") + self.fail(_("No valid captcha code entered")) - found = re.search("countdown_number = (\d+);", self.html) - self.setWait(int(found.group(1)) if found else 50) + m = re.search("countdown_number = (\d+);", self.html) + self.setWait(int(m.group(1)) if m else 50) # download the file, destination is determined by pyLoad self.logDebug("WAIT URL", self.req.lastEffectiveURL) - found = re.search("free_wait.php\?server=(.*?)&(.*)", self.req.lastEffectiveURL) - if not found: - raise PluginParseError('Download URL') + m = re.search("free_wait.php\?server=(.*?)&(.*)", self.req.lastEffectiveURL) + if m is None: + self.error(_("Download URL not found")) - url = "http://%s/download.php?%s" % (found.group(1), found.group(2)) + url = "http://%s/download.php?%s" % (m.group(1), m.group(2)) self.wait() self.download(url) self.checkDownloadedFile() + def checkDownloadedFile(self): # check download check = self.checkDownload({ - "tempoffline": re.compile(r"^Soubor je do.*asn.* nedostupn.*$"), + "temp_offline": re.compile(r"^Soubor je do.*asn.* nedostupn.*$"), "credit": re.compile(r"^Nem.*te dostate.*n.* kredit.$"), "multi_dl": re.compile(self.MULTIDL_PATTERN), "captcha_err": "<li>Zadaný ověřovací kód nesouhlasí!</li>" }) - if check == "tempoffline": - self.fail("File not available - try later") + if check == "temp_offline": + self.fail(_("File not available - try later")) if check == "credit": self.resetAccount() elif check == "multi_dl": diff --git a/module/plugins/hoster/DailymotionCom.py b/module/plugins/hoster/DailymotionCom.py index 17e1ecf92..dc42d1f60 100644 --- a/module/plugins/hoster/DailymotionCom.py +++ b/module/plugins/hoster/DailymotionCom.py @@ -1,49 +1,30 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -# @author: Walter Purcaro -############################################################################ - import re +from module.PyFile import statusMap from module.common.json_layer import json_loads from module.network.RequestFactory import getURL from module.plugins.Hoster import Hoster -from module.PyFile import statusMap def getInfo(urls): - result = [] #: [ .. (name, size, status, url) .. ] - regex = re.compile(DailymotionCom.__pattern__) - apiurl = "https://api.dailymotion.com/video/" + result = [] + regex = re.compile(DailymotionCom.__pattern__) + apiurl = "https://api.dailymotion.com/video/%s" request = {"fields": "access_error,status,title"} + for url in urls: - id = regex.search(url).group("ID") - page = getURL(apiurl + id, get=request) + id = regex.match(url).group('ID') + page = getURL(apiurl % id, get=request) info = json_loads(page) - if "title" in info: - name = info["title"] + ".mp4" - else: - name = url + name = info['title'] + ".mp4" if "title" in info else url - if "error" in info or info["access_error"]: + if "error" in info or info['access_error']: status = "offline" else: - status = info["status"] + status = info['status'] if status in ("ready", "published"): status = "online" elif status in ("waiting", "processing"): @@ -52,43 +33,57 @@ def getInfo(urls): status = "offline" result.append((name, 0, statusMap[status], url)) + return result class DailymotionCom(Hoster): - __name__ = "DailymotionCom" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?dailymotion\.com/.*?video/(?P<ID>[\w^_]+)' - __version__ = "0.2" - __config__ = [("quality", "Lowest;LD 144p;LD 240p;SD 384p;HQ 480p;HD 720p;HD 1080p;Highest", "Quality", "HD 720p")] + __name__ = "DailymotionCom" + __type__ = "hoster" + __version__ = "0.20" + + __pattern__ = r'https?://(?:www\.)?dailymotion\.com/.*video/(?P<ID>[\w^_]+)' + __config__ = [("quality", "Lowest;LD 144p;LD 240p;SD 384p;HQ 480p;HD 720p;HD 1080p;Highest", "Quality", "Highest")] + __description__ = """Dailymotion.com hoster plugin""" - __author_name__ = "Walter Purcaro" - __author_mail__ = "vuolter@gmail.com" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + def setup(self): - self.resumeDownload = self.multiDL = True + self.resumeDownload = True + self.multiDL = True + def getStreams(self): streams = [] + for result in re.finditer(r"\"(?P<URL>http:\\/\\/www.dailymotion.com\\/cdn\\/H264-(?P<QF>.*?)\\.*?)\"", self.html): - url = result.group("URL") - qf = result.group("QF") - link = url.replace("\\", "") + url = result.group('URL') + qf = result.group('QF') + + link = url.replace("\\", "") quality = tuple(int(x) for x in qf.split("x")) + streams.append((quality, link)) + return sorted(streams, key=lambda x: x[0][::-1]) + def getQuality(self): q = self.getConfig("quality") + if q == "Lowest": quality = 0 elif q == "Highest": quality = -1 else: quality = int(q.rsplit(" ")[1][:-1]) + return quality + def getLink(self, streams, quality): if quality > 0: for x, s in reversed([item for item in enumerate(streams)]): @@ -102,24 +97,29 @@ class DailymotionCom(Hoster): idx = quality s = streams[idx] - self.logInfo("Download video quality %sx%s" % s[0]) + + self.logInfo(_("Download video quality %sx%s") % s[0]) + return s[1] + def checkInfo(self, pyfile): pyfile.name, pyfile.size, pyfile.status, pyfile.url = getInfo([pyfile.url])[0] + if pyfile.status == 1: self.offline() + elif pyfile.status == 6: self.tempOffline() + def process(self, pyfile): self.checkInfo(pyfile) - id = re.match(self.__pattern__, pyfile.url).group("ID") + id = re.match(self.__pattern__, pyfile.url).group('ID') self.html = self.load("http://www.dailymotion.com/embed/video/" + id, decode=True) streams = self.getStreams() quality = self.getQuality() - link = self.getLink(streams, quality) - self.download(link) + self.download(self.getLink(streams, quality)) diff --git a/module/plugins/hoster/DataHu.py b/module/plugins/hoster/DataHu.py index 0c872b419..437fea7cd 100644 --- a/module/plugins/hoster/DataHu.py +++ b/module/plugins/hoster/DataHu.py @@ -1,20 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################ - -# Test links (random.bin): +# +# Test links: # http://data.hu/get/6381232/random.bin import re @@ -23,30 +9,34 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class DataHu(SimpleHoster): - __name__ = "DataHu" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?data.hu/get/\w+' - __version__ = "0.01" + __name__ = "DataHu" + __type__ = "hoster" + __version__ = "0.02" + + __pattern__ = r'http://(?:www\.)?data\.hu/get/\w+' + __description__ = """Data.hu hoster plugin""" - __author_name__ = ("crash", "stickell") - __author_mail__ = "l.stickell@yahoo.it" + __license__ = "GPLv3" + __authors__ = [("crash", None), + ("stickell", "l.stickell@yahoo.it")] - FILE_INFO_PATTERN = ur'<title>(?P<N>.*) \((?P<S>[^)]+)\) let\xf6lt\xe9se</title>' - FILE_OFFLINE_PATTERN = ur'Az adott f\xe1jl nem l\xe9tezik' - DIRECT_LINK_PATTERN = r'<div class="download_box_button"><a href="([^"]+)">' - def handleFree(self): + INFO_PATTERN = ur'<title>(?P<N>.*) \((?P<S>[^)]+)\) let\xf6lt\xe9se</title>' + OFFLINE_PATTERN = ur'Az adott f\xe1jl nem l\xe9tezik' + LINK_PATTERN = r'<div class="download_box_button"><a href="([^"]+)">' + + + def setup(self): self.resumeDownload = True - self.html = self.load(self.pyfile.url, decode=True) + self.multiDL = self.premium + - m = re.search(self.DIRECT_LINK_PATTERN, self.html) - if m: - url = m.group(1) - self.logDebug('Direct link: ' + url) - else: - self.parseError('Unable to get direct link') + def handleFree(self): + m = re.search(self.LINK_PATTERN, self.html) + if m is None: + self.error(_("LINK_PATTERN not found")) - self.download(url, disposition=True) + self.download(m.group(1), disposition=True) getInfo = create_getInfo(DataHu) diff --git a/module/plugins/hoster/DataportCz.py b/module/plugins/hoster/DataportCz.py index 291dcaf55..8e74f5553 100644 --- a/module/plugins/hoster/DataportCz.py +++ b/module/plugins/hoster/DataportCz.py @@ -1,62 +1,48 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, PluginParseError +class DataportCz(SimpleHoster): + __name__ = "DataportCz" + __type__ = "hoster" + __version__ = "0.40" + __pattern__ = r'http://(?:www\.)?dataport\.cz/file/(.+)' -class DataportCz(SimpleHoster): - __name__ = "DataportCz" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?dataport.cz/file/(.*)' - __version__ = "0.37" __description__ = """Dataport.cz hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + - FILE_NAME_PATTERN = r'<span itemprop="name">(?P<N>[^<]+)</span>' - FILE_SIZE_PATTERN = r'<td class="fil">Velikost</td>\s*<td>(?P<S>[^<]+)</td>' - FILE_OFFLINE_PATTERN = r'<h2>Soubor nebyl nalezen</h2>' - FILE_URL_REPLACEMENTS = [(__pattern__, r'http://www.dataport.cz/file/\1')] + NAME_PATTERN = r'<span itemprop="name">(?P<N>[^<]+)</span>' + SIZE_PATTERN = r'<td class="fil">Velikost</td>\s*<td>(?P<S>[^<]+)</td>' + OFFLINE_PATTERN = r'<h2>Soubor nebyl nalezen</h2>' - CAPTCHA_URL_PATTERN = r'<section id="captcha_bg">\s*<img src="(.*?)"' + CAPTCHA_PATTERN = r'<section id="captcha_bg">\s*<img src="(.*?)"' FREE_SLOTS_PATTERN = ur'Počet volných slotů: <span class="darkblue">(\d+)</span><br />' + def handleFree(self): captchas = {"1": "jkeG", "2": "hMJQ", "3": "vmEK", "4": "ePQM", "5": "blBd"} - for _ in xrange(60): + for _i in xrange(60): action, inputs = self.parseHtmlForm('free_download_form') self.logDebug(action, inputs) if not action or not inputs: - raise PluginParseError('free_download_form') + self.error(_("free_download_form")) - if "captchaId" in inputs and inputs["captchaId"] in captchas: - inputs['captchaCode'] = captchas[inputs["captchaId"]] + if "captchaId" in inputs and inputs['captchaId'] in captchas: + inputs['captchaCode'] = captchas[inputs['captchaId']] else: - raise PluginParseError('captcha') + self.error(_("captcha")) self.html = self.download("http://www.dataport.cz%s" % action, post=inputs) check = self.checkDownload({"captcha": 'alert("\u0160patn\u011b opsan\u00fd k\u00f3d z obr\u00e1zu");', "slot": 'alert("Je n\u00e1m l\u00edto, ale moment\u00e1ln\u011b nejsou'}) if check == "captcha": - raise PluginParseError('invalid captcha') + self.error(_("invalid captcha")) elif check == "slot": self.logDebug("No free slots - wait 60s and retry") self.wait(60, False) @@ -66,4 +52,4 @@ class DataportCz(SimpleHoster): break -create_getInfo(DataportCz) +getInfo = create_getInfo(DataportCz) diff --git a/module/plugins/hoster/DateiTo.py b/module/plugins/hoster/DateiTo.py index 223138592..e4bff8458 100644 --- a/module/plugins/hoster/DateiTo.py +++ b/module/plugins/hoster/DateiTo.py @@ -1,52 +1,39 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class DateiTo(SimpleHoster): - __name__ = "DateiTo" - __type__ = "hoster" + __name__ = "DateiTo" + __type__ = "hoster" + __version__ = "0.05" + __pattern__ = r'http://(?:www\.)?datei\.to/datei/(?P<ID>\w+)\.html' - __version__ = "0.02" + __description__ = """Datei.to hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + - FILE_NAME_PATTERN = r'Dateiname:</td>\s*<td colspan="2"><strong>(?P<N>.*?)</' - FILE_SIZE_PATTERN = r'Dateigröße:</td>\s*<td colspan="2">(?P<S>.*?)</' - FILE_OFFLINE_PATTERN = r'>Datei wurde nicht gefunden<|>Bitte wähle deine Datei aus... <' - PARALELL_PATTERN = r'>Du lädst bereits eine Datei herunter<' + NAME_PATTERN = r'Dateiname:</td>\s*<td colspan="2"><strong>(?P<N>.*?)</' + SIZE_PATTERN = r'Dateigröße:</td>\s*<td colspan="2">(?P<S>.*?)</' + OFFLINE_PATTERN = r'>Datei wurde nicht gefunden<|>Bitte wähle deine Datei aus... <' + + WAIT_PATTERN = r'countdown\({seconds: (\d+)' + MULTIDL_PATTERN = r'>Du lädst bereits eine Datei herunter<' - WAIT_PATTERN = r'countdown\({seconds: (\d+)' DATA_PATTERN = r'url: "(.*?)", data: "(.*?)",' - RECAPTCHA_KEY_PATTERN = r'Recaptcha.create\("(.*?)"' + def handleFree(self): url = 'http://datei.to/ajax/download.php' - data = {'P': 'I', 'ID': self.file_info['ID']} - + data = {'P': 'I', 'ID': self.info['pattern']['ID']} recaptcha = ReCaptcha(self) - for _ in xrange(10): + for _i in xrange(10): self.logDebug("URL", url, "POST", data) self.html = self.load(url, post=data) self.checkErrors() @@ -58,39 +45,38 @@ class DateiTo(SimpleHoster): elif data['P'] == 'IV': break - found = re.search(self.DATA_PATTERN, self.html) - if not found: - self.parseError('data') - url = 'http://datei.to/' + found.group(1) - data = dict(x.split('=') for x in found.group(2).split('&')) + m = re.search(self.DATA_PATTERN, self.html) + if m is None: + self.error(_("data")) + url = 'http://datei.to/' + m.group(1) + data = dict(x.split('=') for x in m.group(2).split('&')) if url.endswith('recaptcha.php'): - found = re.search(self.RECAPTCHA_KEY_PATTERN, self.html) - recaptcha_key = found.group(1) if found else "6LdBbL8SAAAAAI0vKUo58XRwDd5Tu_Ze1DA7qTao" - - data['recaptcha_challenge_field'], data['recaptcha_response_field'] = recaptcha.challenge(recaptcha_key) - + data['recaptcha_challenge_field'], data['recaptcha_response_field'] = recaptcha.challenge() else: - self.fail('Too bad...') + self.fail(_("Too bad...")) + + self.download(self.html) - download_url = self.html - self.logDebug('Download URL', download_url) - self.download(download_url) def checkErrors(self): - found = re.search(self.PARALELL_PATTERN, self.html) - if found: - found = re.search(self.WAIT_PATTERN, self.html) - wait_time = int(found.group(1)) if found else 30 - self.wait(wait_time + 1, False) - self.retry() + m = re.search(self.MULTIDL_PATTERN, self.html) + if m: + m = re.search(self.WAIT_PATTERN, self.html) + wait_time = int(m.group(1)) if m else 30 + + errmsg = self.info['error'] = _("Parallel downloads") + self.retry(wait_time=wait_time, reason=errmsg) + + self.info.pop('error', None) + def doWait(self): - found = re.search(self.WAIT_PATTERN, self.html) - wait_time = int(found.group(1)) if found else 30 + m = re.search(self.WAIT_PATTERN, self.html) + wait_time = int(m.group(1)) if m else 30 self.load('http://datei.to/ajax/download.php', post={'P': 'Ads'}) - self.wait(wait_time + 1, False) + self.wait(wait_time, False) getInfo = create_getInfo(DateiTo) diff --git a/module/plugins/hoster/DdlstorageCom.py b/module/plugins/hoster/DdlstorageCom.py index eed53b1e1..a45ef27e9 100644 --- a/module/plugins/hoster/DdlstorageCom.py +++ b/module/plugins/hoster/DdlstorageCom.py @@ -1,89 +1,19 @@ # -*- coding: utf-8 -*- -import re -from hashlib import md5 +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo -from module.plugins.hoster.XFileSharingPro import XFileSharingPro -from module.network.RequestFactory import getURL -from module.plugins.Plugin import chunks -from module.common.json_layer import json_loads +class DdlstorageCom(DeadHoster): + __name__ = "DdlstorageCom" + __type__ = "hoster" + __version__ = "1.02" -def getInfo(urls): - # DDLStorage API Documentation: - # http://www.ddlstorage.com/cgi-bin/api_req.cgi?req_type=doc - ids = dict() - for url in urls: - m = re.search(DdlstorageCom.__pattern__, url) - ids[m.group('ID')] = url + __pattern__ = r'https?://(?:www\.)?ddlstorage\.com/\w+' - for chunk in chunks(ids.keys(), 5): - for _ in xrange(5): - api = getURL('http://www.ddlstorage.com/cgi-bin/api_req.cgi', - post={'req_type': 'file_info_free', - 'client_id': 53472, - 'file_code': ','.join(chunk), - 'sign': md5('file_info_free%d%s%s' % (53472, ','.join(chunk), - '25JcpU2dPOKg8E2OEoRqMSRu068r0Cv3')).hexdigest()}) - api = api.replace('<pre>', '').replace('</pre>', '') - api = json_loads(api) - if 'error' not in api: - break - - result = list() - for el in api: - if el['status'] == 'online': - result.append((el['file_name'], int(el['file_size']), 2, ids[el['file_code']])) - else: - result.append((ids[el['file_code']], 0, 1, ids[el['file_code']])) - yield result - - -class DdlstorageCom(XFileSharingPro): - __name__ = "DdlstorageCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?ddlstorage.com/(?P<ID>\w{12})' - __version__ = "1.01" __description__ = """DDLStorage.com hoster plugin""" - __author_name__ = ("zoidberg", "stickell") - __author_mail__ = ("zoidberg@mujmail.cz", "l.stickell@yahoo.it") - - HOSTER_NAME = "ddlstorage.com" - - FILE_INFO_PATTERN = r'<p class="sub_title"[^>]*>(?P<N>.+) \((?P<S>[^)]+)\)</p>' - - def prepare(self): - self.getAPIData() - super(DdlstorageCom, self).prepare() - - def getAPIData(self): - file_id = re.match(self.__pattern__, self.pyfile.url).group('ID') - data = {'client_id': 53472, - 'file_code': file_id} - if self.user: - passwd = self.account.getAccountData(self.user)["password"] - data['req_type'] = 'file_info_reg' - data['user_login'] = self.user - data['user_password'] = md5(passwd).hexdigest() - data['sign'] = md5('file_info_reg%d%s%s%s%s' % (data['client_id'], data['user_login'], - data['user_password'], data['file_code'], - '25JcpU2dPOKg8E2OEoRqMSRu068r0Cv3')).hexdigest() - else: - data['req_type'] = 'file_info_free' - data['sign'] = md5('file_info_free%d%s%s' % (data['client_id'], data['file_code'], - '25JcpU2dPOKg8E2OEoRqMSRu068r0Cv3')).hexdigest() - - self.api_data = self.load('http://www.ddlstorage.com/cgi-bin/api_req.cgi', post=data) - self.api_data = self.api_data.replace('<pre>', '').replace('</pre>', '') - self.logDebug('API Data: ' + self.api_data) - self.api_data = json_loads(self.api_data)[0] + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it")] - if self.api_data['status'] == 'offline': - self.offline() - if 'file_name' in self.api_data: - self.pyfile.name = self.api_data['file_name'] - if 'file_size' in self.api_data: - self.pyfile.size = self.api_data['size'] = self.api_data['file_size'] - if 'file_md5_base64' in self.api_data: - self.api_data['md5_ddlstorage'] = self.api_data['file_md5_base64'] +getInfo = create_getInfo(DdlstorageCom) diff --git a/module/plugins/hoster/DebridItaliaCom.py b/module/plugins/hoster/DebridItaliaCom.py index a8b4248b4..842e3cd63 100644 --- a/module/plugins/hoster/DebridItaliaCom.py +++ b/module/plugins/hoster/DebridItaliaCom.py @@ -1,60 +1,48 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################ import re -from module.plugins.Hoster import Hoster +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -class DebridItaliaCom(Hoster): - __name__ = "DebridItaliaCom" - __version__ = "0.05" - __type__ = "hoster" - __pattern__ = r'https?://(?:[^/]*\.)?debriditalia\.com' +class DebridItaliaCom(MultiHoster): + __name__ = "DebridItaliaCom" + __type__ = "hoster" + __version__ = "0.16" + + __pattern__ = r'https?://(?:www\.|s\d+\.)?debriditalia\.com/dl/\d+' + __description__ = """Debriditalia.com hoster plugin""" - __author_name__ = "stickell" - __author_mail__ = "l.stickell@yahoo.it" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + URL_REPLACEMENTS = [("https://", "http://")] + def setup(self): - self.chunkLimit = -1 + self.chunkLimit = 1 self.resumeDownload = True - def process(self, pyfile): - if re.match(self.__pattern__, pyfile.url): - new_url = pyfile.url - elif not self.account: - self.logError(_("Please enter your %s account or deactivate this plugin") % "DebridItalia") - self.fail("No DebridItalia account provided") - else: - self.logDebug("Old URL: %s" % pyfile.url) - url = "http://debriditalia.com/linkgen2.php?xjxfun=convertiLink&xjxargs[]=S<![CDATA[%s]]>" % pyfile.url - page = self.load(url) - self.logDebug("XML data: %s" % page) - if 'File not available' in page: - self.fail('File not available') - else: - new_url = re.search(r'<a href="(?:[^"]+)">(?P<direct>[^<]+)</a>', page).group('direct') + def handlePremium(self): + self.html = self.load("http://www.debriditalia.com/api.php", + get={'generate': "on", 'link': self.pyfile.url, 'p': self.getPassword()}) - if new_url != pyfile.url: - self.logDebug("New URL: %s" % new_url) + if "ERROR:" not in self.html: + self.link = self.html.strip() + else: + self.info['error'] = re.search(r'ERROR:(.*)', self.html).group(1).strip() - self.download(new_url, disposition=True) + self.html = self.load("http://debriditalia.com/linkgen2.php", + post={'xjxfun' : "convertiLink", + 'xjxargs[]': "S<![CDATA[%s]]>" % self.pyfile.url, + 'xjxargs[]': "S%s" % self.getPassword()}) + try: + self.link = re.search(r'<a href="(.+?)"', self.html).group(1) + except AttributeError: + pass - check = self.checkDownload({"empty": re.compile(r"^$")}) - if check == "empty": - self.retry(5, 2 * 60, "Empty file downloaded") +getInfo = create_getInfo(DebridItaliaCom) diff --git a/module/plugins/hoster/DepositfilesCom.py b/module/plugins/hoster/DepositfilesCom.py index 11b4f4112..6588a3b37 100644 --- a/module/plugins/hoster/DepositfilesCom.py +++ b/module/plugins/hoster/DepositfilesCom.py @@ -1,111 +1,123 @@ # -*- coding: utf-8 -*- import re + from urllib import unquote -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class DepositfilesCom(SimpleHoster): - __name__ = "DepositfilesCom" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?(depositfiles\.com|dfiles\.(eu|ru))(/\w{1,3})?/files/[\w]+' - __version__ = "0.46" + __name__ = "DepositfilesCom" + __type__ = "hoster" + __version__ = "0.51" + + __pattern__ = r'https?://(?:www\.)?(depositfiles\.com|dfiles\.(eu|ru))(/\w{1,3})?/files/(?P<ID>\w+)' + __description__ = """Depositfiles.com hoster plugin""" - __author_name__ = ("spoob", "zoidberg") - __author_mail__ = ("spoob@pyload.org", "zoidberg@mujmail.cz") - - FILE_SIZE_PATTERN = r': <b>(?P<S>[0-9.]+) (?P<U>[kKMG])i?B</b>' - FILE_NAME_PATTERN = r'<script type="text/javascript">eval\( unescape\(\'(?P<N>.*?)\'' - FILE_OFFLINE_PATTERN = r'<span class="html_download_api-not_exists"></span>' - FILE_URL_REPLACEMENTS = [(r"\.com(/.*?)?/files", ".com/en/files"), (r"\.html$", "")] - FILE_NAME_REPLACEMENTS = [(r'\%u([0-9A-Fa-f]{4})', lambda m: unichr(int(m.group(1), 16))), + __license__ = "GPLv3" + __authors__ = [("spoob", "spoob@pyload.org"), + ("zoidberg", "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + NAME_PATTERN = r'<script type="text/javascript">eval\( unescape\(\'(?P<N>.*?)\'' + SIZE_PATTERN = r': <b>(?P<S>[\d.,]+) (?P<U>[\w^_]+)</b>' + OFFLINE_PATTERN = r'<span class="html_download_api-not_exists"></span>' + + NAME_REPLACEMENTS = [(r'\%u([0-9A-Fa-f]{4})', lambda m: unichr(int(m.group(1), 16))), (r'.*<b title="(?P<N>[^"]+).*', "\g<N>")] + URL_REPLACEMENTS = [(__pattern__ + ".*", "https://dfiles.eu/files/\g<ID>")] + + COOKIES = [("dfiles.eu", "lang_current", "en")] + + FREE_LINK_PATTERN = r'<form id="downloader_file_form" action="(http://.+?\.(dfiles\.eu|depositfiles\.com)/.+?)" method="post"' + PREMIUM_LINK_PATTERN = r'class="repeat"><a href="(.+?)"' + PREMIUM_MIRROR_PATTERN = r'class="repeat_mirror"><a href="(.+?)"' - RECAPTCHA_PATTERN = r"Recaptcha.create\('([^']+)'" - DOWNLOAD_LINK_PATTERN = r'<form id="downloader_file_form" action="(http://.+?\.(dfiles\.eu|depositfiles\.com)/.+?)" method="post"' def handleFree(self): self.html = self.load(self.pyfile.url, post={"gateway_result": "1"}, cookies=True) - if re.search(self.FILE_OFFLINE_PATTERN, self.html): - self.offline() if re.search(r'File is checked, please try again in a minute.', self.html) is not None: - self.logInfo("DepositFiles.com: The file is being checked. Waiting 1 minute.") - self.wait(61) - self.retry() + self.logInfo(_("The file is being checked. Waiting 1 minute")) + self.retry(wait_time=60) wait = re.search(r'html_download_api-limit_interval\">(\d+)</span>', self.html) if wait: wait_time = int(wait.group(1)) - self.logInfo("%s: Traffic used up. Waiting %d seconds." % (self.__name__, wait_time)) + self.logInfo(_("Traffic used up. Waiting %d seconds") % wait_time) self.wait(wait_time, True) self.retry() wait = re.search(r'>Try in (\d+) minutes or use GOLD account', self.html) if wait: wait_time = int(wait.group(1)) - self.logInfo("%s: All free slots occupied. Waiting %d minutes." % (self.__name__, wait_time)) + self.logInfo(_("All free slots occupied. Waiting %d minutes") % wait_time) self.setWait(wait_time * 60, False) wait = re.search(r'Please wait (\d+) sec', self.html) if wait: self.setWait(int(wait.group(1))) - found = re.search(r"var fid = '(\w+)';", self.html) - if not found: + m = re.search(r"var fid = '(\w+)';", self.html) + if m is None: self.retry(wait_time=5) - params = {'fid': found.group(1)} + params = {'fid': m.group(1)} self.logDebug("FID: %s" % params['fid']) - captcha_key = '6LdRTL8SAAAAAE9UOdWZ4d0Ky-aeA7XfSqyWDM2m' - found = re.search(self.RECAPTCHA_PATTERN, self.html) - if found: - captcha_key = found.group(1) - self.logDebug("CAPTCHA_KEY: %s" % captcha_key) - self.wait() recaptcha = ReCaptcha(self) + captcha_key = recaptcha.detect_key() + if captcha_key is None: + self.error(_("ReCaptcha key not found")) - for _ in xrange(5): - self.html = self.load("http://depositfiles.com/get_file.php", get=params) + for _i in xrange(5): + self.html = self.load("https://dfiles.eu/get_file.php", get=params) if '<input type=button value="Continue" onclick="check_recaptcha' in self.html: - if not captcha_key: - self.parseError('Captcha key') if 'response' in params: self.invalidCaptcha() params['challenge'], params['response'] = recaptcha.challenge(captcha_key) self.logDebug(params) continue - found = re.search(self.DOWNLOAD_LINK_PATTERN, self.html) - if found: + m = re.search(self.FREE_LINK_PATTERN, self.html) + if m: if 'response' in params: self.correctCaptcha() - link = unquote(found.group(1)) + link = unquote(m.group(1)) self.logDebug("LINK: %s" % link) break else: - self.parseError('Download link') + self.error(_("Download link")) else: - self.fail('No valid captcha response received') + self.fail(_("No valid captcha response received")) try: self.download(link, disposition=True) except: self.retry(wait_time=60) + def handlePremium(self): if '<span class="html_download_api-gold_traffic_limit">' in self.html: - self.logWarning("Download limit reached") + self.logWarning(_("Download limit reached")) self.retry(25, 60 * 60, "Download limit reached") elif 'onClick="show_gold_offer' in self.html: self.account.relogin(self.user) self.retry() - link = unquote( - re.search('<div id="download_url">\s*<a href="(http://.+?\.depositfiles.com/.+?)"', self.html).group(1)) - self.download(link, disposition=True) + else: + link = re.search(self.PREMIUM_LINK_PATTERN, self.html) + mirror = re.search(self.PREMIUM_MIRROR_PATTERN, self.html) + if link: + dlink = link.group(1) + elif mirror: + dlink = mirror.group(1) + else: + self.error(_("No direct download link or mirror found")) + self.download(dlink, disposition=True) getInfo = create_getInfo(DepositfilesCom) diff --git a/module/plugins/hoster/DevhostSt.py b/module/plugins/hoster/DevhostSt.py new file mode 100644 index 000000000..85e36edb3 --- /dev/null +++ b/module/plugins/hoster/DevhostSt.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# +# Test links: +# http://d-h.st/mM8 + +import re + +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + + +class DevhostSt(SimpleHoster): + __name__ = "DevhostSt" + __type__ = "hoster" + __version__ = "0.03" + + __pattern__ = r'http://(?:www\.)?d-h\.st/(?!users/)\w{3}' + + __description__ = """d-h.st hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zapp-brannigan", "fuerst.reinje@web.de")] + + + NAME_PATTERN = r'>Filename:</span> <div title="(?P<N>.+?)"' + SIZE_PATTERN = r'>Size:</span> (?P<S>[\d.,]+) (?P<U>[\w^_]+)' + + OFFLINE_PATTERN = r'>File Not Found<' + LINK_PATTERN = r'id="downloadfile" href="(.+?)"' + + + def setup(self): + self.multiDL = True + self.chunkLimit = 1 + + + def handleFree(self): + m = re.search(self.LINK_PATTERN, self.html) + if m is None: + self.error(_("Download link not found")) + + dl_url = m.group(1) + self.download(dl_url, disposition=True) + + check = self.checkDownload({'html': re.compile("html")}) + if check == "html": + self.error(_("Downloaded file is an html page")) + + +getInfo = create_getInfo(DevhostSt) diff --git a/module/plugins/hoster/DlFreeFr.py b/module/plugins/hoster/DlFreeFr.py index 998dcd606..793c81b1c 100644 --- a/module/plugins/hoster/DlFreeFr.py +++ b/module/plugins/hoster/DlFreeFr.py @@ -1,23 +1,26 @@ # -*- coding: utf-8 -*- -import re import pycurl +import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, replace_patterns -from module.common.json_layer import json_loads from module.network.Browser import Browser from module.network.CookieJar import CookieJar +from module.plugins.internal.CaptchaService import AdYouLike +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, replace_patterns class CustomBrowser(Browser): + def __init__(self, bucket=None, options={}): Browser.__init__(self, bucket, options) + def load(self, *args, **kwargs): post = kwargs.get("post") - if post is None: - if len(args) > 2: - post = args[2] + + if post is None and len(args) > 2: + post = args[2] + if post: self.http.c.setopt(pycurl.FOLLOWLOCATION, 0) self.http.c.setopt(pycurl.POST, 1) @@ -26,114 +29,46 @@ class CustomBrowser(Browser): self.http.c.setopt(pycurl.FOLLOWLOCATION, 1) self.http.c.setopt(pycurl.POST, 0) self.http.c.setopt(pycurl.CUSTOMREQUEST, "GET") - return Browser.load(self, *args, **kwargs) - - -class AdYouLike(): - """ - Class to support adyoulike captcha service - """ - ADYOULIKE_INPUT_PATTERN = r'Adyoulike.create\((.*?)\);' - ADYOULIKE_CALLBACK = r'Adyoulike.g._jsonp_5579316662423138' - ADYOULIKE_CHALLENGE_PATTERN = ADYOULIKE_CALLBACK + r'\((.*?)\)' - - def __init__(self, plugin, engine="adyoulike"): - self.plugin = plugin - self.engine = engine - - def challenge(self, html): - adyoulike_data_string = None - found = re.search(self.ADYOULIKE_INPUT_PATTERN, html) - if found: - adyoulike_data_string = found.group(1) - else: - self.plugin.fail("Can't read AdYouLike input data") - # {"adyoulike":{"key":"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"}, - # "all":{"element_id":"ayl_private_cap_92300","lang":"fr","env":"prod"}} - ayl_data = json_loads(adyoulike_data_string) + return Browser.load(self, *args, **kwargs) - res = self.plugin.load( - r'http://api-ayl.appspot.com/challenge?key=%(ayl_key)s&env=%(ayl_env)s&callback=%(callback)s' % { - "ayl_key": ayl_data[self.engine]["key"], "ayl_env": ayl_data["all"]["env"], - "callback": self.ADYOULIKE_CALLBACK}) - found = re.search(self.ADYOULIKE_CHALLENGE_PATTERN, res) - challenge_string = None - if found: - challenge_string = found.group(1) - else: - self.plugin.fail("Invalid AdYouLike challenge") - challenge_data = json_loads(challenge_string) - - return ayl_data, challenge_data - - def result(self, ayl, challenge): - """ - Adyoulike.g._jsonp_5579316662423138 - ({"translations":{"fr":{"instructions_visual":"Recopiez « Soonnight » ci-dessous :"}}, - "site_under":true,"clickable":true,"pixels":{"VIDEO_050":[],"DISPLAY":[],"VIDEO_000":[],"VIDEO_100":[], - "VIDEO_025":[],"VIDEO_075":[]},"medium_type":"image/adyoulike", - "iframes":{"big":"<iframe src=\"http://www.soonnight.com/campagn.html\" scrolling=\"no\" - height=\"250\" width=\"300\" frameborder=\"0\"></iframe>"},"shares":{},"id":256, - "token":"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1","formats":{"small":{"y":300,"x":0,"w":300,"h":60}, - "big":{"y":0,"x":0,"w":300,"h":250},"hover":{"y":440,"x":0,"w":300,"h":60}}, - "tid":"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"}) - """ - response = None - try: - instructions_visual = challenge["translations"][ayl["all"]["lang"]]["instructions_visual"] - found = re.search(u".*«(.*)».*", instructions_visual) - if found: - response = found.group(1).strip() - else: - self.plugin.fail("Can't parse instructions visual") - except KeyError: - self.plugin.fail("No instructions visual") +class DlFreeFr(SimpleHoster): + __name__ = "DlFreeFr" + __type__ = "hoster" + __version__ = "0.26" - #TODO: Supports captcha + __pattern__ = r'http://(?:www\.)?dl\.free\.fr/(\w+|getfile\.pl\?file=/\w+)' - if not response: - self.plugin.fail("AdYouLike result failed") + __description__ = """Dl.free.fr hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("the-razer", "daniel_ AT gmx DOT net"), + ("zoidberg", "zoidberg@mujmail.cz"), + ("Toilal", "toilal.dev@gmail.com")] - return {"_ayl_captcha_engine": self.engine, - "_ayl_env": ayl["all"]["env"], - "_ayl_tid": challenge["tid"], - "_ayl_token_challenge": challenge["token"], - "_ayl_response": response} + NAME_PATTERN = r'Fichier:</td>\s*<td[^>]*>(?P<N>[^>]*)</td>' + SIZE_PATTERN = r'Taille:</td>\s*<td[^>]*>(?P<S>[\d.,]+\w)o' + OFFLINE_PATTERN = r'Erreur 404 - Document non trouv|Fichier inexistant|Le fichier demandé n\'a pas été trouvé' -class DlFreeFr(SimpleHoster): - __name__ = "DlFreeFr" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?dl\.free\.fr/([a-zA-Z0-9]+|getfile\.pl\?file=/[a-zA-Z0-9]+)' - __version__ = "0.25" - __description__ = """Dl.free.fr hoster plugin""" - __author_name__ = ("the-razer", "zoidberg", "Toilal") - __author_mail__ = ("daniel_ AT gmx DOT net", "zoidberg@mujmail.cz", "toilal.dev@gmail.com") - - FILE_NAME_PATTERN = r"Fichier:</td>\s*<td[^>]*>(?P<N>[^>]*)</td>" - FILE_SIZE_PATTERN = r"Taille:</td>\s*<td[^>]*>(?P<S>[\d.]+[KMG])o" - FILE_OFFLINE_PATTERN = r"Erreur 404 - Document non trouv|Fichier inexistant|Le fichier demandé n'a pas été trouvé" - #FILE_URL_PATTERN = r'href="(?P<url>http://.*?)">Télécharger ce fichier' def setup(self): - self.multiDL = self.resumeDownload = True - self.limitDL = 5 - self.chunkLimit = 1 + self.resumeDownload = True + self.multiDL = True + self.limitDL = 5 + self.chunkLimit = 1 + def init(self): factory = self.core.requestFactory self.req = CustomBrowser(factory.bucket, factory.getOptions()) - def process(self, pyfile): - self.req.setCookieJar(None) - pyfile.url = replace_patterns(pyfile.url, self.FILE_URL_REPLACEMENTS) + def process(self, pyfile): + pyfile.url = replace_patterns(pyfile.url, self.URL_REPLACEMENTS) valid_url = pyfile.url headers = self.load(valid_url, just_header=True) - self.html = None if headers.get('code') == 302: valid_url = headers.get('location') headers = self.load(valid_url, just_header=True) @@ -145,35 +80,35 @@ class DlFreeFr(SimpleHoster): self.html = self.load(valid_url) self.handleFree() else: - # Direct access to requested file for users using free.fr as Internet Service Provider. + # Direct access to requested file for users using free.fr as Internet Service Provider. self.download(valid_url, disposition=True) elif headers.get('code') == 404: self.offline() else: - self.fail("Invalid return code: " + str(headers.get('code'))) + self.fail(_("Invalid return code: ") + str(headers.get('code'))) + def handleFree(self): action, inputs = self.parseHtmlForm('action="getfile.pl"') adyoulike = AdYouLike(self) - ayl, challenge = adyoulike.challenge(self.html) - result = adyoulike.result(ayl, challenge) - inputs.update(result) + inputs.update(adyoulike.challenge()) self.load("http://dl.free.fr/getfile.pl", post=inputs) headers = self.getLastHeaders() if headers.get("code") == 302 and "set-cookie" in headers and "location" in headers: - found = re.search("(.*?)=(.*?); path=(.*?); domain=(.*?)", headers.get("set-cookie")) + m = re.search("(.*?)=(.*?); path=(.*?); domain=(.*?)", headers.get("set-cookie")) cj = CookieJar(__name__) - if found: - cj.setCookie(found.group(4), found.group(1), found.group(2), found.group(3)) + if m: + cj.setCookie(m.group(4), m.group(1), m.group(2), m.group(3)) else: - self.fail("Cookie error") + self.fail(_("Cookie error")) location = headers.get("location") self.req.setCookieJar(cj) self.download(location, disposition=True) else: - self.fail("Invalid response") + self.fail(_("Invalid response")) + def getLastHeaders(self): #parse header diff --git a/module/plugins/hoster/DodanePl.py b/module/plugins/hoster/DodanePl.py new file mode 100644 index 000000000..65d8452fa --- /dev/null +++ b/module/plugins/hoster/DodanePl.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo + + +class DodanePl(DeadHoster): + __name__ = "DodanePl" + __type__ = "hoster" + __version__ = "0.03" + + __pattern__ = r'http://(?:www\.)?dodane\.pl/file/\d+' + + __description__ = """Dodane.pl hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("z00nx", "z00nx0@gmail.com")] + + +getInfo = create_getInfo(DodanePl) diff --git a/module/plugins/hoster/DropboxCom.py b/module/plugins/hoster/DropboxCom.py new file mode 100644 index 000000000..658974d13 --- /dev/null +++ b/module/plugins/hoster/DropboxCom.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + + +class DropboxCom(SimpleHoster): + __name__ = "DropboxCom" + __type__ = "hoster" + __version__ = "0.03" + + __pattern__ = r'https?://(?:www\.)?dropbox\.com/.+' + + __description__ = """Dropbox.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zapp-brannigan", "fuerst.reinje@web.de")] + + + NAME_PATTERN = r'<title>Dropbox - (?P<N>.+?)<' + SIZE_PATTERN = r' · (?P<S>[\d.,]+) (?P<U>[\w^_]+)' + + OFFLINE_PATTERN = r'<title>Dropbox - (404|Shared link error)<' + + COOKIES = [("dropbox.com", "lang", "en")] + + + def setup(self): + self.multiDL = True + self.chunkLimit = 1 + self.resumeDownload = True + + + def handleFree(self): + self.download(self.pyfile.url, get={'dl': "1"}) + + check = self.checkDownload({'html': re.compile("html")}) + if check == "html": + self.error(_("Downloaded file is an html page")) + + +getInfo = create_getInfo(DropboxCom) diff --git a/module/plugins/hoster/DuploadOrg.py b/module/plugins/hoster/DuploadOrg.py index 5909f7ccf..73702eb67 100644 --- a/module/plugins/hoster/DuploadOrg.py +++ b/module/plugins/hoster/DuploadOrg.py @@ -1,34 +1,18 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################ -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo -class DuploadOrg(XFileSharingPro): - __name__ = "DuploadOrg" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?dupload\.org/\w{12}' - __version__ = "0.01" - __description__ = """Dupload.grg hoster plugin""" - __author_name__ = "stickell" - __author_mail__ = "l.stickell@yahoo.it" +class DuploadOrg(DeadHoster): + __name__ = "DuploadOrg" + __type__ = "hoster" + __version__ = "0.02" - HOSTER_NAME = "dupload.org" + __pattern__ = r'http://(?:www\.)?dupload\.org/\w{12}' - FILE_INFO_PATTERN = r'<h3[^>]*>(?P<N>.+) \((?P<S>[\d.]+) (?P<U>\w+)\)</h3>' + __description__ = """Dupload.grg hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it")] getInfo = create_getInfo(DuploadOrg) diff --git a/module/plugins/hoster/EasybytezCom.py b/module/plugins/hoster/EasybytezCom.py index 0ea9b186f..cd54bdc70 100644 --- a/module/plugins/hoster/EasybytezCom.py +++ b/module/plugins/hoster/EasybytezCom.py @@ -1,46 +1,26 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. +class EasybytezCom(XFSHoster): + __name__ = "EasybytezCom" + __type__ = "hoster" + __version__ = "0.23" - @author: zoidberg -""" + __pattern__ = r'http://(?:www\.)?easybytez\.com/\w{12}' -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo - - -class EasybytezCom(XFileSharingPro): - __name__ = "EasybytezCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?easybytez.com/(\w+).*' - __version__ = "0.17" __description__ = """Easybytez.com hoster plugin""" - __author_name__ = ("zoidberg", "stickell") - __author_mail__ = ("zoidberg@mujmail.cz", "l.stickell@yahoo.it") + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it")] - HOSTER_NAME = "easybytez.com" - FILE_INFO_PATTERN = r'<span class="name">(?P<N>.+)</span><br>\s*<span class="size">(?P<S>[^<]+)</span>' - FILE_OFFLINE_PATTERN = r'<h1>File not available</h1>' + HOSTER_DOMAIN = "easybytez.com" - DIRECT_LINK_PATTERN = r'(http://(\w+\.(easyload|easybytez|zingload)\.(com|to)|\d+\.\d+\.\d+\.\d+)/files/\d+/\w+/[^"<]+)' - OVR_DOWNLOAD_LINK_PATTERN = r'<h2>Download Link</h2>\s*<textarea[^>]*>([^<]+)' - OVR_KILL_LINK_PATTERN = r'<h2>Delete Link</h2>\s*<textarea[^>]*>([^<]+)' - ERROR_PATTERN = r'(?:class=["\']err["\'][^>]*>|<Center><b>)(.*?)</' + OFFLINE_PATTERN = r'>File not available' - def setup(self): - self.resumeDownload = self.multiDL = self.premium + LINK_PATTERN = r'(http://(\w+\.(easybytez|easyload|ezbytez|zingload)\.(com|to)|\d+\.\d+\.\d+\.\d+)/files/\d+/\w+/.+?)["\'<]' getInfo = create_getInfo(EasybytezCom) diff --git a/module/plugins/hoster/EdiskCz.py b/module/plugins/hoster/EdiskCz.py index f2d0fa206..eb9338871 100644 --- a/module/plugins/hoster/EdiskCz.py +++ b/module/plugins/hoster/EdiskCz.py @@ -1,53 +1,42 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class EdiskCz(SimpleHoster): - __name__ = "EdiskCz" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?edisk.(cz|sk|eu)/(stahni|sk/stahni|en/download)/.*' - __version__ = "0.21" + __name__ = "EdiskCz" + __type__ = "hoster" + __version__ = "0.22" + + __pattern__ = r'http://(?:www\.)?edisk\.(cz|sk|eu)/(stahni|sk/stahni|en/download)/.+' + __description__ = """Edisk.cz hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + + INFO_PATTERN = r'<span class="fl" title="(?P<N>[^"]+)">\s*.*?\((?P<S>[\d.,]+) (?P<U>[\w^_]+)\)</h1></span>' + OFFLINE_PATTERN = r'<h3>This file does not exist due to one of the following:</h3><ul><li>' - URL_PATTERN = r'<form name = "formular" action = "([^"]+)" method = "post">' - FILE_INFO_PATTERN = r'<span class="fl" title="(?P<N>[^"]+)">\s*.*?\((?P<S>[0-9.]*) (?P<U>[kKMG])i?B\)</h1></span>' ACTION_PATTERN = r'/en/download/(\d+/.*\.html)' - DLLINK_PATTERN = r'http://.*edisk.cz.*\.html' - FILE_OFFLINE_PATTERN = r'<h3>This file does not exist due to one of the following:</h3><ul><li>' + LINK_PATTERN = r'http://.*edisk\.cz.*\.html' + def setup(self): self.multiDL = False + def process(self, pyfile): url = re.sub("/(stahni|sk/stahni)/", "/en/download/", pyfile.url) - self.logDebug('URL:' + url) + self.logDebug("URL:" + url) - found = re.search(self.ACTION_PATTERN, url) - if found is None: - self.parseError("ACTION") - action = found.group(1) + m = re.search(self.ACTION_PATTERN, url) + if m is None: + self.error(_("ACTION_PATTERN not found")) + action = m.group(1) self.html = self.load(url, decode=True) self.getFileInfo() @@ -58,8 +47,8 @@ class EdiskCz(SimpleHoster): "action": action }) - if not re.match(self.DLLINK_PATTERN, url): - self.fail("Unexpected server response") + if not re.match(self.LINK_PATTERN, url): + self.fail(_("Unexpected server response")) self.download(url) diff --git a/module/plugins/hoster/EgoFilesCom.py b/module/plugins/hoster/EgoFilesCom.py index 68a95b33a..9a2f50ed4 100644 --- a/module/plugins/hoster/EgoFilesCom.py +++ b/module/plugins/hoster/EgoFilesCom.py @@ -1,100 +1,18 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################ -# Test link (random.bin): -# http://egofiles.com/mOZfMI1WLZ6HBkGG/random.bin +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo -import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.plugins.internal.CaptchaService import ReCaptcha +class EgoFilesCom(DeadHoster): + __name__ = "EgoFilesCom" + __type__ = "hoster" + __version__ = "0.16" + __pattern__ = r'https?://(?:www\.)?egofiles\.com/\w+' -class EgoFilesCom(SimpleHoster): - __name__ = "EgoFilesCom" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?egofiles.com/(\w+)' - __version__ = "0.15" __description__ = """Egofiles.com hoster plugin""" - __author_name__ = "stickell" - __author_mail__ = "l.stickell@yahoo.it" - - FILE_INFO_PATTERN = r'<div class="down-file">\s+(?P<N>[^\t]+)\s+<div class="file-properties">\s+(File size|Rozmiar): (?P<S>[\w.]+) (?P<U>\w+) \|' - FILE_OFFLINE_PATTERN = r'(File size|Rozmiar): 0 KB' - WAIT_TIME_PATTERN = r'For next free download you have to wait <strong>((?P<m>\d*)m)? ?((?P<s>\d+)s)?</strong>' - DIRECT_LINK_PATTERN = r'<a href="(?P<link>[^"]+)">Download ></a>' - RECAPTCHA_KEY = '6LeXatQSAAAAAHezcjXyWAni-4t302TeYe7_gfvX' - - def setup(self): - # Set English language - self.load("https://egofiles.com/ajax/lang.php?lang=en", just_header=True) - - def process(self, pyfile): - if self.premium and (not self.SH_CHECK_TRAFFIC or self.checkTrafficLeft()): - self.handlePremium() - else: - self.handleFree() - - def handleFree(self): - self.html = self.load(self.pyfile.url, decode=True) - self.getFileInfo() - - # Wait time between free downloads - if 'For next free download you have to wait' in self.html: - m = re.search(self.WAIT_TIME_PATTERN, self.html).groupdict('0') - waittime = int(m['m']) * 60 + int(m['s']) - self.wait(waittime, True) - - downloadURL = '' - recaptcha = ReCaptcha(self) - for _ in xrange(5): - challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY) - post_data = {'recaptcha_challenge_field': challenge, - 'recaptcha_response_field': response} - self.html = self.load(self.pyfile.url, post=post_data, decode=True) - m = re.search(self.DIRECT_LINK_PATTERN, self.html) - if not m: - self.logInfo('Wrong captcha') - self.invalidCaptcha() - elif hasattr(m, 'group'): - downloadURL = m.group('link') - self.correctCaptcha() - break - else: - self.fail('Unknown error - Plugin may be out of date') - - if not downloadURL: - self.fail("No Download url retrieved/all captcha attempts failed") - - self.download(downloadURL, disposition=True) - - def handlePremium(self): - header = self.load(self.pyfile.url, just_header=True) - if 'location' in header: - self.logDebug('DIRECT LINK from header: ' + header['location']) - self.download(header['location']) - else: - self.html = self.load(self.pyfile.url, decode=True) - self.getFileInfo() - m = re.search(r'<a href="(?P<link>[^"]+)">Download ></a>', self.html) - if not m: - self.parseError('Unable to detect direct download url') - else: - self.logDebug('DIRECT URL from html: ' + m.group('link')) - self.download(m.group('link'), disposition=True) + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it")] getInfo = create_getInfo(EgoFilesCom) diff --git a/module/plugins/hoster/EnteruploadCom.py b/module/plugins/hoster/EnteruploadCom.py new file mode 100644 index 000000000..bbd613f57 --- /dev/null +++ b/module/plugins/hoster/EnteruploadCom.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo + + +class EnteruploadCom(DeadHoster): + __name__ = "EnteruploadCom" + __type__ = "hoster" + __version__ = "0.02" + + __pattern__ = r'http://(?:www\.)?enterupload\.com/\w+' + + __description__ = """EnterUpload.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + +getInfo = create_getInfo(EnteruploadCom) diff --git a/module/plugins/hoster/EpicShareNet.py b/module/plugins/hoster/EpicShareNet.py index 65e9cb5c3..8ac8cdaf2 100644 --- a/module/plugins/hoster/EpicShareNet.py +++ b/module/plugins/hoster/EpicShareNet.py @@ -1,24 +1,18 @@ # -*- coding: utf-8 -*- -# Test links: -# BigBuckBunny_320x180.mp4 - 61.7 Mb - http://epicshare.net/fch3m2bk6ihp/BigBuckBunny_320x180.mp4.html +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +class EpicShareNet(DeadHoster): + __name__ = "EpicShareNet" + __type__ = "hoster" + __version__ = "0.02" -class EpicShareNet(XFileSharingPro): - __name__ = "EpicShareNet" - __type__ = "hoster" __pattern__ = r'https?://(?:www\.)?epicshare\.net/\w{12}' - __version__ = "0.01" - __description__ = """EpicShare.net hoster plugin""" - __author_name__ = "t4skforce" - __author_mail__ = "t4skforce1337[AT]gmail[DOT]com" - - HOSTER_NAME = "epicshare.net" - FILE_OFFLINE_PATTERN = r'<b>File Not Found</b><br><br>' - FILE_NAME_PATTERN = r'<b>Password:</b></div>\s*<h2>(?P<N>[^<]+)</h2>' + __description__ = """EpicShare.net hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("t4skforce", "t4skforce1337[AT]gmail[DOT]com")] getInfo = create_getInfo(EpicShareNet) diff --git a/module/plugins/hoster/EuroshareEu.py b/module/plugins/hoster/EuroshareEu.py index fa6342014..cc10abb37 100644 --- a/module/plugins/hoster/EuroshareEu.py +++ b/module/plugins/hoster/EuroshareEu.py @@ -1,52 +1,41 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class EuroshareEu(SimpleHoster): - __name__ = "EuroshareEu" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?euroshare.(eu|sk|cz|hu|pl)/file/.*' - __version__ = "0.25" + __name__ = "EuroshareEu" + __type__ = "hoster" + __version__ = "0.26" + + __pattern__ = r'http://(?:www\.)?euroshare\.(eu|sk|cz|hu|pl)/file/.+' + __description__ = """Euroshare.eu hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + - FILE_INFO_PATTERN = r'<span style="float: left;"><strong>(?P<N>.+?)</strong> \((?P<S>.+?)\)</span>' - FILE_OFFLINE_PATTERN = ur'<h2>S.bor sa nena.iel</h2>|Požadovaná stránka neexistuje!' + INFO_PATTERN = r'<span style="float: left;"><strong>(?P<N>.+?)</strong> \((?P<S>.+?)\)</span>' + OFFLINE_PATTERN = ur'<h2>S.bor sa nena.iel</h2>|Požadovaná stránka neexistuje!' FREE_URL_PATTERN = r'<a href="(/file/\d+/[^/]*/download/)"><div class="downloadButton"' ERR_PARDL_PATTERN = r'<h2>Prebieha s.ahovanie</h2>|<p>Naraz je z jednej IP adresy mo.n. s.ahova. iba jeden s.bor' ERR_NOT_LOGGED_IN_PATTERN = r'href="/customer-zone/login/"' - FILE_URL_REPLACEMENTS = [(r"(http://[^/]*\.)(sk|cz|hu|pl)/", r"\1eu/")] + URL_REPLACEMENTS = [(r"(http://[^/]*\.)(sk|cz|hu|pl)/", r"\1eu/")] + def setup(self): self.multiDL = self.resumeDownload = self.premium self.req.setOption("timeout", 120) + def handlePremium(self): if self.ERR_NOT_LOGGED_IN_PATTERN in self.html: self.account.relogin(self.user) - self.retry(reason="User not logged in") + self.retry(reason=_("User not logged in")) self.download(self.pyfile.url.rstrip('/') + "/download/") @@ -54,18 +43,19 @@ class EuroshareEu(SimpleHoster): "json": re.compile(r'\{"status":"error".*?"message":"(.*?)"')}) if check == "login" or (check == "json" and self.lastCheck.group(1) == "Access token expired"): self.account.relogin(self.user) - self.retry(reason="Access token expired") + self.retry(reason=_("Access token expired")) elif check == "json": self.fail(self.lastCheck.group(1)) + def handleFree(self): if re.search(self.ERR_PARDL_PATTERN, self.html) is not None: self.longWait(5 * 60, 12) - found = re.search(self.FREE_URL_PATTERN, self.html) - if found is None: - self.parseError("Parse error (URL)") - parsed_url = "http://euroshare.eu%s" % found.group(1) + m = re.search(self.FREE_URL_PATTERN, self.html) + if m is None: + self.error(_("FREE_URL_PATTERN not found")) + parsed_url = "http://euroshare.eu%s" % m.group(1) self.logDebug("URL", parsed_url) self.download(parsed_url, disposition=True) diff --git a/module/plugins/hoster/ExtabitCom.py b/module/plugins/hoster/ExtabitCom.py index 4dba81a8f..7609954d3 100644 --- a/module/plugins/hoster/ExtabitCom.py +++ b/module/plugins/hoster/ExtabitCom.py @@ -1,87 +1,77 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.plugins.internal.CaptchaService import ReCaptcha from module.common.json_layer import json_loads +from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, secondsToMidnight + class ExtabitCom(SimpleHoster): - __name__ = "ExtabitCom" - __type__ = "hoster" + __name__ = "ExtabitCom" + __type__ = "hoster" + __version__ = "0.63" + __pattern__ = r'http://(?:www\.)?extabit\.com/(file|go|fid)/(?P<ID>\w+)' - __version__ = "0.5" + __description__ = """Extabit.com hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + - FILE_NAME_PATTERN = r'<th>File:</th>\s*<td class="col-fileinfo">\s*<div title="(?P<N>[^"]+)">' - FILE_SIZE_PATTERN = r'<th>Size:</th>\s*<td class="col-fileinfo">(?P<S>[^<]+)</td>' - FILE_OFFLINE_PATTERN = r'>File not found<' - TEMP_OFFLINE_PATTERN = r">(File is temporary unavailable|No download mirror)<" + NAME_PATTERN = r'<th>File:</th>\s*<td class="col-fileinfo">\s*<div title="(?P<N>[^"]+)">' + SIZE_PATTERN = r'<th>Size:</th>\s*<td class="col-fileinfo">(?P<S>[^<]+)</td>' + OFFLINE_PATTERN = r'>File not found<' + TEMP_OFFLINE_PATTERN = r'>(File is temporary unavailable|No download mirror)<' + + LINK_PATTERN = r'[\'"](http://guest\d+\.extabit\.com/\w+/.*?)[\'"]' - DOWNLOAD_LINK_PATTERN = r'[\'"](http://guest\d+\.extabit\.com/[a-z0-9]+/.*?)[\'"]' def handleFree(self): if r">Only premium users can download this file" in self.html: - self.fail("Only premium users can download this file") + self.fail(_("Only premium users can download this file")) m = re.search(r"Next free download from your ip will be available in <b>(\d+)\s*minutes", self.html) if m: self.wait(int(m.group(1)) * 60, True) elif "The daily downloads limit from your IP is exceeded" in self.html: - self.wait(1 * 60 * 60, True) + self.logWarning(_("You have reached your daily downloads limit for today")) + self.wait(secondsToMidnight(gmt=2), True) self.logDebug("URL: " + self.req.http.lastEffectiveURL) m = re.match(self.__pattern__, self.req.http.lastEffectiveURL) - fileID = m.group('ID') if m else self.file_info('ID') + fileID = m.group('ID') if m else self.info('ID') m = re.search(r'recaptcha/api/challenge\?k=(\w+)', self.html) if m: recaptcha = ReCaptcha(self) captcha_key = m.group(1) - for _ in xrange(5): + for _i in xrange(5): get_data = {"type": "recaptcha"} - get_data["challenge"], get_data["capture"] = recaptcha.challenge(captcha_key) - response = json_loads(self.load("http://extabit.com/file/%s/" % fileID, get=get_data)) - if "ok" in response: + get_data['challenge'], get_data['capture'] = recaptcha.challenge(captcha_key) + res = json_loads(self.load("http://extabit.com/file/%s/" % fileID, get=get_data)) + if "ok" in res: self.correctCaptcha() break else: self.invalidCaptcha() else: - self.fail("Invalid captcha") + self.fail(_("Invalid captcha")) else: - self.parseError('Captcha') + self.error(_("Captcha")) + + if not "href" in res: + self.error(_("Bad JSON response")) + + self.html = self.load("http://extabit.com/file/%s%s" % (fileID, res['href'])) - if not "href" in response: - self.parseError('JSON') + m = re.search(self.LINK_PATTERN, self.html) + if m is None: + self.error(_("LINK_PATTERN not found")) - self.html = self.load("http://extabit.com/file/%s%s" % (fileID, response['href'])) - m = re.search(self.DOWNLOAD_LINK_PATTERN, self.html) - if not m: - self.parseError('Download URL') url = m.group(1) - self.logDebug("Download URL: " + url) self.download(url) diff --git a/module/plugins/hoster/FastixRu.py b/module/plugins/hoster/FastixRu.py index 8eeabc17c..5f6fd2d4c 100644 --- a/module/plugins/hoster/FastixRu.py +++ b/module/plugins/hoster/FastixRu.py @@ -1,20 +1,25 @@ # -*- coding: utf-8 -*- import re -from urllib import unquote + from random import randrange -from module.plugins.Hoster import Hoster +from urllib import unquote + from module.common.json_layer import json_loads +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -class FastixRu(Hoster): - __name__ = "FastixRu" - __version__ = "0.04" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?fastix\.(ru|it)/file/(?P<ID>[a-zA-Z0-9]{24})' +class FastixRu(MultiHoster): + __name__ = "FastixRu" + __type__ = "hoster" + __version__ = "0.08" + + __pattern__ = r'http://(?:www\.)?fastix\.(ru|it)/file/\w{24}' + __description__ = """Fastix hoster plugin""" - __author_name__ = "Massimo Rosamilia" - __author_mail__ = "max@spiritix.eu" + __license__ = "GPLv3" + __authors__ = [("Massimo Rosamilia", "max@spiritix.eu")] + def getFilename(self, url): try: @@ -25,42 +30,40 @@ class FastixRu(Hoster): name += "%s.tmp" % randrange(100, 999) return name + def setup(self): - self.chunkLimit = 3 + self.chunkLimit = 3 self.resumeDownload = True - def process(self, pyfile): - if re.match(self.__pattern__, pyfile.url): - new_url = pyfile.url - elif not self.account: - self.logError(_("Please enter your %s account or deactivate this plugin") % "Fastix") - self.fail("No Fastix account provided") + + def handlePremium(self): + api_key = self.account.getAccountData(self.user) + api_key = api_key['api'] + + page = self.load("http://fastix.ru/api_v2/", + get={'apikey': api_key, 'sub': "getdirectlink", 'link': self.pyfile.url}) + data = json_loads(page) + + self.logDebug("Json data", data) + + if "error\":true" in page: + self.offline() else: - self.logDebug("Old URL: %s" % pyfile.url) - api_key = self.account.getAccountData(self.user) - api_key = api_key["api"] - url = "http://fastix.ru/api_v2/?apikey=%s&sub=getdirectlink&link=%s" % (api_key, pyfile.url) - page = self.load(url) - data = json_loads(page) - self.logDebug("Json data: %s" % str(data)) - if "error\":true" in page: - self.offline() - else: - new_url = data["downloadlink"] - - if new_url != pyfile.url: - self.logDebug("New URL: %s" % new_url) - - if pyfile.name.startswith("http") or pyfile.name.startswith("Unknown"): + self.link = data['downloadlink'] + + if self.link != self.pyfile.url: + self.logDebug("New URL: %s" % self.link) + + if self.pyfile.name.startswith("http") or self.pyfile.name.startswith("Unknown"): #only use when name wasnt already set - pyfile.name = self.getFilename(new_url) + self.pyfile.name = self.getFilename(self.link) + + + def checkFile(self): + super(FastixRu, self).checkFile() - self.download(new_url, disposition=True) + if self.checkDownload({"error": "<title>An error occurred while processing your request</title>"}) is "error": + self.retry(wait_time=60, reason=_("An error occurred while generating link")) - check = self.checkDownload({"error": "<title>An error occurred while processing your request</title>", - "empty": re.compile(r"^$")}) - if check == "error": - self.retry(wait_time=60, reason="An error occurred while generating link.") - elif check == "empty": - self.retry(wait_time=60, reason="Downloaded File was empty.") +getInfo = create_getInfo(FastixRu) diff --git a/module/plugins/hoster/FastshareCz.py b/module/plugins/hoster/FastshareCz.py index c7841a237..31437c6e7 100644 --- a/module/plugins/hoster/FastshareCz.py +++ b/module/plugins/hoster/FastshareCz.py @@ -1,98 +1,78 @@ # -*- coding: utf-8 -*- -############################################################################### -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -# @author: zoidberg -############################################################################### - -# Test links (random.bin): -# http://www.fastshare.cz/2141189/random.bin import re + from urlparse import urljoin from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class FastshareCz(SimpleHoster): - __name__ = "FastshareCz" - __type__ = "hoster" + __name__ = "FastshareCz" + __type__ = "hoster" + __version__ = "0.26" + __pattern__ = r'http://(?:www\.)?fastshare\.cz/\d+/.+' - __version__ = "0.22" + __description__ = """FastShare.cz hoster plugin""" - __author_name__ = ("zoidberg", "stickell", "Walter Purcaro") - __author_mail__ = ("zoidberg@mujmail.cz", "l.stickell@yahoo.it", "vuolter@gmail.com") + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - FILE_INFO_PATTERN = r'<h1 class="dwp">(?P<N>[^<]+)</h1>\s*<div class="fileinfo">\s*Size\s*: (?P<S>\d+) (?P<U>\w+),' - FILE_OFFLINE_PATTERN = '>(The file has been deleted|Requested page not found)' + URL_REPLACEMENTS = [("#.*", "")] - FILE_URL_REPLACEMENTS = [("#.*", "")] - SH_COOKIES = [(".fastshare.cz", "lang", "en")] + COOKIES = [("fastshare.cz", "lang", "en")] - FREE_URL_PATTERN = r'action=(/free/.*?)>\s*<img src="([^"]*)"><br' - PREMIUM_URL_PATTERN = r'(http://data\d+\.fastshare\.cz/download\.php\?id=\d+&)' - CREDIT_PATTERN = " credit for " + INFO_PATTERN = r'<h1 class="dwp">(?P<N>[^<]+)</h1>\s*<div class="fileinfo">\s*Size\s*: (?P<S>\d+) (?P<U>[\w^_]+),' + OFFLINE_PATTERN = r'>(The file has been deleted|Requested page not found)' - def handleFree(self): - if "> 100% of FREE slots are full" in self.html: - self.retry(120, 60, "No free slots") + LINK_FREE_PATTERN = r'action=(/free/.*?)>\s*<img src="([^"]*)"><br' + LINK_PREMIUM_PATTERN = r'(http://data\d+\.fastshare\.cz/download\.php\?id=\d+&)' + + SLOT_ERROR = "> 100% of FREE slots are full" + CREDIT_ERROR = " credit for " + + + def checkErrors(self): + if self.SLOT_ERROR in self.html: + errmsg = self.info['error'] = _("No free slots") + self.retry(12, 60, errmsg) + + if self.CREDIT_ERROR in self.html: + errmsg = self.info['error'] = _("Not enough traffic left") + self.logWarning(errmsg) + self.resetAccount() + + self.info.pop('error', None) - found = re.search(self.FREE_URL_PATTERN, self.html) - if found: - action, captcha_src = found.groups() + + def handleFree(self): + m = re.search(self.FREE_URL_PATTERN, self.html) + if m: + action, captcha_src = m.groups() else: - self.parseError("Free URL") + self.error(_("FREE_URL_PATTERN not found")) baseurl = "http://www.fastshare.cz" captcha = self.decryptCaptcha(urljoin(baseurl, captcha_src)) - self.download(urljoin(baseurl, action), post={"code": captcha, "btn.x": 77, "btn.y": 18}) + self.download(urljoin(baseurl, action), post={'code': captcha, 'btn.x': 77, 'btn.y': 18}) + + + def checkFile(self): + super(FastshareCz, self).checkFile() check = self.checkDownload({ - "paralell_dl": - "<title>FastShare.cz</title>|<script>alert\('Pres FREE muzete stahovat jen jeden soubor najednou.'\)", - "wrong_captcha": "Download for FREE" + 'paralell_dl' : re.compile(r"<title>FastShare.cz</title>|<script>alert\('Pres FREE muzete stahovat jen jeden soubor najednou.'\)"), + 'wrong_captcha': re.compile(r'Download for FREE'), + 'credit' : re.compile(self.CREDIT_ERROR) }) if check == "paralell_dl": - self.retry(6, 10 * 60, "Paralell download") - elif check == "wrong_captcha": - self.retry(max_tries=5, reason="Wrong captcha") + self.retry(6, 10 * 60, _("Paralell download")) - def handlePremium(self): - header = self.load(self.pyfile.url, just_header=True) - if "location" in header: - url = header["location"] - else: - self.html = self.load(self.pyfile.url) - - self.getFileInfo() # - - if self.CREDIT_PATTERN in self.html: - self.logWarning("Not enough traffic left") - self.resetAccount() - else: - found = re.search(self.PREMIUM_URL_PATTERN, self.html) - if found: - url = found.group(1) - else: - self.parseError("Premium URL") - - self.logDebug("PREMIUM URL: " + url) - self.download(url, disposition=True) + elif check == "wrong_captcha": + self.retry(max_tries=5, reason=_("Wrong captcha")) - check = self.checkDownload({"credit": re.compile(self.CREDIT_PATTERN)}) - if check == "credit": + elif check == "credit": self.resetAccount() diff --git a/module/plugins/hoster/File4safeCom.py b/module/plugins/hoster/File4safeCom.py deleted file mode 100644 index 9e06972e2..000000000 --- a/module/plugins/hoster/File4safeCom.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -from pycurl import FOLLOWLOCATION - -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo - - -class File4safeCom(XFileSharingPro): - __name__ = "File4safeCom" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?file4safe\.com/\w+' - __version__ = "0.01" - __description__ = """File4safe.com hoster plugin""" - __author_name__ = "stickell" - __author_mail__ = "l.stickell@yahoo.it" - - HOSTER_NAME = "file4safe.com" - - def handlePremium(self): - self.req.http.lastURL = self.pyfile.url - - self.req.http.c.setopt(FOLLOWLOCATION, 0) - self.load(self.pyfile.url, post=self.getPostParameters(), decode=True) - self.header = self.req.http.header - self.req.http.c.setopt(FOLLOWLOCATION, 1) - - found = re.search(r"Location\s*:\s*(.*)", self.header, re.I) - if found and re.match(self.DIRECT_LINK_PATTERN, found.group(1)): - location = found.group(1).strip() - self.startDownload(location) - else: - self.parseError("Unable to detect premium download link") - - -getInfo = create_getInfo(File4safeCom) diff --git a/module/plugins/hoster/FileApeCom.py b/module/plugins/hoster/FileApeCom.py index 34b4acd07..db843586b 100644 --- a/module/plugins/hoster/FileApeCom.py +++ b/module/plugins/hoster/FileApeCom.py @@ -4,13 +4,15 @@ from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo class FileApeCom(DeadHoster): - __name__ = "FileApeCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?fileape\.com/(index\.php\?act=download\&id=|dl/)\w+' + __name__ = "FileApeCom" + __type__ = "hoster" __version__ = "0.12" + + __pattern__ = r'http://(?:www\.)?fileape\.com/(index\.php\?act=download\&id=|dl/)\w+' + __description__ = """FileApe.com hoster plugin""" - __author_name__ = "espes" - __author_mail__ = "" + __license__ = "GPLv3" + __authors__ = [("espes", None)] getInfo = create_getInfo(FileApeCom) diff --git a/module/plugins/hoster/FileParadoxIn.py b/module/plugins/hoster/FileParadoxIn.py new file mode 100644 index 000000000..0b5b57e22 --- /dev/null +++ b/module/plugins/hoster/FileParadoxIn.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo + + +class FileParadoxIn(XFSHoster): + __name__ = "FileParadoxIn" + __type__ = "hoster" + __version__ = "0.04" + + __pattern__ = r'https?://(?:www\.)?fileparadox\.in/\w{12}' + + __description__ = """FileParadox.in hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("RazorWing", "muppetuk1@hotmail.com")] + + + HOSTER_DOMAIN = "fileparadox.in" + + +getInfo = create_getInfo(FileParadoxIn) diff --git a/module/plugins/hoster/FileSharkPl.py b/module/plugins/hoster/FileSharkPl.py new file mode 100644 index 000000000..5250a92fe --- /dev/null +++ b/module/plugins/hoster/FileSharkPl.py @@ -0,0 +1,140 @@ +# -*- coding: utf-8 -*- + +import re + +from urlparse import urljoin + +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + + +class FileSharkPl(SimpleHoster): + __name__ = "FileSharkPl" + __type__ = "hoster" + __version__ = "0.05" + + __pattern__ = r'http://(?:www\.)?fileshark\.pl/pobierz/\d{6}/\w{5}' + + __description__ = """FileShark.pl hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("prOq", None), + ("Walter Purcaro", "vuolter@gmail.com")] + + + NAME_PATTERN = r'<h2 class="name-file">(?P<N>.+)</h2>' + SIZE_PATTERN = r'<p class="size-file">(.*?)<strong>(?P<S>\d+\.?\d*)\s(?P<U>\w+)</strong></p>' + + OFFLINE_PATTERN = '(P|p)lik zosta. (usuni.ty|przeniesiony)' + + LINK_FREE_PATTERN = r'<a href="(.*?)" class="btn-upload-free">' + LINK_PREMIUM_PATTERN = r'<a href="(.*?)" class="btn-upload-premium">' + + WAIT_PATTERN = r'var timeToDownload = (\d+);' + ERROR_PATTERN = r'<p class="lead text-center alert alert-warning">(.*?)</p>' + IP_ERROR_PATTERN = r'Strona jest dost.pna wy..cznie dla u.ytkownik.w znajduj.cych si. na terenie Polski' + SLOT_ERROR_PATTERN = r'Osi.gni.to maksymaln. liczb. .ci.ganych jednocze.nie plik.w\.' + + CAPTCHA_PATTERN = '<img src="data:image/jpeg;base64,(.*?)" title="captcha"' + TOKEN_PATTERN = r'name="form\[_token\]" value="(.*?)" />' + + + def setup(self): + self.resumeDownload = True + if self.premium: + self.multiDL = True + self.limitDL = 20 + else: + self.multiDL = False + + + def checkErrors(self): + # check if file is now available for download (-> file name can be found in html body) + m = re.search(self.WAIT_PATTERN, self.html) + if m: + errmsg = self.info['error'] = _("Another download already run") + self.retry(15, int(m.group(1)), errmsg) + + m = re.search(self.ERROR_PATTERN, self.html): + if m: + alert = m.group(1) + + if re.match(self.IP_ERROR_PATTERN, alert): + self.fail(_("Only connections from Polish IP are allowed")) + + elif re.match(self.SLOT_ERROR_PATTERN, alert): + errmsg = self.info['error'] = _("No free download slots available") + self.logWarning(errmsg) + self.retry(10, 30 * 60, _("Still no free download slots available")) + + else: + self.info['error'] = alert + self.retry(10, 10 * 60, _("Try again later")) + + self.info.pop('error', None) + + + #@NOTE: handlePremium method was never been tested + def handlePremium(self): + super(FilerNet, self).handlePremium() + if self.link: + self.link = urljoin("http://fileshark.pl/", self.link) + + + def handleFree(self): + m = re.search(self.LINK_FREE_PATTERN, self.html) + if m is None: + self.error(_("Download url not found")) + + link = urljoin("http://fileshark.pl", m.group(1)) + + m = re.search(self.WAIT_PATTERN, self.html) + if m: + seconds = int(m.group(1)) + self.logDebug("Wait %s seconds" % seconds) + self.wait(seconds) + + action, inputs = self.parseHtmlForm('action=""') + + m = re.search(self.TOKEN_PATTERN, self.html) + if m is None: + self.retry(reason=_("Captcha form not found")) + + inputs['form[_token]'] = m.group(1) + + m = re.search(self.CAPTCHA_PATTERN, self.html) + if m is None: + self.retry(reason=_("Captcha image not found")) + + tmp_load = self.load + self.load = self._decode64 #: work-around: injects decode64 inside decryptCaptcha + + inputs['form[captcha]'] = self.decryptCaptcha(m.group(1), imgtype='jpeg') + inputs['form[start]'] = "" + + self.load = tmp_load + + self.download(link, post=inputs, cookies=True, disposition=True) + + + def checkFile(self): + super(FileSharkPl, self).checkFile() + + check = self.checkDownload({'wrong_captcha': re.compile(r'<label for="form_captcha" generated="true" class="error">(.*?)</label>'), + 'wait_pattern' : re.compile(self.SECONDS_PATTERN), + 'DL-found' : re.compile('<a href="(.*)">')}) + + if check == "DL-found": + self.correctCaptcha() + + elif check == "wrong_captcha": + self.invalidCaptcha() + self.retry(10, 1, _("Wrong captcha solution")) + + elif check == "wait_pattern": + self.retry() + + + def _decode64(self, data, *args, **kwargs): + return data.decode("base64") + + +getInfo = create_getInfo(FileSharkPl) diff --git a/module/plugins/hoster/FileStoreTo.py b/module/plugins/hoster/FileStoreTo.py index 5a73fb9ef..e1bd8da71 100644 --- a/module/plugins/hoster/FileStoreTo.py +++ b/module/plugins/hoster/FileStoreTo.py @@ -1,47 +1,36 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: Walter Purcaro -""" - import re from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class FileStoreTo(SimpleHoster): - __name__ = "FileStoreTo" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?filestore\.to/\?d=(?P<ID>\w+)' + __name__ = "FileStoreTo" + __type__ = "hoster" __version__ = "0.01" + + __pattern__ = r'http://(?:www\.)?filestore\.to/\?d=(?P<ID>\w+)' + __description__ = """FileStore.to hoster plugin""" - __author_name__ = ("Walter Purcaro", "stickell") - __author_mail__ = ("vuolter@gmail.com", "l.stickell@yahoo.it") + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com"), + ("stickell", "l.stickell@yahoo.it")] + + + INFO_PATTERN = r'File: <span[^>]*>(?P<N>.+)</span><br />Size: (?P<S>[\d.,]+) (?P<U>[\w^_]+)' + OFFLINE_PATTERN = r'>Download-Datei wurde nicht gefunden<' - FILE_INFO_PATTERN = r'File: <span[^>]*>(?P<N>.+)</span><br />Size: (?P<S>[\d,.]+) (?P<U>\w+)' - FILE_OFFLINE_PATTERN = r'>Download-Datei wurde nicht gefunden<' def setup(self): - self.resumeDownload = self.multiDL = True + self.resumeDownload = True + self.multiDL = True + def handleFree(self): self.wait(10) ldc = re.search(r'wert="(\w+)"', self.html).group(1) link = self.load("http://filestore.to/ajax/download.php", get={"LDC": ldc}) - self.logDebug("Download link = " + link) self.download(link) diff --git a/module/plugins/hoster/FilebeerInfo.py b/module/plugins/hoster/FilebeerInfo.py index dd26b9120..885010a2c 100644 --- a/module/plugins/hoster/FilebeerInfo.py +++ b/module/plugins/hoster/FilebeerInfo.py @@ -4,13 +4,15 @@ from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo class FilebeerInfo(DeadHoster): - __name__ = "FilebeerInfo" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?filebeer\.info/(?!\d*~f)(?P<ID>\w+).*' + __name__ = "FilebeerInfo" + __type__ = "hoster" __version__ = "0.03" + + __pattern__ = r'http://(?:www\.)?filebeer\.info/(?!\d*~f)(?P<ID>\w+)' + __description__ = """Filebeer.info plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] getInfo = create_getInfo(FilebeerInfo) diff --git a/module/plugins/hoster/FilecloudIo.py b/module/plugins/hoster/FilecloudIo.py index 56eedf33a..8b6804a68 100644 --- a/module/plugins/hoster/FilecloudIo.py +++ b/module/plugins/hoster/FilecloudIo.py @@ -1,119 +1,116 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, PluginParseError + from module.common.json_layer import json_loads from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class FilecloudIo(SimpleHoster): - __name__ = "FilecloudIo" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?(?:filecloud\.io|ifile\.it|mihd\.net)/(?P<ID>\w+).*' - __version__ = "0.02" + __name__ = "FilecloudIo" + __type__ = "hoster" + __version__ = "0.05" + + __pattern__ = r'http://(?:www\.)?(?:filecloud\.io|ifile\.it|mihd\.net)/(?P<ID>\w+)' + __description__ = """Filecloud.io hoster plugin""" - __author_name__ = ("zoidberg", "stickell") - __author_mail__ = ("zoidberg@mujmail.cz", "l.stickell@yahoo.it") + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it")] + + + SIZE_PATTERN = r'{var __ab1 = (?P<S>\d+);}' + NAME_PATTERN = r'id="aliasSpan">(?P<N>.*?) <' + OFFLINE_PATTERN = r'l10n\.(FILES__DOESNT_EXIST|REMOVED)' + TEMP_OFFLINE_PATTERN = r'l10n\.FILES__WARNING' - FILE_SIZE_PATTERN = r'{var __ab1 = (?P<S>\d+);}' - FILE_NAME_PATTERN = r'id="aliasSpan">(?P<N>.*?) <' - FILE_OFFLINE_PATTERN = r'l10n.(FILES__DOESNT_EXIST|REMOVED)' - TEMP_OFFLINE_PATTERN = r'l10n.FILES__WARNING' + UKEY_PATTERN = r'\'ukey\'\s*:\'(\w+)' + AB1_PATTERN = r'if\( __ab1 == \'(\w+)\' \)' + ERROR_MSG_PATTERN = r'var __error_msg\s*=\s*l10n\.(.*?);' + RECAPTCHA_PATTERN = r'var __recaptcha_public\s*=\s*\'(.+?)\';' + + LINK_PATTERN = r'"(http://s\d+\.filecloud\.io/%s/\d+/.*?)"' - UKEY_PATTERN = r"'ukey'\s*:'(\w+)'," - AB1_PATTERN = r"if\( __ab1 == '(\w+)' \)" - ERROR_MSG_PATTERN = r"var __error_msg\s*=\s*l10n\.(.*?);" - DOWNLOAD_LINK_PATTERN = r'"(http://s\d+.filecloud.io/%s/\d+/.*?)"' - RECAPTCHA_KEY_PATTERN = r"var __recaptcha_public\s*=\s*'([^']+)';" - RECAPTCHA_KEY = '6Lf5OdISAAAAAEZObLcx5Wlv4daMaASRov1ysDB1' def setup(self): - self.resumeDownload = self.multiDL = True - self.chunkLimit = 1 + self.resumeDownload = True + self.multiDL = True + self.chunkLimit = 1 + def handleFree(self): - data = {"ukey": self.file_info['ID']} + data = {"ukey": self.info['pattern']['ID']} + + m = re.search(self.AB1_PATTERN, self.html) + if m is None: + self.error(_("__AB1")) + data['__ab1'] = m.group(1) + + recaptcha = ReCaptcha(self) + + m = re.search(self.RECAPTCHA_PATTERN, self.html) + captcha_key = m.group(1) if m else recaptcha.detect_key() - found = re.search(self.AB1_PATTERN, self.html) - if not found: - raise PluginParseError("__AB1") - data["__ab1"] = found.group(1) + if captcha_key is None: + self.error(_("ReCaptcha key not found")) if not self.account: - self.fail("User not logged in") + self.fail(_("User not logged in")) elif not self.account.logged_in: - recaptcha = ReCaptcha(self) - captcha_challenge, captcha_response = recaptcha.challenge(self.RECAPTCHA_KEY) - self.account.form_data = {"recaptcha_challenge_field": captcha_challenge, - "recaptcha_response_field": captcha_response} + challenge, response = recaptcha.challenge(captcha_key) + self.account.form_data = {"recaptcha_challenge_field": challenge, + "recaptcha_response_field" : response} self.account.relogin(self.user) self.retry(2) json_url = "http://filecloud.io/download-request.json" - response = self.load(json_url, post=data) - self.logDebug(response) - response = json_loads(response) + res = self.load(json_url, post=data) + self.logDebug(res) + res = json_loads(res) - if "error" in response and response["error"]: - self.fail(response) + if "error" in res and res['error']: + self.fail(res) - self.logDebug(response) - if response["captcha"]: - recaptcha = ReCaptcha(self) - found = re.search(self.RECAPTCHA_KEY_PATTERN, self.html) - captcha_key = found.group(1) if found else self.RECAPTCHA_KEY - data["ctype"] = "recaptcha" + self.logDebug(res) + if res['captcha']: + data['ctype'] = "recaptcha" - for _ in xrange(5): - data["recaptcha_challenge"], data["recaptcha_response"] = recaptcha.challenge(captcha_key) + for _i in xrange(5): + data['recaptcha_challenge'], data['recaptcha_response'] = recaptcha.challenge(captcha_key) json_url = "http://filecloud.io/download-request.json" - response = self.load(json_url, post=data) - self.logDebug(response) - response = json_loads(response) + res = self.load(json_url, post=data) + self.logDebug(res) + res = json_loads(res) - if "retry" in response and response["retry"]: + if "retry" in res and res['retry']: self.invalidCaptcha() else: self.correctCaptcha() break else: - self.fail("Incorrect captcha") + self.fail(_("Incorrect captcha")) - if response["dl"]: + if res['dl']: self.html = self.load('http://filecloud.io/download.html') - found = re.search(self.DOWNLOAD_LINK_PATTERN % self.file_info['ID'], self.html) - if not found: - raise PluginParseError("Download URL") - download_url = found.group(1) - self.logDebug("Download URL: %s" % download_url) - - if "size" in self.file_info and self.file_info['size']: - self.check_data = {"size": int(self.file_info['size'])} + + m = re.search(self.LINK_PATTERN % self.info['pattern']['ID'], self.html) + if m is None: + self.error(_("LINK_PATTERN not found")) + + if "size" in self.info and self.info['size']: + self.check_data = {"size": int(self.info['size'])} + + download_url = m.group(1) self.download(download_url) else: - self.fail("Unexpected server response") + self.fail(_("Unexpected server response")) + def handlePremium(self): akey = self.account.getAccountData(self.user)['akey'] - ukey = self.file_info['ID'] + ukey = self.info['pattern']['ID'] self.logDebug("Akey: %s | Ukey: %s" % (akey, ukey)) rep = self.load("http://api.filecloud.io/api-fetch_download_url.api", post={"akey": akey, "ukey": ukey}) diff --git a/module/plugins/hoster/FilefactoryCom.py b/module/plugins/hoster/FilefactoryCom.py index 273a717b5..ada498a51 100644 --- a/module/plugins/hoster/FilefactoryCom.py +++ b/module/plugins/hoster/FilefactoryCom.py @@ -1,106 +1,90 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################ import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from urlparse import urljoin + +from module.network.RequestFactory import getURL +from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo + + +def getInfo(urls): + for url in urls: + h = getURL(url, just_header=True) + m = re.search(r'Location: (.+)\r\n', h) + if m and not re.match(m.group(1), FilefactoryCom.__pattern__): #: It's a direct link! Skipping + yield (url, 0, 3, url) + else: #: It's a standard html page + yield parseFileInfo(FilefactoryCom, url, getURL(url)) class FilefactoryCom(SimpleHoster): - __name__ = "FilefactoryCom" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?filefactory\.com/file/(?P<id>[a-zA-Z0-9]+)' - __version__ = "0.47" + __name__ = "FilefactoryCom" + __type__ = "hoster" + __version__ = "0.52" + + __pattern__ = r'https?://(?:www\.)?filefactory\.com/(file|trafficshare/\w+)/\w+' + __description__ = """Filefactory.com hoster plugin""" - __author_name__ = "stickell" - __author_mail__ = "l.stickell@yahoo.it" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + INFO_PATTERN = r'<div id="file_name"[^>]*>\s*<h2>(?P<N>[^<]+)</h2>\s*<div id="file_info">\s*(?P<S>[\d.,]+) (?P<U>[\w^_]+) uploaded' + OFFLINE_PATTERN = r'<h2>File Removed</h2>|This file is no longer available' + + LINK_PATTERN = r'"([^"]+filefactory\.com/get.+?)"' + + WAIT_PATTERN = r'<div id="countdown_clock" data-delay="(\d+)">' + PREMIUM_ONLY_PATTERN = r'>Premium Account Required' + + COOKIES = [("filefactory.com", "locale", "en_US.utf8")] - FILE_INFO_PATTERN = r'<div id="file_name"[^>]*>\s*<h2>(?P<N>[^<]+)</h2>\s*<div id="file_info">\s*(?P<S>[\d.]+) (?P<U>\w+) uploaded' - DIRECT_LINK_PATTERN = r'<a href="(https?://[^"]+)"[^>]*><i[^>]*></i> Download with FileFactory Premium</a>' - FILE_OFFLINE_PATTERN = r'<h2>File Removed</h2>' - PREMIUM_ONLY_PATTERN = r'>Premium Account Required<' def handleFree(self): - self.html = self.load(self.pyfile.url, decode=True) if "Currently only Premium Members can download files larger than" in self.html: - self.fail("File too large for free download") + self.fail(_("File too large for free download")) elif "All free download slots on this server are currently in use" in self.html: - self.retry(50, 15 * 60, "All free slots are busy") + self.retry(50, 15 * 60, _("All free slots are busy")) - m = re.search(r'data-href-direct="(http://[^"]+)"', self.html) + m = re.search(self.LINK_PATTERN, self.html) + if m is None: + self.error(_("Free download link not found")) + + dl_link = m.group(1) + + m = re.search(self.WAIT_PATTERN, self.html) if m: - t = re.search(r'<div id="countdown_clock" data-delay="(\d+)">', self.html) - if t: - t = t.group(1) - else: - self.logDebug("Unable to detect countdown duration. Guessing 60 seconds") - t = 60 - self.wait(t) - direct = m.group(1) - else: # This section could be completely useless now - # Load the page that contains the direct link - url = re.search(r"document\.location\.host \+\s*'(.+)';", self.html) - if not url: - self.parseError('Unable to detect free link') - url = 'http://www.filefactory.com' + url.group(1) - self.html = self.load(url, decode=True) - - # Free downloads wait time - waittime = re.search(r'id="startWait" value="(\d+)"', self.html) - if not waittime: - self.parseError('Unable to detect wait time') - self.wait(int(waittime.group(1))) - - # Parse the direct link and download it - direct = re.search(r'data-href-direct="(.*)" class="button', self.html) - if not direct: - self.parseError('Unable to detect free direct link') - direct = direct.group(1) - - self.logDebug('DIRECT LINK: ' + direct) - self.download(direct, disposition=True) - - check = self.checkDownload({"multiple": "You are currently downloading too many files at once.", - "error": '<div id="errorMessage">'}) + self.wait(int(m.group(1))) + + self.download(dl_link, disposition=True) + + check = self.checkDownload({'multiple': "You are currently downloading too many files at once.", + 'error': '<div id="errorMessage">'}) if check == "multiple": self.logDebug("Parallel downloads detected; waiting 15 minutes") - self.retry(wait_time=15 * 60, reason="Parallel downloads") + self.retry(wait_time=15 * 60, reason=_("Parallel downloads")) elif check == "error": - self.fail("Unknown error") + self.error(_("Unknown error")) + def handlePremium(self): header = self.load(self.pyfile.url, just_header=True) + if 'location' in header: url = header['location'].strip() if not url.startswith("http://"): - url = "http://www.filefactory.com" + url + url = urljoin("http://www.filefactory.com", url) elif 'content-disposition' in header: url = self.pyfile.url else: - self.logInfo('You could enable "Direct Downloads" on http://filefactory.com/account/') html = self.load(self.pyfile.url) - found = re.search(self.DIRECT_LINK_PATTERN, html) - if found: - url = found.group(1) + m = re.search(self.LINK_PATTERN, html) + if m: + url = m.group(1) else: - self.parseError('Unable to detect premium direct link') + self.error(_("Premium download link not found")) - self.logDebug('DIRECT PREMIUM LINK: ' + url) self.download(url, disposition=True) - - -getInfo = create_getInfo(FilefactoryCom) diff --git a/module/plugins/hoster/FilejungleCom.py b/module/plugins/hoster/FilejungleCom.py index 910798bf6..8a8aee9e2 100644 --- a/module/plugins/hoster/FilejungleCom.py +++ b/module/plugins/hoster/FilejungleCom.py @@ -1,37 +1,23 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - from module.plugins.hoster.FileserveCom import FileserveCom, checkFile from module.plugins.Plugin import chunks class FilejungleCom(FileserveCom): - __name__ = "FilejungleCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?filejungle\.com/f/(?P<id>[^/]+).*' + __name__ = "FilejungleCom" + __type__ = "hoster" __version__ = "0.51" + + __pattern__ = r'http://(?:www\.)?filejungle\.com/f/(?P<ID>[^/]+)' + __description__ = """Filejungle.com hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + - URLS = ['http://www.filejungle.com/f/', 'http://www.filejungle.com/check_links.php', - 'http://www.filejungle.com/checkReCaptcha.php'] + URLS = ["http://www.filejungle.com/f/", "http://www.filejungle.com/check_links.php", + "http://www.filejungle.com/checkReCaptcha.php"] LINKCHECK_TR = r'<li>\s*(<div class="col1">.*?)</li>' LINKCHECK_TD = r'<div class="(?:col )?col\d">(?:<[^>]*>| )*([^<]*)' diff --git a/module/plugins/hoster/FileomCom.py b/module/plugins/hoster/FileomCom.py index 9fda2353c..2b6fd34db 100644 --- a/module/plugins/hoster/FileomCom.py +++ b/module/plugins/hoster/FileomCom.py @@ -1,52 +1,35 @@ # -*- coding: utf-8 -*- -############################################################################### -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -# @author: Walter Purcaro -############################################################################### - -# Test links (random.bin): +# Test links: # http://fileom.com/gycaytyzdw3g/random.bin.html -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo + +class FileomCom(XFSHoster): + __name__ = "FileomCom" + __type__ = "hoster" + __version__ = "0.05" + + __pattern__ = r'https?://(?:www\.)?fileom\.com/\w{12}' -class FileomCom(XFileSharingPro): - __name__ = "FileomCom" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?fileom\.com/\w+' - __version__ = "0.01" __description__ = """Fileom.com hoster plugin""" - __author_name__ = "Walter Purcaro" - __author_mail__ = "vuolter@gmail.com" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - HOSTER_NAME = "fileom.com" - FILE_URL_REPLACEMENTS = [(r'/$', "")] - SH_COOKIES = [(".fileom.com", "lang", "english")] + HOSTER_DOMAIN = "fileom.com" - FILE_NAME_PATTERN = r'Filename: <span>(?P<N>.+?)<' - FILE_SIZE_PATTERN = r'File Size: <span class="size">(?P<S>[\d\.]+) (?P<U>\w+)' + NAME_PATTERN = r'Filename: <span>(?P<N>.+?)<' + SIZE_PATTERN = r'File Size: <span class="size">(?P<S>[\d.,]+) (?P<U>[\w^_]+)' - ERROR_PATTERN = r'class=["\']err["\'][^>]*>(.*?)(?:\'|</)' + LINK_PATTERN = r'var url2 = \'(.+?)\';' - DIRECT_LINK_PATTERN = r"var url2 = '(.+?)';" def setup(self): - self.resumeDownload = self.premium self.multiDL = True self.chunkLimit = 1 + self.resumeDownload = self.premium getInfo = create_getInfo(FileomCom) diff --git a/module/plugins/hoster/FilepostCom.py b/module/plugins/hoster/FilepostCom.py index 01ac76850..66c040770 100644 --- a/module/plugins/hoster/FilepostCom.py +++ b/module/plugins/hoster/FilepostCom.py @@ -1,87 +1,71 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg - - changelog: - 0.27 - 2012-08-12 - hgg - fix "global name 'js_answer' is not defined" bug - fix captcha bug #1 (failed on non-english "captcha wrong" errors) -""" - import re + from time import time -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.plugins.internal.CaptchaService import ReCaptcha from module.common.json_layer import json_loads +from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class FilepostCom(SimpleHoster): - __name__ = "FilepostCom" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?(?:filepost\.com/files|fp.io)/([^/]+).*' - __version__ = "0.27" + __name__ = "FilepostCom" + __type__ = "hoster" + __version__ = "0.31" + + __pattern__ = r'https?://(?:www\.)?(?:filepost\.com/files|fp\.io)/(?P<ID>[^/]+)' + __description__ = """Filepost.com hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - FILE_INFO_PATTERN = r'<input type="text" id="url" value=\'<a href[^>]*>(?P<N>[^>]+?) - (?P<S>[0-9\.]+ [kKMG]i?B)</a>\' class="inp_text"/>' - #FILE_INFO_PATTERN = r'<h1>(?P<N>[^<]+)</h1>\s*<div class="ul">\s*<ul>\s*<li><span>Size:</span> (?P<S>[0-9.]+) (?P<U>[kKMG])i?B</li>' - FILE_OFFLINE_PATTERN = r'class="error_msg_title"> Invalid or Deleted File. </div>|<div class="file_info file_info_deleted">' - RECAPTCHA_KEY_PATTERN = r"Captcha.init\({\s*key:\s*'([^']+)'" - FLP_TOKEN_PATTERN = r"set_store_options\({token: '([^']+)'" - def handleFree(self): - # Find token and captcha key - file_id = re.match(self.__pattern__, self.pyfile.url).group(1) + INFO_PATTERN = r'<input type="text" id="url" value=\'<a href[^>]*>(?P<N>[^>]+?) - (?P<S>[\d.,]+) (?P<U>[\w^_]+)</a>\' class="inp_text"/>' + OFFLINE_PATTERN = r'class="error_msg_title"> Invalid or Deleted File. </div>|<div class="file_info file_info_deleted">' + + PREMIUM_ONLY_PATTERN = r'members only. Please upgrade to premium|a premium membership is required to download this file' + RECAPTCHA_PATTERN = r'Captcha.init\({\s*key:\s*\'(.+?)\'' + FLP_TOKEN_PATTERN = r'set_store_options\({token: \'(.+?)\'' - found = re.search(self.FLP_TOKEN_PATTERN, self.html) - if not found: - self.parseError("Token") - flp_token = found.group(1) - found = re.search(self.RECAPTCHA_KEY_PATTERN, self.html) - if not found: - self.parseError("Captcha key") - captcha_key = found.group(1) + def handleFree(self): + m = re.search(self.FLP_TOKEN_PATTERN, self.html) + if m is None: + self.error(_("Token")) + flp_token = m.group(1) + + m = re.search(self.RECAPTCHA_PATTERN, self.html) + if m is None: + self.error(_("Captcha key")) + captcha_key = m.group(1) # Get wait time get_dict = {'SID': self.req.cj.getCookie('SID'), 'JsHttpRequest': str(int(time() * 10000)) + '-xml'} - post_dict = {'action': 'set_download', 'token': flp_token, 'code': file_id} + post_dict = {'action': 'set_download', 'token': flp_token, 'code': self.info['pattern']['ID']} wait_time = int(self.getJsonResponse(get_dict, post_dict, 'wait_time')) if wait_time > 0: self.wait(wait_time) - post_dict = {"token": flp_token, "code": file_id, "file_pass": ''} + post_dict = {"token": flp_token, "code": self.info['pattern']['ID'], "file_pass": ''} if 'var is_pass_exists = true;' in self.html: - # Solve password - for file_pass in self.getPassword().splitlines(): + # Solve password + password = self.getPassword() + + if password: + self.logInfo(_("Password protected link, trying ") + file_pass) + get_dict['JsHttpRequest'] = str(int(time() * 10000)) + '-xml' post_dict['file_pass'] = file_pass - self.logInfo("Password protected link, trying " + file_pass) - download_url = self.getJsonResponse(get_dict, post_dict, 'link') - if download_url: - break + self.link = self.getJsonResponse(get_dict, post_dict, 'link') + if not self.link: + self.fail(_("Incorrect password")) else: - self.fail("No or incorrect password") + self.fail(_("No password found")) else: # Solve recaptcha @@ -90,10 +74,10 @@ class FilepostCom(SimpleHoster): for i in xrange(5): get_dict['JsHttpRequest'] = str(int(time() * 10000)) + '-xml' if i: - post_dict["recaptcha_challenge_field"], post_dict["recaptcha_response_field"] = recaptcha.challenge( + post_dict['recaptcha_challenge_field'], post_dict['recaptcha_response_field'] = recaptcha.challenge( captcha_key) self.logDebug(u"RECAPTCHA: %s : %s : %s" % ( - captcha_key, post_dict["recaptcha_challenge_field"], post_dict["recaptcha_response_field"])) + captcha_key, post_dict['recaptcha_challenge_field'], post_dict['recaptcha_response_field'])) download_url = self.getJsonResponse(get_dict, post_dict, 'link') if download_url: @@ -104,43 +88,46 @@ class FilepostCom(SimpleHoster): self.invalidCaptcha() else: - self.fail("Invalid captcha") + self.fail(_("Invalid captcha")) # Download self.download(download_url) + def getJsonResponse(self, get_dict, post_dict, field): - json_response = json_loads(self.load('https://filepost.com/files/get/', get=get_dict, post=post_dict)) - self.logDebug(json_response) + res = json_loads(self.load('https://filepost.com/files/get/', get=get_dict, post=post_dict)) - if not 'js' in json_response: - self.parseError('JSON %s 1' % field) + self.logDebug(res) - # i changed js_answer to json_response['js'] since js_answer is nowhere set. + if not 'js' in res: + self.error(_("JSON %s 1") % field) + + # i changed js_answer to res['js'] since js_answer is nowhere set. # i don't know the JSON-HTTP specs in detail, but the previous author - # accessed json_response['js']['error'] as well as js_answer['error']. + # accessed res['js']['error'] as well as js_answer['error']. # see the two lines commented out with "# ~?". - if 'error' in json_response['js']: - if json_response['js']['error'] == 'download_delay': - self.retry(wait_time=json_response['js']['params']['next_download']) + if 'error' in res['js']: + + if res['js']['error'] == 'download_delay': + self.retry(wait_time=res['js']['params']['next_download']) # ~? self.retry(wait_time=js_answer['params']['next_download']) - elif 'Wrong file password' in json_response['js']['error']: - return None - elif 'You entered a wrong CAPTCHA code' in json_response['js']['error']: - return None - elif 'CAPTCHA Code nicht korrekt' in json_response['js']['error']: + + elif ('Wrong file password' in res['js']['error'] + or 'You entered a wrong CAPTCHA code' in res['js']['error'] + or 'CAPTCHA Code nicht korrekt' in res['js']['error']): return None - elif 'CAPTCHA' in json_response['js']['error']: - self.logDebug('error response is unknown, but mentions CAPTCHA -> return None') + + elif 'CAPTCHA' in res['js']['error']: + self.logDebug("Error response is unknown, but mentions CAPTCHA") return None + else: - self.fail(json_response['js']['error']) - # ~? self.fail(js_answer['error']) + self.fail(res['js']['error']) - if not 'answer' in json_response['js'] or not field in json_response['js']['answer']: - self.parseError('JSON %s 2' % field) + if not 'answer' in res['js'] or not field in res['js']['answer']: + self.error(_("JSON %s 2") % field) - return json_response['js']['answer'][field] + return res['js']['answer'][field] getInfo = create_getInfo(FilepostCom) diff --git a/module/plugins/hoster/FilepupNet.py b/module/plugins/hoster/FilepupNet.py new file mode 100644 index 000000000..cc3e86bc9 --- /dev/null +++ b/module/plugins/hoster/FilepupNet.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# +# Test links: +# http://www.filepup.net/files/k5w4ZVoF1410184283.html +# http://www.filepup.net/files/R4GBq9XH1410186553.html + +import re + +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + + +class FilepupNet(SimpleHoster): + __name__ = "FilepupNet" + __type__ = "hoster" + __version__ = "0.02" + + __pattern__ = r'http://(?:www\.)?filepup\.net/files/\w+' + + __description__ = """Filepup.net hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zapp-brannigan", "fuerst.reinje@web.de"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + NAME_PATTERN = r'>(?P<N>.+?)</h1>' + SIZE_PATTERN = r'class="fa fa-archive"></i> \((?P<S>[\d.,]+) (?P<U>[\w^_]+)' + + OFFLINE_PATTERN = r'>This file has been deleted' + + LINK_PATTERN = r'(http://www\.filepup\.net/get/.+?)\'' + + + def setup(self): + self.multiDL = False + self.chunkLimit = 1 + + + def handleFree(self): + m = re.search(self.LINK_PATTERN, self.html) + if m is None: + self.error(_("Download link not found")) + + dl_link = m.group(1) + self.download(dl_link, post={'task': "download"}) + + check = self.checkDownload({'html': re.compile("html")}) + if check == "html": + self.error(_("Downloaded file is an html page")) + + +getInfo = create_getInfo(FilepupNet) diff --git a/module/plugins/hoster/FilerNet.py b/module/plugins/hoster/FilerNet.py index d39666922..2a38ac470 100644 --- a/module/plugins/hoster/FilerNet.py +++ b/module/plugins/hoster/FilerNet.py @@ -1,119 +1,82 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################ - -# Test links (random.bin): +# +# Test links: # http://filer.net/get/ivgf5ztw53et3ogd # http://filer.net/get/hgo14gzcng3scbvv import pycurl import re + from urlparse import urljoin -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class FilerNet(SimpleHoster): - __name__ = "FilerNet" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?filer\.net/get/(\w+)' - __version__ = "0.03" + __name__ = "FilerNet" + __type__ = "hoster" + __version__ = "0.12" + + __pattern__ = r'https?://(?:www\.)?filer\.net/get/\w+' + __description__ = """Filer.net hoster plugin""" - __author_name__ = "stickell" - __author_mail__ = "l.stickell@yahoo.it" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com")] - FILE_INFO_PATTERN = r'<h1 class="page-header">Free Download (?P<N>\S+) <small>(?P<S>[\w.]+) (?P<U>\w+)</small></h1>' - FILE_OFFLINE_PATTERN = r'Nicht gefunden' - RECAPTCHA_KEY = '6LcFctISAAAAAAgaeHgyqhNecGJJRnxV1m_vAz3V' - DIRECT_LINK_PATTERN = r'href="([^"]+)">Get download</a>' - def process(self, pyfile): - if self.premium and (not self.SH_CHECK_TRAFFIC or self.checkTrafficLeft()): - self.handlePremium() - else: - self.handleFree() + INFO_PATTERN = r'<h1 class="page-header">Free Download (?P<N>\S+) <small>(?P<S>[\w.]+) (?P<U>[\w^_]+)</small></h1>' + OFFLINE_PATTERN = r'Nicht gefunden' - def handleFree(self): - self.req.setOption("timeout", 120) - self.html = self.load(self.pyfile.url, decode=not self.SH_BROKEN_ENCODING, cookies=self.SH_COOKIES) + LINK_FREE_PATTERN = LINK_PREMIUM_PATTERN = r'href="([^"]+)">Get download</a>' + + def checkErrors(self): # Wait between downloads m = re.search(r'musst du <span id="time">(\d+)</span> Sekunden warten', self.html) if m: - waittime = int(m.group(1)) - self.retry(3, waittime, "Wait between free downloads") + errmsg = self.info['error'] = _("Wait between free downloads") + self.retry(wait_time=int(m.group(1)), reason=errmsg) - self.getFileInfo() + self.info.pop('error', None) - self.html = self.load(self.pyfile.url, decode=True) - inputs = self.parseHtmlForm(input_names='token')[1] + def handleFree(self): + inputs = self.parseHtmlForm(input_names={'token': re.compile(r'.+')})[1] if 'token' not in inputs: - self.parseError('Unable to detect token') - token = inputs['token'] - self.logDebug('Token: ' + token) + self.error(_("Unable to detect token")) - self.html = self.load(self.pyfile.url, post={'token': token}, decode=True) + self.html = self.load(self.pyfile.url, post={'token': inputs['token']}, decode=True) - inputs = self.parseHtmlForm(input_names='hash')[1] + inputs = self.parseHtmlForm(input_names={'hash': re.compile(r'.+')})[1] if 'hash' not in inputs: - self.parseError('Unable to detect hash') - hash_data = inputs['hash'] - self.logDebug('Hash: ' + hash_data) + self.error(_("Unable to detect hash")) - downloadURL = '' recaptcha = ReCaptcha(self) - for _ in xrange(5): - challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY) - post_data = {'recaptcha_challenge_field': challenge, - 'recaptcha_response_field': response, - 'hash': hash_data} - # Workaround for 0.4.9 just_header issue. In 0.5 clean the code using just_header + for _i in xrange(5): + challenge, response = recaptcha.challenge() + + #@NOTE: Work-around for v0.4.9 just_header issue + #@TODO: Check for v0.4.10 self.req.http.c.setopt(pycurl.FOLLOWLOCATION, 0) - self.load(self.pyfile.url, post=post_data) + self.load(self.pyfile.url, post={'recaptcha_challenge_field': challenge, + 'recaptcha_response_field' : response, + 'hash' : inputs['hash']}) self.req.http.c.setopt(pycurl.FOLLOWLOCATION, 1) if 'location' in self.req.http.header.lower(): - location = re.search(r'location: (\S+)', self.req.http.header, re.I).group(1) - downloadURL = urljoin('http://filer.net', location) + self.link = re.search(r'location: (\S+)', self.req.http.header, re.I).group(1) self.correctCaptcha() break else: - self.logInfo('Wrong captcha') self.invalidCaptcha() - if not downloadURL: - self.fail("No Download url retrieved/all captcha attempts failed") - - self.download(downloadURL, disposition=True) - - def handlePremium(self): - header = self.load(self.pyfile.url, just_header=True) - if 'location' in header: # Direct Download ON - dl = self.pyfile.url - else: # Direct Download OFF - html = self.load(self.pyfile.url) - m = re.search(self.DIRECT_LINK_PATTERN, html) - if not m: - self.parseError("Unable to detect direct link, try to enable 'Direct download' in your user settings") - dl = 'http://filer.net' + m.group(1) - self.logDebug('Direct link: ' + dl) - self.download(dl, disposition=True) + def downloadLink(self, link): + if link and isinstance(link, basestring): + self.download(urljoin("http://filer.net/", link), disposition=True) getInfo = create_getInfo(FilerNet) diff --git a/module/plugins/hoster/FilerioCom.py b/module/plugins/hoster/FilerioCom.py index a0c67509f..db81f5b16 100644 --- a/module/plugins/hoster/FilerioCom.py +++ b/module/plugins/hoster/FilerioCom.py @@ -1,24 +1,25 @@ # -*- coding: utf-8 -*- -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo -class FilerioCom(XFileSharingPro): - __name__ = "FilerioCom" - __type__ = "hoster" +class FilerioCom(XFSHoster): + __name__ = "FilerioCom" + __type__ = "hoster" + __version__ = "0.07" + __pattern__ = r'http://(?:www\.)?(filerio\.(in|com)|filekeen\.com)/\w{12}' - __version__ = "0.02" + __description__ = """FileRio.in hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + - HOSTER_NAME = "filerio.in" + HOSTER_DOMAIN = "filerio.in" - FILE_OFFLINE_PATTERN = '<b>"File Not Found"</b>|File has been removed due to Copyright Claim' - FILE_URL_REPLACEMENTS = [(r'http://.*?/', 'http://filerio.in/')] + URL_REPLACEMENTS = [(r'filekeen\.com', "filerio.in")] - def setup(self): - self.resumeDownload = self.multiDL = self.premium + OFFLINE_PATTERN = r'>"File Not Found|File has been removed' getInfo = create_getInfo(FilerioCom) diff --git a/module/plugins/hoster/FilesMailRu.py b/module/plugins/hoster/FilesMailRu.py index 34998726d..9b39d818f 100644 --- a/module/plugins/hoster/FilesMailRu.py +++ b/module/plugins/hoster/FilesMailRu.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- import re -from module.plugins.Hoster import Hoster + from module.network.RequestFactory import getURL +from module.plugins.Hoster import Hoster from module.plugins.Plugin import chunks @@ -10,15 +11,15 @@ def getInfo(urls): result = [] for chunk in chunks(urls, 10): for url in chunk: - src = getURL(url) - if r'<div class="errorMessage mb10">' in src: + html = getURL(url) + if r'<div class="errorMessage mb10">' in html: result.append((url, 0, 1, url)) - elif r'Page cannot be displayed' in src: + elif r'Page cannot be displayed' in html: result.append((url, 0, 1, url)) else: try: url_pattern = '<a href="(.+?)" onclick="return Act\(this\, \'dlink\'\, event\)">(.+?)</a>' - file_name = re.search(url_pattern, src).group(0).split(', event)">')[1].split('</a>')[0] + file_name = re.search(url_pattern, html).group(0).split(', event)">')[1].split('</a>')[0] result.append((file_name, 0, 2, url)) except: pass @@ -29,18 +30,22 @@ def getInfo(urls): class FilesMailRu(Hoster): - __name__ = "FilesMailRu" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?files\.mail\.ru/.*' + __name__ = "FilesMailRu" + __type__ = "hoster" __version__ = "0.31" + + __pattern__ = r'http://(?:www\.)?files\.mail\.ru/.+' + __description__ = """Files.mail.ru hoster plugin""" - __author_name__ = "oZiRiz" - __author_mail__ = "ich@oziriz.de" + __license__ = "GPLv3" + __authors__ = [("oZiRiz", "ich@oziriz.de")] + def setup(self): if not self.account: self.multiDL = False + def process(self, pyfile): self.html = self.load(pyfile.url) self.url_pattern = '<a href="(.+?)" onclick="return Act\(this\, \'dlink\'\, event\)">(.+?)</a>' @@ -64,22 +69,23 @@ class FilesMailRu(Hoster): self.download(self.getFileUrl()) self.myPostProcess() + def prepare(self): """You have to wait some seconds. Otherwise you will get a 40Byte HTML Page instead of the file you expected""" self.setWait(10) self.wait() return True + def getFileUrl(self): """gives you the URL to the file. Extracted from the Files.mail.ru HTML-page stored in self.html""" - file_url = re.search(self.url_pattern, self.html).group(0).split('<a href="')[1].split('" onclick="return Act')[ - 0] - return file_url + return re.search(self.url_pattern, self.html).group(0).split('<a href="')[1].split('" onclick="return Act')[0] + def getFileName(self): """gives you the Name for each file. Also extracted from the HTML-Page""" - file_name = re.search(self.url_pattern, self.html).group(0).split(', event)">')[1].split('</a>')[0] - return file_name + return re.search(self.url_pattern, self.html).group(0).split(', event)">')[1].split('</a>')[0] + def myPostProcess(self): # searches the file for HTMl-Code. Sometimes the Redirect @@ -87,7 +93,7 @@ class FilesMailRu(Hoster): # HTML file and the Download is marked as "finished" # then the download will be restarted. It's only bad for these # who want download a HTML-File (it's one in a million ;-) ) - # + # # The maximum UploadSize allowed on files.mail.ru at the moment is 100MB # so i set it to check every download because sometimes there are downloads # that contain the HTML-Text and 60MB ZEROs after that in a xyzfile.part1.rar file diff --git a/module/plugins/hoster/FileserveCom.py b/module/plugins/hoster/FileserveCom.py index 4c678c1b1..52a071b52 100644 --- a/module/plugins/hoster/FileserveCom.py +++ b/module/plugins/hoster/FileserveCom.py @@ -1,34 +1,21 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. -""" - import re -from module.plugins.Hoster import Hoster + +from module.common.json_layer import json_loads from module.network.RequestFactory import getURL +from module.plugins.Hoster import Hoster +from module.plugins.Plugin import chunks from module.plugins.internal.CaptchaService import ReCaptcha -from module.common.json_layer import json_loads +from module.plugins.internal.SimpleHoster import secondsToMidnight from module.utils import parseFileSize -from module.plugins.Plugin import chunks def checkFile(plugin, urls): html = getURL(plugin.URLS[1], post={"urls": "\n".join(urls)}, decode=True) file_info = [] - for li in re.finditer(plugin.LINKCHECK_TR, html, re.DOTALL): + for li in re.finditer(plugin.LINKCHECK_TR, html, re.S): try: cols = re.findall(plugin.LINKCHECK_TD, li.group(1)) if cols: @@ -44,34 +31,40 @@ def checkFile(plugin, urls): class FileserveCom(Hoster): - __name__ = "FileserveCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?fileserve\.com/file/(?P<id>[^/]+).*' - __version__ = "0.51" + __name__ = "FileserveCom" + __type__ = "hoster" + __version__ = "0.53" + + __pattern__ = r'http://(?:www\.)?fileserve\.com/file/(?P<ID>[^/]+)' + __description__ = """Fileserve.com hoster plugin""" - __author_name__ = ("jeix", "mkaay", "Paul King", "zoidberg") - __author_mail__ = ("jeix@hasnomail.de", "mkaay@mkaay.de", "", "zoidberg@mujmail.cz") + __license__ = "GPLv3" + __authors__ = [("jeix", "jeix@hasnomail.de"), + ("mkaay", "mkaay@mkaay.de"), + ("Paul King", None), + ("zoidberg", "zoidberg@mujmail.cz")] + - URLS = ['http://www.fileserve.com/file/', 'http://www.fileserve.com/link-checker.php', - 'http://www.fileserve.com/checkReCaptcha.php'] - LINKCHECK_TR = r'<tr>\s*(<td>http://www.fileserve\.com/file/.*?)</tr>' + URLS = ["http://www.fileserve.com/file/", "http://www.fileserve.com/link-checker.php", + "http://www.fileserve.com/checkReCaptcha.php"] + LINKCHECK_TR = r'<tr>\s*(<td>http://www\.fileserve\.com/file/.*?)</tr>' LINKCHECK_TD = r'<td>(?:<[^>]*>| )*([^<]*)' - CAPTCHA_KEY_PATTERN = r"var reCAPTCHA_publickey='(?P<key>[^']+)'" + CAPTCHA_KEY_PATTERN = r'var reCAPTCHA_publickey=\'(.+?)\'' LONG_WAIT_PATTERN = r'<li class="title">You need to wait (\d+) (\w+) to start another download\.</li>' - LINK_EXPIRED_PATTERN = "Your download link has expired" - DAILY_LIMIT_PATTERN = "Your daily download limit has been reached" - NOT_LOGGED_IN_PATTERN = '<form (name="loginDialogBoxForm"|id="login_form")|<li><a href="/login.php">Login</a></li>' + LINK_EXPIRED_PATTERN = r'Your download link has expired' + DAILY_LIMIT_PATTERN = r'Your daily download limit has been reached' + NOT_LOGGED_IN_PATTERN = r'<form (name="loginDialogBoxForm"|id="login_form")|<li><a href="/login\.php">Login</a></li>' - # shares code with FilejungleCom and UploadstationCom def setup(self): self.resumeDownload = self.multiDL = self.premium + self.file_id = re.match(self.__pattern__, self.pyfile.url).group('ID') + self.url = "%s%s" % (self.URLS[0], self.file_id) - self.file_id = re.match(self.__pattern__, self.pyfile.url).group('id') - self.url = "%s%s" % (self.URLS[0], self.file_id) self.logDebug("File ID: %s URL: %s" % (self.file_id, self.url)) + def process(self, pyfile): pyfile.name, pyfile.size, status, self.url = checkFile(self, [self.url])[0] if status != 2: @@ -83,6 +76,7 @@ class FileserveCom(Hoster): else: self.handleFree() + def handleFree(self): self.html = self.load(self.url) action = self.load(self.url, post={"checkDownload": "check"}, decode=True) @@ -90,34 +84,34 @@ class FileserveCom(Hoster): self.logDebug(action) if "fail" in action: - if action["fail"] == "timeLimit": + if action['fail'] == "timeLimit": self.html = self.load(self.url, post={"checkDownload": "showError", "errorType": "timeLimit"}, decode=True) self.doLongWait(re.search(self.LONG_WAIT_PATTERN, self.html)) - elif action["fail"] == "parallelDownload": - self.logWarning(_("Parallel download error, now waiting 60s.")) - self.retry(wait_time=60, reason="parallelDownload") + elif action['fail'] == "parallelDownload": + self.logWarning(_("Parallel download error, now waiting 60s")) + self.retry(wait_time=60, reason=_("parallelDownload")) else: - self.fail("Download check returned %s" % action["fail"]) + self.fail(_("Download check returned: %s") % action['fail']) elif "success" in action: - if action["success"] == "showCaptcha": + if action['success'] == "showCaptcha": self.doCaptcha() self.doTimmer() - elif action["success"] == "showTimmer": + elif action['success'] == "showTimmer": self.doTimmer() else: - self.fail("Unknown server response") + self.error(_("Unknown server response")) # show download link - response = self.load(self.url, post={"downloadLink": "show"}, decode=True) - self.logDebug("show downloadLink response : %s" % response) - if "fail" in response: - self.fail("Couldn't retrieve download url") + res = self.load(self.url, post={"downloadLink": "show"}, decode=True) + self.logDebug("Show downloadLink response: %s" % res) + if "fail" in res: + self.error(_("Couldn't retrieve download url")) # this may either download our file or forward us to an error page self.download(self.url, post={"download": "normal"}) @@ -133,50 +127,51 @@ class FileserveCom(Hoster): elif check == "wait": self.doLongWait(self.lastCheck) elif check == "limit": - #download limited reached for today (not a exact time known) - self.setWait(3 * 60 * 60, True) # wait 3 hours #TO-DO: resolve waittime using UnrestrictLi's secondsToMidnight + self.logWarning(_("Download limited reached for today")) + self.setWait(secondsToMidnight(gmt=2), True) self.wait() self.retry() self.thread.m.reconnecting.wait(3) # Ease issue with later downloads appearing to be in parallel + def doTimmer(self): - response = self.load(self.url, post={"downloadLink": "wait"}, decode=True) - self.logDebug("wait response : %s" % response[:80]) + res = self.load(self.url, post={"downloadLink": "wait"}, decode=True) + self.logDebug("Wait response: %s" % res[:80]) - if "fail" in response: - self.fail("Failed getting wait time") + if "fail" in res: + self.fail(_("Failed getting wait time")) if self.__name__ == "FilejungleCom": - found = re.search(r'"waitTime":(\d+)', response) - if not found: - self.fail("Cannot get wait time") - wait_time = int(found.group(1)) + m = re.search(r'"waitTime":(\d+)', res) + if m is None: + self.fail(_("Cannot get wait time")) + wait_time = int(m.group(1)) else: - wait_time = int(response) + 3 + wait_time = int(res) + 3 self.setWait(wait_time) self.wait() + def doCaptcha(self): - captcha_key = re.search(self.CAPTCHA_KEY_PATTERN, self.html).group("key") + captcha_key = re.search(self.CAPTCHA_KEY_PATTERN, self.html).group(1) recaptcha = ReCaptcha(self) - for _ in xrange(5): - challenge, code = recaptcha.challenge(captcha_key) - - response = json_loads(self.load(self.URLS[2], - post={'recaptcha_challenge_field': challenge, - 'recaptcha_response_field': code, - 'recaptcha_shortencode_field': self.file_id})) - self.logDebug("reCaptcha response : %s" % response) - if not response["success"]: + for _i in xrange(5): + challenge, response = recaptcha.challenge(captcha_key) + res = json_loads(self.load(self.URLS[2], + post={'recaptcha_challenge_field' : challenge, + 'recaptcha_response_field' : response, + 'recaptcha_shortencode_field': self.file_id})) + if not res['success']: self.invalidCaptcha() else: self.correctCaptcha() break else: - self.fail("Invalid captcha") + self.fail(_("Invalid captcha")) + def doLongWait(self, m): wait_time = (int(m.group(1)) * {'seconds': 1, 'minutes': 60, 'hours': 3600}[m.group(2)]) if m else 12 * 60 @@ -184,27 +179,28 @@ class FileserveCom(Hoster): self.wait() self.retry() + def handlePremium(self): premium_url = None if self.__name__ == "FileserveCom": #try api download - response = self.load("http://app.fileserve.com/api/download/premium/", - post={"username": self.user, - "password": self.account.getAccountData(self.user)["password"], - "shorten": self.file_id}, - decode=True) - if response: - response = json_loads(response) - if response['error_code'] == "302": - premium_url = response['next'] - elif response['error_code'] in ["305", "500"]: + res = self.load("http://app.fileserve.com/api/download/premium/", + post={"username": self.user, + "password": self.account.getAccountData(self.user)['password'], + "shorten": self.file_id}, + decode=True) + if res: + res = json_loads(res) + if res['error_code'] == "302": + premium_url = res['next'] + elif res['error_code'] in ["305", "500"]: self.tempOffline() - elif response['error_code'] in ["403", "605"]: + elif res['error_code'] in ["403", "605"]: self.resetAccount() - elif response['error_code'] in ["606", "607", "608"]: + elif res['error_code'] in ["606", "607", "608"]: self.offline() else: - self.logError(response['error_code'], response['error_message']) + self.logError(res['error_code'], res['error_message']) self.download(premium_url or self.pyfile.url) @@ -213,7 +209,7 @@ class FileserveCom(Hoster): if check == "login": self.account.relogin(self.user) - self.retry(reason=_("Not logged in.")) + self.retry(reason=_("Not logged in")) def getInfo(urls): diff --git a/module/plugins/hoster/FileshareInUa.py b/module/plugins/hoster/FileshareInUa.py index db2b1a998..08e10dccb 100644 --- a/module/plugins/hoster/FileshareInUa.py +++ b/module/plugins/hoster/FileshareInUa.py @@ -1,79 +1,18 @@ # -*- coding: utf-8 -*- -import re -from module.plugins.Hoster import Hoster -from module.network.RequestFactory import getURL -from module.utils import parseFileSize +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo -class FileshareInUa(Hoster): - __name__ = "FileshareInUa" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?fileshare.in.ua/[A-Za-z0-9]+' - __version__ = "0.01" - __description__ = """Fileshare.in.ua hoster plugin""" - __author_name__ = "fwannmacher" - __author_mail__ = "felipe@warhammerproject.com" - - PATTERN_FILENAME = r'<h3 class="b-filename">(.*?)</h3>' - PATTERN_FILESIZE = r'<b class="b-filesize">(.*?)</b>' - PATTERN_OFFLINE = "This file doesn't exist, or has been removed." - - def setup(self): - self.resumeDownload = self.multiDL = True - - def process(self, pyfile): - self.pyfile = pyfile - self.html = self.load(pyfile.url, decode=True) - - if not self._checkOnline(): - self.offline() - - pyfile.name = self._getName() - - self.link = self._getLink() - - if not self.link.startswith('http://'): - self.link = "http://fileshare.in.ua" + self.link - - self.download(self.link) +class FileshareInUa(DeadHoster): + __name__ = "FileshareInUa" + __type__ = "hoster" + __version__ = "0.02" - def _checkOnline(self): - if re.search(self.PATTERN_OFFLINE, self.html): - return False - else: - return True + __pattern__ = r'https?://(?:www\.)?fileshare\.in\.ua/\w{7}' - def _getName(self): - name = re.search(self.PATTERN_FILENAME, self.html) - if name is None: - self.fail("%s: Plugin broken." % self.__name__) - - return name.group(1) - - def _getLink(self): - return re.search("<a href=\"(/get/.+)\" class=\"b-button m-blue m-big\" >", self.html).group(1) - - -def getInfo(urls): - result = [] - - for url in urls: - html = getURL(url) - - if re.search(FileshareInUa.PATTERN_OFFLINE, html): - result.append((url, 0, 1, url)) - else: - name = re.search(FileshareInUa.PATTERN_FILENAME, html) - - if name is None: - result.append((url, 0, 1, url)) - continue - - name = name.group(1) - size = re.search(FileshareInUa.PATTERN_FILESIZE, html) - size = parseFileSize(size.group(1)) + __description__ = """Fileshare.in.ua hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("fwannmacher", "felipe@warhammerproject.com")] - result.append((name, size, 3, url)) - yield result +getInfo = create_getInfo(FileshareInUa) diff --git a/module/plugins/hoster/FilesonicCom.py b/module/plugins/hoster/FilesonicCom.py new file mode 100644 index 000000000..8bfa0fa2e --- /dev/null +++ b/module/plugins/hoster/FilesonicCom.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo + + +class FilesonicCom(DeadHoster): + __name__ = "FilesonicCom" + __type__ = "hoster" + __version__ = "0.35" + + __pattern__ = r'http://(?:www\.)?filesonic\.com/file/\w+' + + __description__ = """Filesonic.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("jeix", "jeix@hasnomail.de"), + ("paulking", None)] + + +getInfo = create_getInfo(FilesonicCom) diff --git a/module/plugins/hoster/FilezyNet.py b/module/plugins/hoster/FilezyNet.py index cd0902ab3..4197a2858 100644 --- a/module/plugins/hoster/FilezyNet.py +++ b/module/plugins/hoster/FilezyNet.py @@ -1,36 +1,18 @@ # -*- coding: utf-8 -*- -import re -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo -class FilezyNet(XFileSharingPro): - __name__ = "FilezyNet" - __type__ = "hoster" - __version__ = "0.1" - __pattern__ = r'http://(?:www\.)?filezy.net/.*/.*.html' - __description__ = """Filezy.net hoster plugin""" - - HOSTER_NAME = "filezy.net" - - FILE_SIZE_PATTERN = r'<span class="plansize">(?P<S>[0-9.]+) (?P<U>[kKMG])i?B</span>' - WAIT_PATTERN = r'<div id="countdown_str" class="seconds">\n<!--Wait--> <span id=".*?">(\d+)</span>' - DOWNLOAD_JS_PATTERN = r"<script type='text/javascript'>eval(.*)" +class FilezyNet(DeadHoster): + __name__ = "FilezyNet" + __type__ = "hoster" + __version__ = "0.20" - def setup(self): - self.resumeDownload = True - self.multiDL = self.premium + __pattern__ = r'http://(?:www\.)?filezy\.net/\w{12}' - def getDownloadLink(self): - self.logDebug("Getting download link") - - data = self.getPostParameters() - self.html = self.load(self.pyfile.url, post=data, ref=True, decode=True) - - obfuscated_js = re.search(self.DOWNLOAD_JS_PATTERN, self.html) - dl_file_now = self.js.eval(obfuscated_js.group(1)) - link = re.search(self.DIRECT_LINK_PATTERN, dl_file_now) - return link.group(1) + __description__ = """Filezy.net hoster plugin""" + __license__ = "GPLv3" + __authors__ = [] getInfo = create_getInfo(FilezyNet) diff --git a/module/plugins/hoster/FiredriveCom.py b/module/plugins/hoster/FiredriveCom.py new file mode 100644 index 000000000..0e3a4e847 --- /dev/null +++ b/module/plugins/hoster/FiredriveCom.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo + + +class FiredriveCom(DeadHoster): + __name__ = "FiredriveCom" + __type__ = "hoster" + __version__ = "0.05" + + __pattern__ = r'https?://(?:www\.)?(firedrive|putlocker)\.com/(mobile/)?(file|embed)/(?P<ID>\w+)' + + __description__ = """Firedrive.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + +getInfo = create_getInfo(FiredriveCom) diff --git a/module/plugins/hoster/FlyFilesNet.py b/module/plugins/hoster/FlyFilesNet.py index 3e0466a41..49705958d 100644 --- a/module/plugins/hoster/FlyFilesNet.py +++ b/module/plugins/hoster/FlyFilesNet.py @@ -1,24 +1,31 @@ # -*- coding: utf-8 -*- import re -import urllib -from module.plugins.internal.SimpleHoster import SimpleHoster +from urllib import unquote + from module.network.RequestFactory import getURL +from module.plugins.internal.SimpleHoster import SimpleHoster class FlyFilesNet(SimpleHoster): - __name__ = "FlyFilesNet" - __version__ = "0.1" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?flyfiles\.net/.*' + __name__ = "FlyFilesNet" + __type__ = "hoster" + __version__ = "0.10" + + __pattern__ = r'http://(?:www\.)?flyfiles\.net/.+' + + __description__ = """FlyFiles.net hoster plugin""" + __license__ = "GPLv3" + __authors__ = [] SESSION_PATTERN = r'flyfiles\.net/(.*)/.*' - FILE_NAME_PATTERN = r'flyfiles\.net/.*/(.*)' + NAME_PATTERN = r'flyfiles\.net/.*/(.*)' + def process(self, pyfile): - pyfile.name = re.search(self.FILE_NAME_PATTERN, pyfile.url).group(1) - pyfile.name = urllib.unquote_plus(pyfile.name) + name = re.search(self.NAME_PATTERN, pyfile.url).group(1) + pyfile.name = unquote_plus(name) session = re.search(self.SESSION_PATTERN, pyfile.url).group(1) @@ -29,11 +36,10 @@ class FlyFilesNet(SimpleHoster): self.logDebug("Parsed URL: %s" % parsed_url) if parsed_url == '#downlink|' or parsed_url == "#downlink|#": - self.logWarning("Could not get the download URL. Please wait 10 minutes.") + self.logWarning(_("Could not get the download URL. Please wait 10 minutes")) self.wait(10 * 60, True) self.retry() download_url = parsed_url.replace('#downlink|', '') - self.logDebug("Download URL: %s" % download_url) self.download(download_url) diff --git a/module/plugins/hoster/FourSharedCom.py b/module/plugins/hoster/FourSharedCom.py index 9c7752fe1..0406df0c4 100644 --- a/module/plugins/hoster/FourSharedCom.py +++ b/module/plugins/hoster/FourSharedCom.py @@ -6,45 +6,51 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class FourSharedCom(SimpleHoster): - __name__ = "FourSharedCom" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?4shared(\-china)?\.com/(account/)?(download|get|file|document|photo|video|audio|mp3|office|rar|zip|archive|music)/.+?/.*' - __version__ = "0.29" + __name__ = "FourSharedCom" + __type__ = "hoster" + __version__ = "0.30" + + __pattern__ = r'https?://(?:www\.)?4shared(\-china)?\.com/(account/)?(download|get|file|document|photo|video|audio|mp3|office|rar|zip|archive|music)/.+' + __description__ = """4Shared.com hoster plugin""" - __author_name__ = ("jeix", "zoidberg") - __author_mail__ = ("jeix@hasnomail.de", "zoidberg@mujmail.cz") + __license__ = "GPLv3" + __authors__ = [("jeix", "jeix@hasnomail.de"), + ("zoidberg", "zoidberg@mujmail.cz")] + - FILE_NAME_PATTERN = r'<meta name="title" content="(?P<N>.+?)"' - FILE_SIZE_PATTERN = '<span title="Size: (?P<S>[0-9,.]+) (?P<U>[kKMG])i?B">' - FILE_OFFLINE_PATTERN = 'The file link that you requested is not valid\.|This file was deleted.' - FILE_NAME_REPLACEMENTS = [(r"&#(\d+).", lambda m: unichr(int(m.group(1))))] - FILE_SIZE_REPLACEMENTS = [(",", "")] + NAME_PATTERN = r'<meta name="title" content="(?P<N>.+?)"' + SIZE_PATTERN = r'<span title="Size: (?P<S>[\d.,]+) (?P<U>[\w^_]+)">' + OFFLINE_PATTERN = r'The file link that you requested is not valid\.|This file was deleted.' + + NAME_REPLACEMENTS = [(r"&#(\d+).", lambda m: unichr(int(m.group(1))))] + SIZE_REPLACEMENTS = [(",", "")] - DOWNLOAD_BUTTON_PATTERN = 'id="btnLink" href="(.*?)"' - FID_PATTERN = 'name="d3fid" value="(.*?)"' DOWNLOAD_URL_PATTERN = r'name="d3link" value="(.*?)"' + DOWNLOAD_BUTTON_PATTERN = r'id="btnLink" href="(.*?)"' + FID_PATTERN = r'name="d3fid" value="(.*?)"' + def handleFree(self): if not self.account: - self.fail("User not logged in") + self.fail(_("User not logged in")) - found = re.search(self.DOWNLOAD_BUTTON_PATTERN, self.html) - if found: - link = found.group(1) + m = re.search(self.DOWNLOAD_BUTTON_PATTERN, self.html) + if m: + link = m.group(1) else: link = re.sub(r'/(download|get|file|document|photo|video|audio)/', r'/get/', self.pyfile.url) self.html = self.load(link) - found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) - if not found: - self.parseError('Download link') - link = found.group(1) + m = re.search(self.DOWNLOAD_URL_PATTERN, self.html) + if m is None: + self.error(_("Download link")) + link = m.group(1) try: - found = re.search(self.FID_PATTERN, self.html) - response = self.load('http://www.4shared.com/web/d2/getFreeDownloadLimitInfo?fileId=%s' % found.group(1)) - self.logDebug(response) + m = re.search(self.FID_PATTERN, self.html) + res = self.load('http://www.4shared.com/web/d2/getFreeDownloadLimitInfo?fileId=%s' % m.group(1)) + self.logDebug(res) except: pass diff --git a/module/plugins/hoster/FreakshareCom.py b/module/plugins/hoster/FreakshareCom.py index ad9abeb96..2238f07ef 100644 --- a/module/plugins/hoster/FreakshareCom.py +++ b/module/plugins/hoster/FreakshareCom.py @@ -1,23 +1,32 @@ # -*- coding: utf-8 -*- import re + from module.plugins.Hoster import Hoster from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import secondsToMidnight class FreakshareCom(Hoster): - __name__ = "FreakshareCom" - __type__ = "hoster" + __name__ = "FreakshareCom" + __type__ = "hoster" + __version__ = "0.40" + __pattern__ = r'http://(?:www\.)?freakshare\.(net|com)/files/\S*?/' - __version__ = "0.38" + __description__ = """Freakshare.com hoster plugin""" - __author_name__ = ("sitacuisses", "spoob", "mkaay", "Toilal") - __author_mail__ = ("sitacuisses@yahoo.de", "spoob@pyload.org", "mkaay@mkaay.de", "toilal.dev@gmail.com") + __license__ = "GPLv3" + __authors__ = [("sitacuisses", "sitacuisses@yahoo.de"), + ("spoob", "spoob@pyload.org"), + ("mkaay", "mkaay@mkaay.de"), + ("Toilal", "toilal.dev@gmail.com")] + def setup(self): self.multiDL = False self.req_opts = [] + def process(self, pyfile): self.pyfile = pyfile @@ -41,24 +50,23 @@ class FreakshareCom(Hoster): "downloadserver": "No Downloadserver. Please try again later!"}) if check == "bad": - self.fail("Bad Try.") + self.fail(_("Bad Try")) elif check == "paralell": self.setWait(300, True) self.wait() self.retry() elif check == "empty": - self.fail("File not downloadable") + self.fail(_("File not downloadable")) elif check == "wrong_captcha": self.invalidCaptcha() self.retry() elif check == "downloadserver": - self.retry(5, 15 * 60, "No Download server") + self.retry(5, 15 * 60, _("No Download server")) + def prepare(self): pyfile = self.pyfile - self.wantReconnect = False - self.download_html() if not self.file_exists(): @@ -73,14 +81,16 @@ class FreakshareCom(Hoster): return True + def download_html(self): self.load("http://freakshare.com/index.php", {"language": "EN"}) # Set english language in server session self.html = self.load(self.pyfile.url) + def get_file_url(self): """ returns the absolute downloadable filepath """ - if self.html is None: + if not self.html: self.download_html() if not self.wantReconnect: self.req_opts = self.get_download_options() # get the Post options for the Request @@ -89,8 +99,9 @@ class FreakshareCom(Hoster): else: self.offline() + def get_file_name(self): - if self.html is None: + if not self.html: self.download_html() if not self.wantReconnect: file_name = re.search(r"<h1\sclass=\"box_heading\"\sstyle=\"text-align:center;\">([^ ]+)", self.html) @@ -102,9 +113,10 @@ class FreakshareCom(Hoster): else: return self.pyfile.url + def get_file_size(self): size = 0 - if self.html is None: + if not self.html: self.download_html() if not self.wantReconnect: file_size_check = re.search( @@ -116,30 +128,33 @@ class FreakshareCom(Hoster): return size + def get_waiting_time(self): - if self.html is None: + if not self.html: self.download_html() if "Your Traffic is used up for today" in self.html: self.wantReconnect = True - return 24 * 60 * 60 + return secondsToMidnight(gmt=2) - timestring = re.search('\s*var\s(?:downloadWait|time)\s=\s(\d*)[.\d]*;', self.html) + timestring = re.search('\s*var\s(?:downloadWait|time)\s=\s(\d*)[\d.]*;', self.html) if timestring: - return int(timestring.group(1)) + 1 # add 1 sec as tenths of seconds are cut off + return int(timestring.group(1)) else: return 60 + def file_exists(self): """ returns True or False """ - if self.html is None: + if not self.html: self.download_html() if re.search(r"This file does not exist!", self.html) is not None: return False else: return True + def get_download_options(self): re_envelope = re.search(r".*?value=\"Free\sDownload\".*?\n*?(.*?<.*?>\n*)*?\n*\s*?</form>", self.html).group(0) # get the whole request @@ -148,21 +163,14 @@ class FreakshareCom(Hoster): herewego = self.load(self.pyfile.url, None, request_options) # the actual download-Page - # comment this in, when it doesnt work - # with open("DUMP__FS_.HTML", "w") as fp: - # fp.write(herewego) - to_sort = re.findall(r"<input\stype=\".*?\"\svalue=\"(\S*?)\".*?name=\"(\S*?)\"\s.*?\/>", herewego) request_options = dict((n, v) for (v, n) in to_sort) - # comment this in, when it doesnt work as well - #print "\n\n%s\n\n" % ";".join(["%s=%s" % x for x in to_sort]) - - challenge = re.search(r"http://api\.recaptcha\.net/challenge\?k=([0-9A-Za-z]+)", herewego) + challenge = re.search(r"http://api\.recaptcha\.net/challenge\?k=(\w+)", herewego) if challenge: re_captcha = ReCaptcha(self) - (request_options["recaptcha_challenge_field"], - request_options["recaptcha_response_field"]) = re_captcha.challenge(challenge.group(1)) + (request_options['recaptcha_challenge_field'], + request_options['recaptcha_response_field']) = re_captcha.challenge(challenge.group(1)) return request_options diff --git a/module/plugins/hoster/FreeWayMe.py b/module/plugins/hoster/FreeWayMe.py index d72b12a12..80d0b8515 100644 --- a/module/plugins/hoster/FreeWayMe.py +++ b/module/plugins/hoster/FreeWayMe.py @@ -1,49 +1,34 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. +class FreeWayMe(MultiHoster): + __name__ = "FreeWayMe" + __type__ = "hoster" + __version__ = "0.14" - @author: Nicolas Giese -""" + __pattern__ = r'https://(?:www\.)?free-way\.me/.+' -from module.plugins.Hoster import Hoster - - -class FreeWayMe(Hoster): - __name__ = "FreeWayMe" - __version__ = "0.11" - __type__ = "hoster" - __pattern__ = r'https://(?:www\.)?free-way.me/.*' __description__ = """FreeWayMe hoster plugin""" - __author_name__ = "Nicolas Giese" - __author_mail__ = "james@free-way.me" + __license__ = "GPLv3" + __authors__ = [("Nicolas Giese", "james@free-way.me")] + def setup(self): self.resumeDownload = False - self.chunkLimit = 1 - self.multiDL = self.premium + self.multiDL = self.premium + self.chunkLimit = 1 - def process(self, pyfile): - if not self.account: - self.logError(_("Please enter your %s account or deactivate this plugin") % "FreeWayMe") - self.fail("No FreeWay account provided") - self.logDebug("Old URL: %s" % pyfile.url) - - (user, data) = self.account.selectAccount() + def handlePremium(self): + user, data = self.account.selectAccount() + self.link = True self.download( "https://www.free-way.me/load.php", - get={"multiget": 7, "url": pyfile.url, "user": user, "pw": self.account.getpw(user), "json": ""}, + get={"multiget": 7, "url": self.pyfile.url, "user": user, "pw": self.account.getpw(user), "json": ""}, disposition=True) + + +getInfo = create_getInfo(FreeWayMe) diff --git a/module/plugins/hoster/FreevideoCz.py b/module/plugins/hoster/FreevideoCz.py index eebb43b48..e56d1a299 100644 --- a/module/plugins/hoster/FreevideoCz.py +++ b/module/plugins/hoster/FreevideoCz.py @@ -1,68 +1,18 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. +class FreevideoCz(DeadHoster): + __name__ = "FreevideoCz" + __type__ = "hoster" + __version__ = "0.30" - @author: zoidberg -""" + __pattern__ = r'http://(?:www\.)?freevideo\.cz/vase-videa/.+' -import re -from module.plugins.Hoster import Hoster -from module.network.RequestFactory import getURL - - -def getInfo(urls): - result = [] - - for url in urls: - - html = getURL(url) - if re.search(FreevideoCz.FILE_OFFLINE_PATTERN, html): - # File offline - result.append((url, 0, 1, url)) - else: - result.append((url, 0, 2, url)) - yield result - - -class FreevideoCz(Hoster): - __name__ = "FreevideoCz" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?freevideo.cz/vase-videa/(.*)\.html' - __version__ = "0.2" __description__ = """Freevideo.cz hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" - - URL_PATTERN = r'clip: {\s*url: "([^"]+)"' - FILE_OFFLINE_PATTERN = r'<h2 class="red-corner-full">Str.nka nebyla nalezena</h2>' - - def setup(self): - self.multiDL = self.resumeDownload = True - - def process(self, pyfile): - - self.html = self.load(pyfile.url, decode=True) - - if re.search(self.FILE_OFFLINE_PATTERN, self.html): - self.offline() - - found = re.search(self.URL_PATTERN, self.html) - if found is None: - self.fail("Parse error (URL)") - download_url = found.group(1) + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - pyfile.name = re.match(self.__pattern__, pyfile.url).group(1) + ".mp4" - self.download(download_url) +getInfo = create_getInfo(FreevideoCz)
\ No newline at end of file diff --git a/module/plugins/hoster/FshareVn.py b/module/plugins/hoster/FshareVn.py index f9a9b6c16..a3f9703df 100644 --- a/module/plugins/hoster/FshareVn.py +++ b/module/plugins/hoster/FshareVn.py @@ -1,22 +1,20 @@ # -*- coding: utf-8 -*- import re + from time import strptime, mktime, gmtime -from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo from module.network.RequestFactory import getURL +from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo def getInfo(urls): for url in urls: - html = getURL('http://www.fshare.vn/check_link.php', post={ - "action": "check_link", - "arrlinks": url - }, decode=True) - - file_info = parseFileInfo(FshareVn, url, html) + html = getURL("http://www.fshare.vn/check_link.php", + post={'action': "check_link", 'arrlinks': url}, + decode=True) - yield file_info + yield parseFileInfo(FshareVn, url, html) def doubleDecode(m): @@ -24,21 +22,26 @@ def doubleDecode(m): class FshareVn(SimpleHoster): - __name__ = "FshareVn" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?fshare.vn/file/.*' - __version__ = "0.16" + __name__ = "FshareVn" + __type__ = "hoster" + __version__ = "0.18" + + __pattern__ = r'http://(?:www\.)?fshare\.vn/file/.+' + __description__ = """FshareVn hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" - - FILE_INFO_PATTERN = r'<p>(?P<N>[^<]+)<\\/p>[\\trn\s]*<p>(?P<S>[0-9,.]+)\s*(?P<U>[kKMG])i?B<\\/p>' - FILE_OFFLINE_PATTERN = r'<div class=\\"f_left file_w\\"|<\\/p>\\t\\t\\t\\t\\r\\n\\t\\t<p><\\/p>\\t\\t\\r\\n\\t\\t<p>0 KB<\\/p>' - FILE_NAME_REPLACEMENTS = [("(.*)", doubleDecode)] - DOWNLOAD_URL_PATTERN = r'action="(http://download.*?)[#"]' - VIP_URL_PATTERN = r'<form action="([^>]+)" method="get" name="frm_download">' + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + + INFO_PATTERN = r'<p>(?P<N>[^<]+)<\\/p>[\\trn\s]*<p>(?P<S>[\d.,]+)\s*(?P<U>[\w^_]+)<\\/p>' + OFFLINE_PATTERN = r'<div class=\\"f_left file_w\\"|<\\/p>\\t\\t\\t\\t\\r\\n\\t\\t<p><\\/p>\\t\\t\\r\\n\\t\\t<p>0 KB<\\/p>' + + NAME_REPLACEMENTS = [("(.*)", doubleDecode)] + + LINK_PATTERN = r'action="(http://download.*?)[#"]' WAIT_PATTERN = ur'Lượt tải xuống kế tiếp là:\s*(.*?)\s*<' + def process(self, pyfile): self.html = self.load('http://www.fshare.vn/check_link.php', post={ "action": "check_link", @@ -52,6 +55,7 @@ class FshareVn(SimpleHoster): self.handleFree() self.checkDownloadedFile() + def handleFree(self): self.html = self.load(self.pyfile.url, decode=True) @@ -61,49 +65,60 @@ class FshareVn(SimpleHoster): self.url = self.pyfile.url + action if not inputs: - self.parseError('FORM') + self.error(_("No FORM")) + elif 'link_file_pwd_dl' in inputs: - for password in self.getPassword().splitlines(): - self.logInfo('Password protected link, trying "%s"' % password) + password = self.getPassword() + + if password: + self.logInfo(_("Password protected link, trying ") + password) inputs['link_file_pwd_dl'] = password self.html = self.load(self.url, post=inputs, decode=True) - if not 'name="link_file_pwd_dl"' in self.html: - break + + if 'name="link_file_pwd_dl"' in self.html: + self.fail(_("Incorrect password")) else: - self.fail("No or incorrect password") + self.fail(_("No password found")) + else: self.html = self.load(self.url, post=inputs, decode=True) self.checkErrors() - found = re.search(r'var count = (\d+)', self.html) - self.setWait(int(found.group(1)) if found else 30) + m = re.search(r'var count = (\d+)', self.html) + self.setWait(int(m.group(1)) if m else 30) - found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) - if not found: - self.parseError('FREE DL URL') - self.url = found.group(1) + m = re.search(self.LINK_PATTERN, self.html) + if m is None: + self.error(_("LINK_PATTERN not found")) + self.url = m.group(1) self.logDebug("FREE DL URL: %s" % self.url) self.wait() self.download(self.url) + def handlePremium(self): self.download(self.pyfile.url) + def checkErrors(self): if '/error.php?' in self.req.lastEffectiveURL or u"Liên kết bạn chọn không tồn" in self.html: self.offline() - found = re.search(self.WAIT_PATTERN, self.html) - if found: - self.logInfo("Wait until %s ICT" % found.group(1)) - wait_until = mktime(strptime(found.group(1), "%d/%m/%Y %H:%M")) + m = re.search(self.WAIT_PATTERN, self.html) + if m: + self.logInfo(_("Wait until %s ICT") % m.group(1)) + wait_until = mktime(strptime(m.group(1), "%d/%m/%Y %H:%M")) self.wait(wait_until - mktime(gmtime()) - 7 * 60 * 60, True) self.retry() elif '<ul class="message-error">' in self.html: - self.logError("Unknown error occured or wait time not parsed") - self.retry(30, 2 * 60, "Unknown error") + msg = "Unknown error occured or wait time not parsed" + self.logError(msg) + self.retry(30, 2 * 60, msg) + + self.info.pop('error', None) + def checkDownloadedFile(self): # check download @@ -112,4 +127,4 @@ class FshareVn(SimpleHoster): }) if check == "not_found": - self.fail("File not found on server") + self.fail(_("File not m on server")) diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py index af9191a4d..c6ad68e49 100644 --- a/module/plugins/hoster/Ftp.py +++ b/module/plugins/hoster/Ftp.py @@ -1,43 +1,33 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: jeix - @author: mkaay -""" -from urlparse import urlparse -from urllib import quote, unquote import pycurl import re +from urllib import quote, unquote +from urlparse import urlparse + from module.plugins.Hoster import Hoster class Ftp(Hoster): - __name__ = "Ftp" - __version__ = "0.41" - __pattern__ = r'(ftps?|sftp)://(.*?:.*?@)?.*?/.*' # ftp://user:password@ftp.server.org/path/to/file - __type__ = "hoster" + __name__ = "Ftp" + __type__ = "hoster" + __version__ = "0.44" + + __pattern__ = r'(?:ftps?|sftp)://([\w.-]+(:[\w.-]+)?@)?[\w.-]+(:\d+)?/.+' + __description__ = """Download from ftp directory""" - __author_name__ = ("jeix", "mkaay", "zoidberg") - __author_mail__ = ("jeix@hasnomail.com", "mkaay@mkaay.de", "zoidberg@mujmail.cz") + __license__ = "GPLv3" + __authors__ = [("jeix", "jeix@hasnomail.com"), + ("mkaay", "mkaay@mkaay.de"), + ("zoidberg", "zoidberg@mujmail.cz")] + def setup(self): self.chunkLimit = -1 self.resumeDownload = True + def process(self, pyfile): parsed_url = urlparse(pyfile.url) netloc = parsed_url.netloc @@ -53,38 +43,36 @@ class Ftp(Hoster): if netloc in servers: self.logDebug("Logging on to %s" % netloc) - self.req.addAuth(self.account.accounts[netloc]["password"]) + self.req.addAuth(self.account.accounts[netloc]['password']) else: - for pwd in pyfile.package().password.splitlines(): - if ":" in pwd: - self.req.addAuth(pwd.strip()) - break + pwd = self.getPassword() + if ':' in pwd: + self.req.addAuth(pwd) self.req.http.c.setopt(pycurl.NOBODY, 1) try: - response = self.load(pyfile.url) + res = self.load(pyfile.url) except pycurl.error, e: - self.fail("Error %d: %s" % e.args) + self.fail(_("Error %d: %s") % e.args) self.req.http.c.setopt(pycurl.NOBODY, 0) self.logDebug(self.req.http.header) - found = re.search(r"Content-Length:\s*(\d+)", response) - if found: - pyfile.size = int(found.group(1)) + m = re.search(r"Content-Length:\s*(\d+)", res) + if m: + pyfile.size = int(m.group(1)) self.download(pyfile.url) else: - #Naive ftp directory listing + #Naive ftp directory listing if re.search(r'^25\d.*?"', self.req.http.header, re.M): pyfile.url = pyfile.url.rstrip('/') - pkgname = "/".join((pyfile.package().name, urlparse(pyfile.url).path.rpartition('/')[2])) + pkgname = "/".join(pyfile.package().name, urlparse(pyfile.url).path.rpartition('/')[2]) pyfile.url += '/' self.req.http.c.setopt(48, 1) # CURLOPT_DIRLISTONLY - response = self.load(pyfile.url, decode=False) - links = [pyfile.url + quote(x) for x in response.splitlines()] + res = self.load(pyfile.url, decode=False) + links = [pyfile.url + quote(x) for x in res.splitlines()] self.logDebug("LINKS", links) - self.core.api.addPackage(pkgname, links, 1) - #self.core.files.addLinks(links, pyfile.package().id) + self.core.api.addPackage(pkgname, links) else: - self.fail("Unexpected server response") + self.fail(_("Unexpected server response")) diff --git a/module/plugins/hoster/GamefrontCom.py b/module/plugins/hoster/GamefrontCom.py index 0cd54d2ea..c68866f87 100644 --- a/module/plugins/hoster/GamefrontCom.py +++ b/module/plugins/hoster/GamefrontCom.py @@ -1,27 +1,34 @@ # -*- coding: utf-8 -*- import re -from module.plugins.Hoster import Hoster + from module.network.RequestFactory import getURL +from module.plugins.Hoster import Hoster from module.utils import parseFileSize class GamefrontCom(Hoster): - __name__ = "GamefrontCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?gamefront.com/files/[A-Za-z0-9]+' + __name__ = "GamefrontCom" + __type__ = "hoster" __version__ = "0.04" + + __pattern__ = r'http://(?:www\.)?gamefront\.com/files/\w+' + __description__ = """Gamefront.com hoster plugin""" - __author_name__ = "fwannmacher" - __author_mail__ = "felipe@warhammerproject.com" + __license__ = "GPLv3" + __authors__ = [("fwannmacher", "felipe@warhammerproject.com")] + PATTERN_FILENAME = r'<title>(.*?) | Game Front' PATTERN_FILESIZE = r'<dt>File Size:</dt>[\n\s]*<dd>(.*?)</dd>' - PATTERN_OFFLINE = "This file doesn't exist, or has been removed." + PATTERN_OFFLINE = r'This file doesn\'t exist, or has been removed.' + def setup(self): - self.resumeDownload = self.multiDL = True - self.chunkLimit = -1 + self.resumeDownload = True + self.multiDL = True + self.chunkLimit = -1 + def process(self, pyfile): self.pyfile = pyfile @@ -32,12 +39,13 @@ class GamefrontCom(Hoster): pyfile.name = self._getName() - self.link = self._getLink() + link = self._getLink() + + if not link.startswith('http://'): + link = "http://www.gamefront.com/" + link - if not self.link.startswith('http://'): - self.link = "http://www.gamefront.com/" + self.link + self.download(link) - self.download(self.link) def _checkOnline(self): if re.search(self.PATTERN_OFFLINE, self.html): @@ -45,19 +53,19 @@ class GamefrontCom(Hoster): else: return True + def _getName(self): name = re.search(self.PATTERN_FILENAME, self.html) if name is None: - self.fail("%s: Plugin broken." % self.__name__) + self.fail(_("Plugin broken") return name.group(1) + def _getLink(self): - self.html2 = self.load("http://www.gamefront.com/" + re.search("(files/service/thankyou\\?id=[A-Za-z0-9]+)", + self.html2 = self.load("http://www.gamefront.com/" + re.search("(files/service/thankyou\\?id=\w+)", self.html).group(1)) - self.link = re.search("<a href=\"(http://media[0-9]+\.gamefront.com/.*)\">click here</a>", self.html2) - - return self.link.group(1).replace("&", "&") + return re.search("<a href=\"(http://media\d+\.gamefront.com/.*)\">click here</a>", self.html2).group(1).replace("&", "&") def getInfo(urls): @@ -70,15 +78,13 @@ def getInfo(urls): result.append((url, 0, 1, url)) else: name = re.search(GamefrontCom.PATTERN_FILENAME, html) - if name is None: result.append((url, 0, 1, url)) - continue - - name = name.group(1) - size = re.search(GamefrontCom.PATTERN_FILESIZE, html) - size = parseFileSize(size.group(1)) + else: + name = name.group(1) + size = re.search(GamefrontCom.PATTERN_FILESIZE, html) + size = parseFileSize(size.group(1)) - result.append((name, size, 3, url)) + result.append((name, size, 3, url)) yield result diff --git a/module/plugins/hoster/GigapetaCom.py b/module/plugins/hoster/GigapetaCom.py index 1282c996d..37af7f216 100644 --- a/module/plugins/hoster/GigapetaCom.py +++ b/module/plugins/hoster/GigapetaCom.py @@ -1,42 +1,31 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re -from random import randint + from pycurl import FOLLOWLOCATION +from random import randint from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class GigapetaCom(SimpleHoster): - __name__ = "GigapetaCom" - __type__ = "hoster" + __name__ = "GigapetaCom" + __type__ = "hoster" + __version__ = "0.02" + __pattern__ = r'http://(?:www\.)?gigapeta\.com/dl/\w+' - __version__ = "0.01" + __description__ = """GigaPeta.com hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + + NAME_PATTERN = r'<img src=".*" alt="file" />-->\s*(?P<N>.*?)\s*</td>' + SIZE_PATTERN = r'<th>\s*Size\s*</th>\s*<td>\s*(?P<S>.*?)\s*</td>' + OFFLINE_PATTERN = r'<div id="page_error">' + + COOKIES = [("gigapeta.com", "lang", "us")] - SH_COOKIES = [("http://gigapeta.com", "lang", "us")] - FILE_NAME_PATTERN = r'<img src=".*" alt="file" />-->\s*(?P<N>.*?)\s*</td>' - FILE_SIZE_PATTERN = r'<th>\s*Size\s*</th>\s*<td>\s*(?P<S>.*?)\s*</td>' - FILE_OFFLINE_PATTERN = r'<div id="page_error">' def handleFree(self): captcha_key = str(randint(1, 100000000)) @@ -44,7 +33,7 @@ class GigapetaCom(SimpleHoster): self.req.http.c.setopt(FOLLOWLOCATION, 0) - for _ in xrange(5): + for _i in xrange(5): self.checkErrors() captcha = self.decryptCaptcha(captcha_url) @@ -53,24 +42,26 @@ class GigapetaCom(SimpleHoster): "captcha": captcha, "download": "Download"}) - found = re.search(r"Location\s*:\s*(.*)", self.req.http.header, re.I) - if found: - download_url = found.group(1) + m = re.search(r'Location\s*:\s*(.+)', self.req.http.header, re.I) + if m: + download_url = m.group(1).rstrip() #@TODO: Remove .rstrip() in 0.4.10 break elif "Entered figures don`t coincide with the picture" in self.html: self.invalidCaptcha() else: - self.fail("No valid captcha code entered") + self.fail(_("No valid captcha code entered")) self.req.http.c.setopt(FOLLOWLOCATION, 1) - self.logDebug("Download URL: %s" % download_url) self.download(download_url) + def checkErrors(self): if "All threads for IP" in self.html: - self.logDebug("Your IP is already downloading a file - wait and retry") + self.logDebug("Your IP is already downloading a file") self.wait(5 * 60, True) self.retry() + self.info.pop('error', None) + getInfo = create_getInfo(GigapetaCom) diff --git a/module/plugins/hoster/GooIm.py b/module/plugins/hoster/GooIm.py index 1f77b7fe0..436d825a9 100644 --- a/module/plugins/hoster/GooIm.py +++ b/module/plugins/hoster/GooIm.py @@ -1,18 +1,7 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################ +# +# Test links: +# https://goo.im/devs/liquidsmooth/3.x/codina/Nightly/LS-KK-v3.2-2014-08-01-codina.zip import re @@ -20,34 +9,31 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class GooIm(SimpleHoster): - __name__ = "GooIm" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?goo\.im/.+' - __version__ = "0.02" + __name__ = "GooIm" + __type__ = "hoster" + __version__ = "0.03" + + __pattern__ = r'https?://(?:www\.)?goo\.im/.+' + __description__ = """Goo.im hoster plugin""" - __author_name__ = "stickell" - __author_mail__ = "l.stickell@yahoo.it" + __license__ = "GPLv3" + __authors__ = [("zapp-brannigan", "fuerst.reinje@web.de")] + + + NAME_PATTERN = r'You will be redirected to .*(?P<N>[^/ ]+) in' + OFFLINE_PATTERN = r'The file you requested was not found' - FILE_NAME_PATTERN = r'<h3>Filename: (?P<N>.+)</h3>' - FILE_OFFLINE_PATTERN = r'The file you requested was not found' def setup(self): - self.chunkLimit = -1 - self.multiDL = self.resumeDownload = True + self.resumeDownload = True + self.multiDL = True + def handleFree(self): - self.html = self.load(self.pyfile.url) - m = re.search(r'MD5sum: (?P<MD5>[0-9a-z]{32})</h3>', self.html) - if m: - self.check_data = {"md5": m.group('MD5')} + url = self.pyfile.url + self.html = self.load(url, cookies=True) self.wait(10) - - header = self.load(self.pyfile.url, just_header=True) - if header['location']: - self.logDebug("Direct link: " + header['location']) - self.download(header['location']) - else: - self.parseError("Unable to detect direct download link") + self.download(url, cookies=True) getInfo = create_getInfo(GooIm) diff --git a/module/plugins/hoster/HellshareCz.py b/module/plugins/hoster/HellshareCz.py index 91e51e314..4b44cc335 100644 --- a/module/plugins/hoster/HellshareCz.py +++ b/module/plugins/hoster/HellshareCz.py @@ -1,59 +1,47 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class HellshareCz(SimpleHoster): - __name__ = "HellshareCz" - __type__ = "hoster" - __pattern__ = r'(http://(?:www\.)?hellshare\.(?:cz|com|sk|hu|pl)/[^?]*/\d+).*' - __version__ = "0.82" + __name__ = "HellshareCz" + __type__ = "hoster" + __version__ = "0.83" + + __pattern__ = r'(http://(?:www\.)?hellshare\.(?:cz|com|sk|hu|pl)/[^?]*/\d+)' + __description__ = """Hellshare.cz hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + - FILE_NAME_PATTERN = r'<h1 id="filename"[^>]*>(?P<N>[^<]+)</h1>' - FILE_SIZE_PATTERN = r'<strong id="FileSize_master">(?P<S>[0-9.]*) (?P<U>[kKMG])i?B</strong>' - FILE_OFFLINE_PATTERN = r'<h1>File not found.</h1>' + NAME_PATTERN = r'<h1 id="filename"[^>]*>(?P<N>[^<]+)</h1>' + SIZE_PATTERN = r'<strong id="FileSize_master">(?P<S>[\d.,]+) (?P<U>[\w^_]+)</strong>' + OFFLINE_PATTERN = r'<h1>File not found.</h1>' SHOW_WINDOW_PATTERN = r'<a href="([^?]+/(\d+)/\?do=(fileDownloadButton|relatedFileDownloadButton-\2)-showDownloadWindow)"' + def setup(self): self.resumeDownload = self.multiDL = True if self.account else False self.chunkLimit = 1 + def process(self, pyfile): if not self.account: - self.fail("User not logged in") + self.fail(_("User not logged in")) pyfile.url = re.match(self.__pattern__, pyfile.url).group(1) self.html = self.load(pyfile.url, decode=True) self.getFileInfo() if not self.checkTrafficLeft(): - self.fail("Not enough traffic left for user %s." % self.user) + self.fail(_("Not enough traffic left for user ") + self.user) - found = re.search(self.SHOW_WINDOW_PATTERN, self.html) - if not found: - self.parseError('SHOW WINDOW') - self.url = "http://www.hellshare.com" + found.group(1) - self.logDebug("DOWNLOAD URL: " + self.url) + m = re.search(self.SHOW_WINDOW_PATTERN, self.html) + if m is None: + self.error(_("SHOW_WINDOW_PATTERN not found")) + self.url = "http://www.hellshare.com" + m.group(1) self.download(self.url) diff --git a/module/plugins/hoster/HellspyCz.py b/module/plugins/hoster/HellspyCz.py index e4ddce514..2b9b76b8a 100644 --- a/module/plugins/hoster/HellspyCz.py +++ b/module/plugins/hoster/HellspyCz.py @@ -1,33 +1,18 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo class HellspyCz(DeadHoster): - __name__ = "HellspyCz" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?(?:hellspy\.(?:cz|com|sk|hu|pl)|sciagaj.pl)(/\S+/\d+)/?.*' + __name__ = "HellspyCz" + __type__ = "hoster" __version__ = "0.28" + + __pattern__ = r'http://(?:www\.)?(?:hellspy\.(?:cz|com|sk|hu|pl)|sciagaj\.pl)(/\S+/\d+)' + __description__ = """HellSpy.cz hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] getInfo = create_getInfo(HellspyCz) diff --git a/module/plugins/hoster/HotfileCom.py b/module/plugins/hoster/HotfileCom.py index 9a0947f2c..f7724faf2 100644 --- a/module/plugins/hoster/HotfileCom.py +++ b/module/plugins/hoster/HotfileCom.py @@ -4,13 +4,18 @@ from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo class HotfileCom(DeadHoster): - __name__ = "HotfileCom" - __type__ = "hoster" - __pattern__ = r'https?://(www.)?hotfile\.com/dl/\d+/[0-9a-zA-Z]+/' + __name__ = "HotfileCom" + __type__ = "hoster" __version__ = "0.37" + + __pattern__ = r'https?://(?:www\.)?hotfile\.com/dl/\d+/\w+' + __description__ = """Hotfile.com hoster plugin""" - __author_name__ = ("sitacuisses", "spoob", "mkaay", "JoKoT3") - __author_mail__ = ("sitacuisses@yhoo.de", "spoob@pyload.org", "mkaay@mkaay.de", "jokot3@gmail.com") + __license__ = "GPLv3" + __authors__ = [("sitacuisses", "sitacuisses@yhoo.de"), + ("spoob", "spoob@pyload.org"), + ("mkaay", "mkaay@mkaay.de"), + ("JoKoT3", "jokot3@gmail.com")] getInfo = create_getInfo(HotfileCom) diff --git a/module/plugins/hoster/HugefilesNet.py b/module/plugins/hoster/HugefilesNet.py index 2375c75f8..f7221f8c5 100644 --- a/module/plugins/hoster/HugefilesNet.py +++ b/module/plugins/hoster/HugefilesNet.py @@ -1,37 +1,27 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################ - -# Test links (random.bin): -# http://hugefiles.net/prthf9ya4w6s - -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo - - -class HugefilesNet(XFileSharingPro): - __name__ = "HugefilesNet" - __type__ = "hoster" + +import re + +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo + + +class HugefilesNet(XFSHoster): + __name__ = "HugefilesNet" + __type__ = "hoster" + __version__ = "0.05" + __pattern__ = r'http://(?:www\.)?hugefiles\.net/\w{12}' - __version__ = "0.01" + __description__ = """Hugefiles.net hoster plugin""" - __author_name__ = "stickell" - __author_mail__ = "l.stickell@yahoo.it" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it")] + + + HOSTER_DOMAIN = "hugefiles.net" - HOSTER_NAME = "hugefiles.net" + SIZE_PATTERN = r'File Size:</span>\s*<span[^>]*>(?P<S>[^<]+)</span></div>' - FILE_SIZE_PATTERN = r'File Size:</span>\s*<span[^>]*>(?P<S>[^<]+)</span></div>' + FORM_INPUTS_MAP = {'ctype': re.compile(r'\d+')} getInfo = create_getInfo(HugefilesNet) diff --git a/module/plugins/hoster/HundredEightyUploadCom.py b/module/plugins/hoster/HundredEightyUploadCom.py index 6e5ffac30..317a49caf 100644 --- a/module/plugins/hoster/HundredEightyUploadCom.py +++ b/module/plugins/hoster/HundredEightyUploadCom.py @@ -1,38 +1,24 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################ - -# Test links (random.bin): +# +# Test links: # http://180upload.com/js9qdm6kjnrs -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo -class HundredEightyUploadCom(XFileSharingPro): - __name__ = "HundredEightyUploadCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?180upload\.com/(\w+).*' - __version__ = "0.01" +class HundredEightyUploadCom(XFSHoster): + __name__ = "HundredEightyUploadCom" + __type__ = "hoster" + __version__ = "0.04" + + __pattern__ = r'http://(?:www\.)?180upload\.com/\w{12}' + __description__ = """180upload.com hoster plugin""" - __author_name__ = "stickell" - __author_mail__ = "l.stickell@yahoo.it" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it")] - HOSTER_NAME = "180upload.com" - FILE_NAME_PATTERN = r'Filename:</b></td><td nowrap>(?P<N>.+)</td></tr>-->' - FILE_SIZE_PATTERN = r'Size:</b></td><td>(?P<S>[\d.]+) (?P<U>[A-Z]+)\s*<small>' + HOSTER_DOMAIN = "180upload.com" getInfo = create_getInfo(HundredEightyUploadCom) diff --git a/module/plugins/hoster/IFileWs.py b/module/plugins/hoster/IFileWs.py index 5b0adaa97..b4f225c4b 100644 --- a/module/plugins/hoster/IFileWs.py +++ b/module/plugins/hoster/IFileWs.py @@ -1,22 +1,18 @@ # -*- coding: utf-8 -*- -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo -class IFileWs(XFileSharingPro): - __name__ = "IFileWs" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?ifile\.ws/\w+(/.+)?' - __version__ = "0.01" - __description__ = """Ifile.ws hoster plugin""" - __author_name__ = "z00nx" - __author_mail__ = "z00nx0@gmail.com" +class IFileWs(DeadHoster): + __name__ = "IFileWs" + __type__ = "hoster" + __version__ = "0.02" - HOSTER_NAME = "ifile.ws" + __pattern__ = r'http://(?:www\.)?ifile\.ws/\w{12}' - FILE_INFO_PATTERN = '<h1\s+style="display:inline;">(?P<N>[^<]+)</h1>\s+\[(?P<S>[^]]+)\]' - FILE_OFFLINE_PATTERN = 'File Not Found|The file was removed by administrator' - LONG_WAIT_PATTERN = "(?P<M>\d(?=\s+minutes)).*(?P<S>\d+(?=\s+seconds))" + __description__ = """Ifile.ws hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("z00nx", "z00nx0@gmail.com")] getInfo = create_getInfo(IFileWs) diff --git a/module/plugins/hoster/IcyFilesCom.py b/module/plugins/hoster/IcyFilesCom.py index 82d760d01..921b64207 100644 --- a/module/plugins/hoster/IcyFilesCom.py +++ b/module/plugins/hoster/IcyFilesCom.py @@ -1,33 +1,18 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: godofdream -""" - from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo class IcyFilesCom(DeadHoster): - __name__ = "IcyFilesCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?icyfiles\.com/(.*)' + __name__ = "IcyFilesCom" + __type__ = "hoster" __version__ = "0.06" + + __pattern__ = r'http://(?:www\.)?icyfiles\.com/(.+)' + __description__ = """IcyFiles.com hoster plugin""" - __author_name__ = "godofdream" - __author_mail__ = "soilfiction@gmail.com" + __license__ = "GPLv3" + __authors__ = [("godofdream", "soilfiction@gmail.com")] getInfo = create_getInfo(IcyFilesCom) diff --git a/module/plugins/hoster/IfileIt.py b/module/plugins/hoster/IfileIt.py index 6c754624b..2dae4cd80 100644 --- a/module/plugins/hoster/IfileIt.py +++ b/module/plugins/hoster/IfileIt.py @@ -1,77 +1,67 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + from module.common.json_layer import json_loads from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class IfileIt(SimpleHoster): - __name__ = "IfileIt" - __type__ = "hoster" + __name__ = "IfileIt" + __type__ = "hoster" + __version__ = "0.28" + __pattern__ = r'^unmatchable$' - __version__ = "0.27" + __description__ = """Ifile.it""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" - - #EVAL_PATTERN = r'(eval\(function\(p,a,c,k,e,d\).*)' - #DEC_PATTERN = r"requestBtn_clickEvent[^}]*url:\s*([^,]+)" - DOWNLOAD_LINK_PATTERN = r'</span> If it doesn\'t, <a target="_blank" href="([^"]+)">' - RECAPTCHA_KEY_PATTERN = r"var __recaptcha_public\s*=\s*'([^']+)';" - FILE_INFO_PATTERN = r'<span style="cursor: default;[^>]*>\s*(?P<N>.*?)\s* \s*<strong>\s*(?P<S>[0-9.]+)\s*(?P<U>[kKMG])i?B\s*</strong>\s*</span>' - FILE_OFFLINE_PATTERN = r'<span style="cursor: default;[^>]*>\s* \s*<strong>\s*</strong>\s*</span>' + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + + LINK_PATTERN = r'</span> If it doesn\'t, <a target="_blank" href="([^"]+)">' + RECAPTCHA_PATTERN = r'var __recaptcha_public\s*=\s*\'(.+?)\'' + INFO_PATTERN = r'<span style="cursor: default;[^>]*>\s*(?P<N>.*?)\s* \s*<strong>\s*(?P<S>[\d.,]+)\s*(?P<U>[\w^_]+)\s*</strong>\s*</span>' + OFFLINE_PATTERN = r'<span style="cursor: default;[^>]*>\s* \s*<strong>\s*</strong>\s*</span>' TEMP_OFFLINE_PATTERN = r'<span class="msg_red">Downloading of this file is temporarily disabled</span>' + def handleFree(self): - ukey = re.match(self.__pattern__, self.pyfile.url).group(1) - json_url = 'http://ifile.it/new_download-request.json' + ukey = re.match(self.__pattern__, self.pyfile.url).group(1) + json_url = 'http://ifile.it/new_download-request.json' post_data = {"ukey": ukey, "ab": "0"} + res = json_loads(self.load(json_url, post=post_data)) + + self.logDebug(res) - json_response = json_loads(self.load(json_url, post=post_data)) - self.logDebug(json_response) - if json_response['status'] == 3: + if res['status'] == 3: self.offline() - if json_response["captcha"]: - captcha_key = re.search(self.RECAPTCHA_KEY_PATTERN, self.html).group(1) + if res['captcha']: + captcha_key = re.search(self.RECAPTCHA_PATTERN, self.html).group(1) + recaptcha = ReCaptcha(self) - post_data["ctype"] = "recaptcha" + post_data['ctype'] = "recaptcha" - for _ in xrange(5): - post_data["recaptcha_challenge"], post_data["recaptcha_response"] = recaptcha.challenge(captcha_key) - json_response = json_loads(self.load(json_url, post=post_data)) - self.logDebug(json_response) + for _i in xrange(5): + challenge, response = recaptcha.challenge(captcha_key) + post_data.update({'recaptcha_challenge': challenge, + 'recaptcha_response' : response}) + res = json_loads(self.load(json_url, post=post_data)) + self.logDebug(res) - if json_response["retry"]: + if res['retry']: self.invalidCaptcha() else: self.correctCaptcha() break else: - self.fail("Incorrect captcha") + self.fail(_("Incorrect captcha")) - if not "ticket_url" in json_response: - self.parseError("Download URL") + if not "ticket_url" in res: + self.error(_("No download URL")) - self.download(json_response["ticket_url"]) + self.download(res['ticket_url']) getInfo = create_getInfo(IfileIt) diff --git a/module/plugins/hoster/IfolderRu.py b/module/plugins/hoster/IfolderRu.py index 7c5fede72..255f10f45 100644 --- a/module/plugins/hoster/IfolderRu.py +++ b/module/plugins/hoster/IfolderRu.py @@ -1,50 +1,39 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class IfolderRu(SimpleHoster): - __name__ = "IfolderRu" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?(?:ifolder\.ru|rusfolder\.(?:com|net|ru))/(?:files/)?(?P<ID>\d+).*' + __name__ = "IfolderRu" + __type__ = "hoster" __version__ = "0.38" + + __pattern__ = r'http://(?:www\.)?(?:ifolder\.ru|rusfolder\.(?:com|net|ru))/(?:files/)?(?P<ID>\d+)' + __description__ = """Ifolder.ru hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" - - FILE_SIZE_REPLACEMENTS = [(u'Кб', 'KB'), (u'Мб', 'MB'), (u'Гб', 'GB')] - FILE_NAME_PATTERN = ur'(?:<div><span>)?Название:(?:</span>)? <b>(?P<N>[^<]+)</b><(?:/div|br)>' - FILE_SIZE_PATTERN = ur'(?:<div><span>)?Размер:(?:</span>)? <b>(?P<S>[^<]+)</b><(?:/div|br)>' - FILE_OFFLINE_PATTERN = ur'<p>Файл номер <b>[^<]*</b> (не найден|удален) !!!</p>' - - SESSION_ID_PATTERN = r'<a href=(http://ints.(?:rusfolder.com|ifolder.ru)/ints/sponsor/\?bi=\d*&session=([^&]+)&u=[^>]+)>' - INTS_SESSION_PATTERN = r'\(\'ints_session\'\);\s*if\(tag\)\{tag.value = "([^"]+)";\}' - HIDDEN_INPUT_PATTERN = r"var v = .*?name='([^']+)' value='1'" - DOWNLOAD_LINK_PATTERN = r'<a id="download_file_href" href="([^"]+)"' + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + + SIZE_REPLACEMENTS = [(u'Кб', 'KB'), (u'Мб', 'MB'), (u'Гб', 'GB')] + NAME_PATTERN = ur'(?:<div><span>)?Название:(?:</span>)? <b>(?P<N>[^<]+)</b><(?:/div|br)>' + SIZE_PATTERN = ur'(?:<div><span>)?Размер:(?:</span>)? <b>(?P<S>[^<]+)</b><(?:/div|br)>' + OFFLINE_PATTERN = ur'<p>Файл номер <b>[^<]*</b> (не найден|удален) !!!</p>' + + SESSION_ID_PATTERN = r'<a href=(http://ints\.(?:rusfolder\.com|ifolder\.ru)/ints/sponsor/\?bi=\d*&session=([^&]+)&u=[^>]+)>' + INTS_SESSION_PATTERN = r'\(\'ints_session\'\);\s*if\(tag\)\{tag\.value = "([^"]+)";\}' + HIDDEN_INPUT_PATTERN = r'var v = .*?name=\'(.+?)\' value=\'1\'' + LINK_PATTERN = r'<a id="download_file_href" href="([^"]+)"' WRONG_CAPTCHA_PATTERN = ur'<font color=Red>неверный код,<br>введите еще раз</font><br>' + def setup(self): self.resumeDownload = self.multiDL = True if self.account else False self.chunkLimit = 1 + def process(self, pyfile): file_id = re.match(self.__pattern__, pyfile.url).group('ID') self.html = self.load("http://rusfolder.com/%s" % file_id, cookies=True, decode=True) @@ -62,7 +51,7 @@ class IfolderRu(SimpleHoster): self.wait(31, False) captcha_url = "http://ints.rusfolder.com/random/images/?session=%s" % session_id - for _ in xrange(5): + for _i in xrange(5): self.html = self.load(url, cookies=True) action, inputs = self.parseHtmlForm('ID="Form1"') inputs['ints_session'] = re.search(self.INTS_SESSION_PATTERN, self.html).group(1) @@ -77,11 +66,10 @@ class IfolderRu(SimpleHoster): else: break else: - self.fail("Invalid captcha") + self.fail(_("Invalid captcha")) - download_url = re.search(self.DOWNLOAD_LINK_PATTERN, self.html).group(1) + download_url = re.search(self.LINK_PATTERN, self.html).group(1) self.correctCaptcha() - self.logDebug("Download URL: %s" % download_url) self.download(download_url) diff --git a/module/plugins/hoster/JumbofilesCom.py b/module/plugins/hoster/JumbofilesCom.py index cdeffff34..cabc0f098 100644 --- a/module/plugins/hoster/JumbofilesCom.py +++ b/module/plugins/hoster/JumbofilesCom.py @@ -1,31 +1,37 @@ # -*- coding: utf-8 -*- import re + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class JumbofilesCom(SimpleHoster): - __name__ = "JumbofilesCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?jumbofiles.com/(\w{12}).*' + __name__ = "JumbofilesCom" + __type__ = "hoster" __version__ = "0.02" + + __pattern__ = r'http://(?:www\.)?jumbofiles\.com/(\w{12})' + __description__ = """JumboFiles.com hoster plugin""" - __author_name__ = "godofdream" - __author_mail__ = "soilfiction@gmail.com" + __license__ = "GPLv3" + __authors__ = [("godofdream", "soilfiction@gmail.com")] + + + INFO_PATTERN = r'<TR><TD>(?P<N>[^<]+?)\s*<small>\((?P<S>[\d.,]+)\s*(?P<U>[\w^_]+)' + OFFLINE_PATTERN = r'Not Found or Deleted / Disabled due to inactivity or DMCA' + LINK_PATTERN = r'<meta http-equiv="refresh" content="10;url=(.+)">' - FILE_INFO_PATTERN = '<TR><TD>(?P<N>[^<]+?)\s*<small>\((?P<S>[\d.]+)\s*(?P<U>[KMG][bB])\)</small></TD></TR>' - FILE_OFFLINE_PATTERN = 'Not Found or Deleted / Disabled due to inactivity or DMCA' - DIRECT_LINK_PATTERN = '<meta http-equiv="refresh" content="10;url=(.+)">' def setup(self): - self.resumeDownload = self.multiDL = True + self.resumeDownload = True + self.multiDL = True + def handleFree(self): ukey = re.match(self.__pattern__, self.pyfile.url).group(1) post_data = {"id": ukey, "op": "download3", "rand": ""} html = self.load(self.pyfile.url, post=post_data, decode=True) - url = re.search(self.DIRECT_LINK_PATTERN, html).group(1) - self.logDebug("Download " + url) + url = re.search(self.LINK_PATTERN, html).group(1) self.download(url) diff --git a/module/plugins/hoster/JunocloudMe.py b/module/plugins/hoster/JunocloudMe.py new file mode 100644 index 000000000..56d6588fa --- /dev/null +++ b/module/plugins/hoster/JunocloudMe.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo + + +class JunocloudMe(XFSHoster): + __name__ = "JunocloudMe" + __type__ = "hoster" + __version__ = "0.05" + + __pattern__ = r'http://(?:\w+\.)?junocloud\.me/\w{12}' + + __description__ = """Junocloud.me hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("guidobelix", "guidobelix@hotmail.it")] + + + HOSTER_DOMAIN = "junocloud.me" + + URL_REPLACEMENTS = [(r'//(www\.)?junocloud', "//dl3.junocloud")] + + OFFLINE_PATTERN = r'>No such file with this filename<' + TEMP_OFFLINE_PATTERN = r'The page may have been renamed, removed or be temporarily unavailable.<' + + +getInfo = create_getInfo(JunocloudMe) diff --git a/module/plugins/hoster/Keep2shareCC.py b/module/plugins/hoster/Keep2shareCC.py deleted file mode 100644 index a7f1efdb8..000000000 --- a/module/plugins/hoster/Keep2shareCC.py +++ /dev/null @@ -1,120 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################ - -# Test links (random.bin): -# http://k2s.cc/file/55fb73e1c00c5/random.bin - -import re -from urlparse import urlparse, urljoin - -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.plugins.internal.CaptchaService import ReCaptcha - - -class Keep2shareCC(SimpleHoster): - __name__ = "Keep2shareCC" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?(keep2share|k2s|keep2s)\.cc/file/(?P<ID>\w+)' - __version__ = "0.10" - __description__ = """Keep2share.cc hoster plugin""" - __author_name__ = "stickell" - __author_mail__ = "l.stickell@yahoo.it" - - FILE_NAME_PATTERN = r'File: <span>(?P<N>.+)</span>' - FILE_SIZE_PATTERN = r'Size: (?P<S>[^<]+)</div>' - FILE_OFFLINE_PATTERN = r'File not found or deleted|Sorry, this file is blocked or deleted|Error 404' - - DIRECT_LINK_PATTERN = r'To download this file with slow speed, use <a href="([^"]+)">this link</a>' - WAIT_PATTERN = r'Please wait ([\d:]+) to download this file' - ALREADY_DOWNLOADING_PATTERN = r'Free account does not allow to download more than one file at the same time' - - RECAPTCHA_KEY = '6LcYcN0SAAAAABtMlxKj7X0hRxOY8_2U86kI1vbb' - - def handleFree(self): - self.sanitize_url() - self.html = self.load(self.pyfile.url) - - self.fid = re.search(r'<input type="hidden" name="slow_id" value="([^"]+)">', self.html).group(1) - self.html = self.load(self.pyfile.url, post={'yt0': '', 'slow_id': self.fid}) - - m = re.search(r"function download\(\){.*window\.location\.href = '([^']+)';", self.html, re.DOTALL) - if m: # Direct mode - self.startDownload(m.group(1)) - else: - self.handleCaptcha() - - self.wait(30) - - self.html = self.load(self.pyfile.url, post={'uniqueId': self.fid, 'free': 1}) - - m = re.search(self.WAIT_PATTERN, self.html) - if m: - self.logDebug('Hoster told us to wait for %s' % m.group(1)) - # string to time convert courtesy of https://stackoverflow.com/questions/10663720 - ftr = [3600, 60, 1] - wait_time = sum([a * b for a, b in zip(ftr, map(int, m.group(1).split(':')))]) - self.wait(wait_time, reconnect=True) - self.retry() - - m = re.search(self.ALREADY_DOWNLOADING_PATTERN, self.html) - if m: - # if someone is already downloading on our line, wait 30min and retry - self.logDebug('Already downloading, waiting for 30 minutes') - self.wait(30 * 60, reconnect=True) - self.retry() - - m = re.search(self.DIRECT_LINK_PATTERN, self.html) - if not m: - self.parseError("Unable to detect direct link") - self.startDownload(m.group(1)) - - def handleCaptcha(self): - recaptcha = ReCaptcha(self) - for _ in xrange(5): - challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY) - post_data = {'recaptcha_challenge_field': challenge, - 'recaptcha_response_field': response, - 'CaptchaForm%5Bcode%5D': '', - 'free': 1, - 'freeDownloadRequest': 1, - 'uniqueId': self.fid, - 'yt0': ''} - - self.html = self.load(self.pyfile.url, post=post_data) - - if 'recaptcha' not in self.html: - self.correctCaptcha() - break - else: - self.logInfo('Wrong captcha') - self.invalidCaptcha() - else: - self.fail("All captcha attempts failed") - - def startDownload(self, url): - d = urljoin(self.base_url, url) - self.logDebug('Direct Link: ' + d) - self.download(d, disposition=True) - - def sanitize_url(self): - header = self.load(self.pyfile.url, just_header=True) - if 'location' in header: - self.pyfile.url = header['location'] - p = urlparse(self.pyfile.url) - self.base_url = "%s://%s" % (p.scheme, p.hostname) - - -getInfo = create_getInfo(Keep2shareCC) diff --git a/module/plugins/hoster/Keep2shareCc.py b/module/plugins/hoster/Keep2shareCc.py new file mode 100644 index 000000000..86c28e93b --- /dev/null +++ b/module/plugins/hoster/Keep2shareCc.py @@ -0,0 +1,130 @@ +# -*- coding: utf-8 -*- + +import re + +from urlparse import urljoin, urlparse + +from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import _isDirectLink, SimpleHoster, create_getInfo + + +class Keep2shareCc(SimpleHoster): + __name__ = "Keep2shareCc" + __type__ = "hoster" + __version__ = "0.18" + + __pattern__ = r'https?://(?:www\.)?(keep2share|k2s|keep2s)\.cc/file/(?P<ID>\w+)' + + __description__ = """Keep2share.cc hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + URL_REPLACEMENTS = [(__pattern__ + ".*", "http://k2s.cc/file/\g<ID>")] + + NAME_PATTERN = r'File: <span>(?P<N>.+)</span>' + SIZE_PATTERN = r'Size: (?P<S>[^<]+)</div>' + + OFFLINE_PATTERN = r'File not found or deleted|Sorry, this file is blocked or deleted|Error 404' + TEMP_OFFLINE_PATTERN = r'Downloading blocked due to' + + LINK_FREE_PATTERN = LINK_PREMIUM_PATTERN = r'"([^"]+url.html?file=.+?)"|window\.location\.href = \'(.+?)\';' + + CAPTCHA_PATTERN = r'src="(/file/captcha\.html.+?)"' + + WAIT_PATTERN = r'Please wait ([\d:]+) to download this file' + TEMP_ERROR_PATTERN = r'>\s*(Download count files exceed|Traffic limit exceed|Free account does not allow to download more than one file at the same time)' + ERROR_PATTERN = r'>\s*(Free user can\'t download large files|You no can access to this file|This download available only for premium users|This is private file)' + + + def checkErrors(self): + m = re.search(self.TEMP_ERROR_PATTERN, self.html) + if m: + self.info['error'] = m.group(1) + self.wantReconnect = True + self.retry(wait_time=30 * 60, reason=m.group(0)) + + m = re.search(self.ERROR_PATTERN, self.html) + if m: + errmsg = self.info['error'] = m.group(1) + self.error(errmsg) + + m = re.search(self.WAIT_PATTERN, self.html) + if m: + self.logDebug("Hoster told us to wait for %s" % m.group(1)) + + # string to time convert courtesy of https://stackoverflow.com/questions/10663720 + ftr = [3600, 60, 1] + wait_time = sum([a * b for a, b in zip(ftr, map(int, m.group(1).split(':')))]) + + self.wantReconnect = True + self.retry(wait_time=wait_time, reason="Please wait to download this file") + + self.info.pop('error', None) + + + def handleFree(self): + self.fid = re.search(r'<input type="hidden" name="slow_id" value="([^"]+)">', self.html).group(1) + self.html = self.load(self.pyfile.url, post={'yt0': '', 'slow_id': self.fid}) + + self.checkErrors() + + m = re.search(self.LINK_FREE_PATTERN, self.html) + + if m is None: + self.handleCaptcha() + + self.wait(30) + + self.html = self.load(self.pyfile.url, post={'uniqueId': self.fid, 'free': 1}) + + self.checkErrors() + + m = re.search(self.LINK_FREE_PATTERN, self.html) + if m is None: + self.error(_("LINK_FREE_PATTERN not found")) + + self.link = m.group(1) + + + def handleCaptcha(self): + recaptcha = ReCaptcha(self) + + for _i in xrange(5): + post_data = {'free' : 1, + 'freeDownloadRequest': 1, + 'uniqueId' : self.fid, + 'yt0' : ''} + + m = re.search(self.CAPTCHA_PATTERN, self.html) + if m: + captcha_url = urljoin("http://k2s.cc/", m.group(1)) + post_data['CaptchaForm[code]'] = self.decryptCaptcha(captcha_url) + else: + challenge, response = recaptcha.challenge() + post_data.update({'recaptcha_challenge_field': challenge, + 'recaptcha_response_field' : response}) + + self.html = self.load(self.pyfile.url, post=post_data) + + if 'recaptcha' not in self.html: + self.correctCaptcha() + break + else: + self.invalidCaptcha() + else: + self.fail(_("All captcha attempts failed")) + + + def downloadLink(self, link): + if not link or not isinstance(link, basestring): + return + + link = _isDirectLink(self, link, self.premium) + + if link: + self.download(urljoin("http://k2s.cc/", link), disposition=True) + + +getInfo = create_getInfo(Keep2shareCc) diff --git a/module/plugins/hoster/KickloadCom.py b/module/plugins/hoster/KickloadCom.py new file mode 100644 index 000000000..1c39db46c --- /dev/null +++ b/module/plugins/hoster/KickloadCom.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo + + +class KickloadCom(DeadHoster): + __name__ = "KickloadCom" + __type__ = "hoster" + __version__ = "0.21" + + __pattern__ = r'http://(?:www\.)?kickload\.com/get/.+' + + __description__ = """Kickload.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("mkaay", "mkaay@mkaay.de")] + + +getInfo = create_getInfo(KickloadCom) diff --git a/module/plugins/hoster/KingfilesNet.py b/module/plugins/hoster/KingfilesNet.py new file mode 100644 index 000000000..13cbf4781 --- /dev/null +++ b/module/plugins/hoster/KingfilesNet.py @@ -0,0 +1,82 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.CaptchaService import SolveMedia +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + + +class KingfilesNet(SimpleHoster): + __name__ = "KingfilesNet" + __type__ = "hoster" + __version__ = "0.05" + + __pattern__ = r'http://(?:www\.)?kingfiles\.net/(?P<ID>\w{12})' + + __description__ = """Kingfiles.net hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zapp-brannigan", "fuerst.reinje@web.de"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + NAME_PATTERN = r'name="fname" value="(?P<N>.+?)">' + SIZE_PATTERN = r'>Size: .+?">(?P<S>[\d.,]+) (?P<U>[\w^_]+)' + + OFFLINE_PATTERN = r'>(File Not Found</b><br><br>|File Not Found</h2>)' + + RAND_ID_PATTERN = r'type=\"hidden\" name=\"rand\" value=\"(.+)\">' + + LINK_PATTERN = r'var download_url = \'(.+)\';' + + + def setup(self): + self.resumeDownload = True + self.multiDL = True + + + def handleFree(self): + # Click the free user button + post_data = {'op' : "download1", + 'usr_login' : "", + 'id' : self.info['pattern']['ID'], + 'fname' : self.pyfile.name, + 'referer' : "", + 'method_free': "+"} + + self.html = self.load(self.pyfile.url, post=post_data, cookies=True, decode=True) + + solvemedia = SolveMedia(self) + challenge, response = solvemedia.challenge() + + # Make the downloadlink appear and load the file + m = re.search(self.RAND_ID_PATTERN, self.html) + if m is None: + self.error(_("Random key not found")) + + rand = m.group(1) + self.logDebug("rand = ", rand) + + post_data = {'op' : "download2", + 'id' : self.info['pattern']['ID'], + 'rand' : rand, + 'referer' : self.pyfile.url, + 'method_free' : "+", + 'method_premium' : "", + 'adcopy_response' : response, + 'adcopy_challenge': challenge, + 'down_direct' : "1"} + + self.html = self.load(self.pyfile.url, post=post_data, cookies=True, decode=True) + + m = re.search(self.LINK_PATTERN, self.html) + if m is None: + self.error(_("Download url not found")) + + self.download(m.group(1), cookies=True, disposition=True) + + check = self.checkDownload({'html': re.compile("<html>")}) + if check == "html": + self.error(_("Downloaded file is an html page")) + + +getInfo = create_getInfo(KingfilesNet) diff --git a/module/plugins/hoster/LemUploadsCom.py b/module/plugins/hoster/LemUploadsCom.py index 426a757b3..22fbd60dd 100644 --- a/module/plugins/hoster/LemUploadsCom.py +++ b/module/plugins/hoster/LemUploadsCom.py @@ -1,24 +1,18 @@ # -*- coding: utf-8 -*- -# Test links: -# BigBuckBunny_320x180.mp4 - 61.7 Mb - http://lemuploads.com/uwol0aly9dld +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +class LemUploadsCom(DeadHoster): + __name__ = "LemUploadsCom" + __type__ = "hoster" + __version__ = "0.02" -class LemUploadsCom(XFileSharingPro): - __name__ = "LemUploadsCom" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?lemuploads.com/\w{12}' - __version__ = "0.01" - __description__ = """LemUploads.com hoster plugin""" - __author_name__ = "t4skforce" - __author_mail__ = "t4skforce1337[AT]gmail[DOT]com" - - HOSTER_NAME = "lemuploads.com" + __pattern__ = r'https?://(?:www\.)?lemuploads\.com/\w{12}' - FILE_OFFLINE_PATTERN = r'<b>File Not Found</b><br><br>' - FILE_NAME_PATTERN = r'<b>Password:</b></div>\s*<h2>(?P<N>[^<]+)</h2>' + __description__ = """LemUploads.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("t4skforce", "t4skforce1337[AT]gmail[DOT]com")] getInfo = create_getInfo(LemUploadsCom) diff --git a/module/plugins/hoster/LetitbitNet.py b/module/plugins/hoster/LetitbitNet.py index 58532fd28..a7b11047f 100644 --- a/module/plugins/hoster/LetitbitNet.py +++ b/module/plugins/hoster/LetitbitNet.py @@ -1,40 +1,25 @@ # -*- coding: utf-8 -*- - -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - +# # API Documentation: # http://api.letitbit.net/reg/static/api.pdf - -# Test links (random.bin): +# +# Test links: # http://letitbit.net/download/07874.0b5709a7d3beee2408bb1f2eefce/random.bin.html import re -import urllib -from module.plugins.internal.SimpleHoster import SimpleHoster +from urllib import urlencode, urlopen +from urlparse import urljoin + from module.common.json_layer import json_loads, json_dumps from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster, secondsToMidnight def api_download_info(url): - json_data = ['yw7XQy2v9', ["download/info", {"link": url}]] - post_data = urllib.urlencode({'r': json_dumps(json_data)}) - api_rep = urllib.urlopen('http://api.letitbit.net/json', data=post_data).read() + json_data = ["yw7XQy2v9", ["download/info", {"link": url}]] + post_data = urlencode({'r': json_dumps(json_data)}) + api_rep = urlopen("http://api.letitbit.net/json", data=post_data).read() return json_loads(api_rep) @@ -49,25 +34,27 @@ def getInfo(urls): class LetitbitNet(SimpleHoster): - __name__ = "LetitbitNet" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?(letitbit|shareflare).net/download/.*' - __version__ = "0.23" + __name__ = "LetitbitNet" + __type__ = "hoster" + __version__ = "0.27" + + __pattern__ = r'https?://(?:www\.)?(letitbit|shareflare)\.net/download/.+' + __description__ = """Letitbit.net hoster plugin""" - __author_name__ = ("zoidberg", "z00nx") - __author_mail__ = ("zoidberg@mujmail.cz", "z00nx0@gmail.com") + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("z00nx", "z00nx0@gmail.com")] - CHECK_URL_PATTERN = r"ajax_check_url\s*=\s*'((http://[^/]+)[^']+)';" - SECONDS_PATTERN = r"seconds\s*=\s*(\d+);" - CAPTCHA_CONTROL_FIELD = r"recaptcha_control_field\s=\s'(?P<value>[^']+)'" - DOMAIN = "http://letitbit.net" - FILE_URL_REPLACEMENTS = [(r"(?<=http://)([^/]+)", "letitbit.net")] - RECAPTCHA_KEY = "6Lc9zdMSAAAAAF-7s2wuQ-036pLRbM0p8dDaQdAM" + URL_REPLACEMENTS = [(r"(?<=http://)([^/]+)", "letitbit.net")] + + SECONDS_PATTERN = r'seconds\s*=\s*(\d+);' + CAPTCHA_CONTROL_FIELD = r'recaptcha_control_field\s=\s\'(.+?)\'' + def setup(self): self.resumeDownload = True - #TODO confirm that resume works + def getFileInfo(self): api_rep = api_download_info(self.pyfile.url) @@ -78,92 +65,77 @@ class LetitbitNet(SimpleHoster): else: self.offline() + def handleFree(self): action, inputs = self.parseHtmlForm('id="ifree_form"') if not action: - self.parseError("page 1 / ifree_form") + self.error(_("ifree_form")) + self.pyfile.size = float(inputs['sssize']) self.logDebug(action, inputs) inputs['desc'] = "" - self.html = self.load(self.DOMAIN + action, post=inputs, cookies=True) - - # action, inputs = self.parseHtmlForm('id="d3_form"') - # if not action: self.parseError("page 2 / d3_form") - # #self.logDebug(action, inputs) - # - # self.html = self.load(action, post = inputs, cookies = True) - # - # try: - # ajax_check_url, captcha_url = re.search(self.CHECK_URL_PATTERN, self.html).groups() - # found = re.search(self.SECONDS_PATTERN, self.html) - # seconds = int(found.group(1)) if found else 60 - # self.wait(seconds+1) - # except Exception, e: - # self.logError(e) - # self.parseError("page 3 / js") - - found = re.search(self.SECONDS_PATTERN, self.html) - seconds = int(found.group(1)) if found else 60 + self.html = self.load(urljoin("http://letitbit.net/", action), post=inputs, cookies=True) + + m = re.search(self.SECONDS_PATTERN, self.html) + seconds = int(m.group(1)) if m else 60 self.logDebug("Seconds found", seconds) - found = re.search(self.CAPTCHA_CONTROL_FIELD, self.html) - recaptcha_control_field = found.group(1) + m = re.search(self.CAPTCHA_CONTROL_FIELD, self.html) + recaptcha_control_field = m.group(1) self.logDebug("ReCaptcha control field found", recaptcha_control_field) - self.wait(seconds + 1) + self.wait(seconds) - response = self.load("%s/ajax/download3.php" % self.DOMAIN, post=" ", cookies=True) - if response != '1': - self.parseError('Unknown response - ajax_check_url') - self.logDebug(response) + res = self.load("http://letitbit.net/ajax/download3.php", post=" ", cookies=True) + if res != '1': + self.error(_("Unknown response - ajax_check_url")) + self.logDebug(res) recaptcha = ReCaptcha(self) - challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY) - post_data = {"recaptcha_challenge_field": challenge, "recaptcha_response_field": response, + challenge, response = recaptcha.challenge() + + post_data = {"recaptcha_challenge_field": challenge, + "recaptcha_response_field": response, "recaptcha_control_field": recaptcha_control_field} self.logDebug("Post data to send", post_data) - response = self.load('%s/ajax/check_recaptcha.php' % self.DOMAIN, post=post_data, cookies=True) - self.logDebug(response) - if not response: + res = self.load("http://letitbit.net/ajax/check_recaptcha.php", post=post_data, cookies=True) + self.logDebug(res) + if not res: self.invalidCaptcha() - if response == "error_free_download_blocked": - self.logInfo("Daily limit reached, waiting 24 hours") - self.wait(24 * 60 * 60) - if response == "error_wrong_captcha": - self.logInfo("Wrong Captcha") + if res == "error_free_download_blocked": + self.logWarning(_("Daily limit reached")) + self.wait(secondsToMidnight(gmt=2), True) + if res == "error_wrong_captcha": self.invalidCaptcha() self.retry() - elif response.startswith('['): - urls = json_loads(response) - elif response.startswith('http://'): - urls = [response] + elif res.startswith('['): + urls = json_loads(res) + elif res.startswith('http://'): + urls = [res] else: - self.parseError("Unknown response - captcha check") + self.error(_("Unknown response - captcha check")) self.correctCaptcha() for download_url in urls: try: - self.logDebug("Download URL", download_url) self.download(download_url) break except Exception, e: self.logError(e) else: - self.fail("Download did not finish correctly") + self.fail(_("Download did not finish correctly")) + def handlePremium(self): api_key = self.user - premium_key = self.account.getAccountData(self.user)["password"] + premium_key = self.account.getAccountData(self.user)['password'] json_data = [api_key, ["download/direct_links", {"pass": premium_key, "link": self.pyfile.url}]] api_rep = self.load('http://api.letitbit.net/json', post={'r': json_dumps(json_data)}) - self.logDebug('API Data: ' + api_rep) + self.logDebug("API Data: " + api_rep) api_rep = json_loads(api_rep) if api_rep['status'] == 'FAIL': self.fail(api_rep['data']) - direct_link = api_rep['data'][0][0] - self.logDebug('Direct Link: ' + direct_link) - - self.download(direct_link, disposition=True) + self.download(api_rep['data'][0][0], disposition=True) diff --git a/module/plugins/hoster/LinestorageCom.py b/module/plugins/hoster/LinestorageCom.py new file mode 100644 index 000000000..a3caacc0c --- /dev/null +++ b/module/plugins/hoster/LinestorageCom.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo + + +class LinestorageCom(XFSHoster): + __name__ = "LinestorageCom" + __type__ = "hoster" + __version__ = "0.01" + + __pattern__ = r'http://(?:www\.)?linestorage\.com/\w{12}' + + __description__ = """Linestorage.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = "linestorage.com" + + +getInfo = create_getInfo(LinestorageCom) diff --git a/module/plugins/hoster/LinksnappyCom.py b/module/plugins/hoster/LinksnappyCom.py index 2ed7744d7..90a47d1ac 100644 --- a/module/plugins/hoster/LinksnappyCom.py +++ b/module/plugins/hoster/LinksnappyCom.py @@ -1,68 +1,75 @@ # -*- coding: utf-8 -*- import re + from urlparse import urlsplit -from module.plugins.Hoster import Hoster from module.common.json_layer import json_loads, json_dumps +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo + +class LinksnappyCom(MultiHoster): + __name__ = "LinksnappyCom" + __type__ = "hoster" + __version__ = "0.06" -class LinksnappyCom(Hoster): - __name__ = "LinksnappyCom" - __version__ = "0.02" - __type__ = "hoster" __pattern__ = r'https?://(?:[^/]*\.)?linksnappy\.com' + __description__ = """Linksnappy.com hoster plugin""" - __author_name__ = "stickell" - __author_mail__ = "l.stickell@yahoo.it" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it")] + SINGLE_CHUNK_HOSTERS = ('easybytez.com') + def setup(self): - self.chunkLimit = -1 + self.chunkLimit = -1 self.resumeDownload = True - def process(self, pyfile): - if re.match(self.__pattern__, pyfile.url): - new_url = pyfile.url - elif not self.account: - self.logError(_("Please enter your %s account or deactivate this plugin") % "Linksnappy.com") - self.fail("No Linksnappy.com account provided") - else: - self.logDebug("Old URL: %s" % pyfile.url) - host = self._get_host(pyfile.url) - json_params = json_dumps({'link': pyfile.url, - 'type': host, - 'username': self.user, - 'password': self.account.getAccountData(self.user)["password"]}) - r = self.load('http://gen.linksnappy.com/genAPI.php', - post={'genLinks': json_params}) - self.logDebug("JSON data: " + r) - j = json_loads(r)['links'][0] + def handlePremium(self): + host = self._get_host(self.pyfile.url) + json_params = json_dumps({'link': self.pyfile.url, + 'type': host, + 'username': self.user, + 'password': self.account.getAccountData(self.user)['password']}) + r = self.load('http://gen.linksnappy.com/genAPI.php', + post={'genLinks': json_params}) + self.logDebug("JSON data: " + r) - if j['error']: - self.logError('Error converting the link: %s' % j['error']) - self.fail('Error converting the link') + j = json_loads(r)['links'][0] - pyfile.name = j['filename'] - new_url = j['generated'] + if j['error']: + msg = _("Error converting the link") + self.logError(msg, j['error']) + self.fail(msg) - if host in self.SINGLE_CHUNK_HOSTERS: - self.chunkLimit = 1 - else: - self.setup() + self.pyfile.name = j['filename'] + self.link = j['generated'] - if new_url != pyfile.url: - self.logDebug("New URL: " + new_url) + if host in self.SINGLE_CHUNK_HOSTERS: + self.chunkLimit = 1 + else: + self.setup() - self.download(new_url, disposition=True) + if self.link != self.pyfile.url: + self.logDebug("New URL: " + self.link) + + + def checkFile(self): + super(LinksnappyCom, self).checkFile() check = self.checkDownload({"html302": "<title>302 Found</title>"}) + if check == "html302": - self.retry(wait_time=5, reason="Linksnappy returns only HTML data.") + self.retry(wait_time=5, reason=_("Linksnappy returns only HTML data")) + @staticmethod def _get_host(url): host = urlsplit(url).netloc return re.search(r'[\w-]+\.\w+$', host).group(0) + + +getInfo = create_getInfo(LinksnappyCom) diff --git a/module/plugins/hoster/LoadTo.py b/module/plugins/hoster/LoadTo.py index e52346274..0a5b26410 100644 --- a/module/plugins/hoster/LoadTo.py +++ b/module/plugins/hoster/LoadTo.py @@ -1,90 +1,75 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################ - -# Test links (random.bin): +# +# Test links: # http://www.load.to/JWydcofUY6/random.bin # http://www.load.to/oeSmrfkXE/random100.bin import re +from module.plugins.internal.CaptchaService import SolveMedia from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.plugins.internal.CaptchaService import ReCaptcha class LoadTo(SimpleHoster): - __name__ = "LoadTo" - __type__ = "hoster" + __name__ = "LoadTo" + __type__ = "hoster" + __version__ = "0.18" + __pattern__ = r'http://(?:www\.)?load\.to/\w+' - __version__ = "0.13" - __description__ = """Load.to hoster plugin""" - __author_name__ = ("halfman", "stickell") - __author_mail__ = ("Pulpan3@gmail.com", "l.stickell@yahoo.it") - - FILE_INFO_PATTERN = r'<a [^>]+>(?P<N>.+)</a></h3>\s*Size: (?P<S>\d+) (?P<U>[kKmMgG]?i?[bB])' - URL_PATTERN = r'<form method="post" action="(.+?)"' - FILE_OFFLINE_PATTERN = r'Can\'t find file. Please check URL.' + + __description__ = """ Load.to hoster plugin """ + __license__ = "GPLv3" + __authors__ = [("halfman", "Pulpan3@gmail.com"), + ("stickell", "l.stickell@yahoo.it")] + + + NAME_PATTERN = r'<h1>(?P<N>.+)</h1>' + SIZE_PATTERN = r'Size: (?P<S>[\d.,]+) (?P<U>[\w^_]+)' + OFFLINE_PATTERN = r'>Can\'t find file' + + LINK_PATTERN = r'<form method="post" action="(.+?)"' WAIT_PATTERN = r'type="submit" value="Download \((\d+)\)"' - RECAPTCHA_PATTERN = r'http://www.google.com/recaptcha/api/challenge' - RECAPTCHA_KEY = "6Lc34eISAAAAAKNbPVyxBgNriTjPRmF-FA1oxApG" + + URL_REPLACEMENTS = [(r'(\w)$', r'\1/')] + def setup(self): self.multiDL = True self.chunkLimit = 1 - def process(self, pyfile): - self.html = self.load(pyfile.url, decode=True) - self.getFileInfo() - - # Check if File is online - if re.search(self.FILE_OFFLINE_PATTERN, self.html): - self.offline() + def handleFree(self): # Search for Download URL - m = re.search(self.URL_PATTERN, self.html) - if not m: - self.parseError('Unable to detect download URL') + m = re.search(self.LINK_PATTERN, self.html) + if m is None: + self.error(_("LINK_PATTERN not found")) + download_url = m.group(1) # Set Timer - may be obsolete m = re.search(self.WAIT_PATTERN, self.html) if m: - self.wait(m.group(1)) + self.wait(int(m.group(1))) - # Check if reCaptcha is present - m = re.search(self.RECAPTCHA_PATTERN, self.html) - if not m: # No captcha found + # Load.to is using solvemedia captchas since ~july 2014: + solvemedia = SolveMedia(self) + captcha_key = solvemedia.detect_key() + + if captcha_key is None: self.download(download_url) else: - recaptcha = ReCaptcha(self) - for _ in xrange(5): - challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY) - if not response == '0': - break - else: - self.fail("No valid captcha solution received") - - self.download(download_url, - post={'recaptcha_challenge_field': challenge, 'recaptcha_response_field': response}) - - # Verifiy reCaptcha by checking content of file for html 404-error - check = self.checkDownload({"404": re.compile("\A<h1>404 Not Found</h1>")}) + challenge, response = solvemedia.challenge(captcha_key) + + self.download(download_url, post={"adcopy_challenge": challenge, "adcopy_response": response}) + + check = self.checkDownload({'404': re.compile("\A<h1>404 Not Found</h1>"), 'html': re.compile("html")}) + if check == "404": - self.logWarning("The captcha you entered was incorrect. Please try again.") self.invalidCaptcha() self.retry() + elif check == "html": + self.logWarning(_("Downloaded file is an html page, will retry")) + self.retry() getInfo = create_getInfo(LoadTo) diff --git a/module/plugins/hoster/LomafileCom.py b/module/plugins/hoster/LomafileCom.py new file mode 100644 index 000000000..475cdacaa --- /dev/null +++ b/module/plugins/hoster/LomafileCom.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo + + +class LomafileCom(DeadHoster): + __name__ = "LomafileCom" + __type__ = "hoster" + __version__ = "0.52" + + __pattern__ = r'http://lomafile\.com/\w{12}' + + __description__ = """Lomafile.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("nath_schwarz", "nathan.notwhite@gmail.com"), + ("guidobelix", "guidobelix@hotmail.it")] + + +getInfo = create_getInfo(LomafileCom) diff --git a/module/plugins/hoster/LuckyShareNet.py b/module/plugins/hoster/LuckyShareNet.py index 75520a6cf..2c33b57e7 100644 --- a/module/plugins/hoster/LuckyShareNet.py +++ b/module/plugins/hoster/LuckyShareNet.py @@ -1,70 +1,72 @@ # -*- coding: utf-8 -*- import re -from module.lib.bottle import json_loads -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from bottle import json_loads + from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class LuckyShareNet(SimpleHoster): - __name__ = "LuckyShareNet" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?luckyshare.net/(?P<ID>\d{10,})' - __version__ = "0.02" + __name__ = "LuckyShareNet" + __type__ = "hoster" + __version__ = "0.04" + + __pattern__ = r'https?://(?:www\.)?luckyshare\.net/(?P<ID>\d{10,})' + __description__ = """LuckyShare.net hoster plugin""" - __author_name__ = "stickell" - __author_mail__ = "l.stickell@yahoo.it" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it")] + + + INFO_PATTERN = r'<h1 class=\'file_name\'>(?P<N>\S+)</h1>\s*<span class=\'file_size\'>Filesize: (?P<S>[\d.,]+)(?P<U>[\w^_]+)</span>' + OFFLINE_PATTERN = r'There is no such file available' - FILE_INFO_PATTERN = r"<h1 class='file_name'>(?P<N>\S+)</h1>\s*<span class='file_size'>Filesize: (?P<S>[\d.]+)(?P<U>\w+)</span>" - FILE_OFFLINE_PATTERN = 'There is no such file available' - RECAPTCHA_KEY = '6LdivsgSAAAAANWh-d7rPE1mus4yVWuSQIJKIYNw' def parseJson(self, rep): if 'AJAX Error' in rep: html = self.load(self.pyfile.url, decode=True) m = re.search(r"waitingtime = (\d+);", html) if m: - waittime = int(m.group(1)) - self.logDebug('You have to wait %d seconds between free downloads' % waittime) - self.retry(wait_time=waittime) + seconds = int(m.group(1)) + self.logDebug("You have to wait %d seconds between free downloads" % seconds) + self.retry(wait_time=seconds) else: - self.parseError('Unable to detect wait time between free downloads') + self.error(_("Unable to detect wait time between free downloads")) elif 'Hash expired' in rep: - self.retry(reason="Hash expired") + self.retry(reason=_("Hash expired")) return json_loads(rep) + # TODO: There should be a filesize limit for free downloads # TODO: Some files could not be downloaded in free mode def handleFree(self): - file_id = re.match(self.__pattern__, self.pyfile.url).group('ID') - self.logDebug('File ID: ' + file_id) - rep = self.load(r"http://luckyshare.net/download/request/type/time/file/" + file_id, decode=True) - self.logDebug('JSON: ' + rep) + rep = self.load(r"http://luckyshare.net/download/request/type/time/file/" + self.info['pattern']['ID'], decode=True) + self.logDebug("JSON: " + rep) json = self.parseJson(rep) self.wait(int(json['time'])) recaptcha = ReCaptcha(self) - for _ in xrange(5): - challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY) + + for _i in xrange(5): + challenge, response = recaptcha.challenge() rep = self.load(r"http://luckyshare.net/download/verify/challenge/%s/response/%s/hash/%s" % (challenge, response, json['hash']), decode=True) - self.logDebug('JSON: ' + rep) + self.logDebug("JSON: " + rep) if 'link' in rep: json.update(self.parseJson(rep)) self.correctCaptcha() break elif 'Verification failed' in rep: - self.logInfo('Wrong captcha') self.invalidCaptcha() else: - self.parseError('Unable to get downlaod link') + self.error(_("Unable to get downlaod link")) if not json['link']: - self.fail("No Download url retrieved/all captcha attempts failed") + self.fail(_("No Download url retrieved/all captcha attempts failed")) - self.logDebug('Direct URL: ' + json['link']) self.download(json['link']) diff --git a/module/plugins/hoster/MediafireCom.py b/module/plugins/hoster/MediafireCom.py index 52e38aada..782d78ce1 100644 --- a/module/plugins/hoster/MediafireCom.py +++ b/module/plugins/hoster/MediafireCom.py @@ -1,25 +1,9 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re -from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo + from module.plugins.internal.CaptchaService import SolveMedia +from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo from module.network.RequestFactory import getURL @@ -29,68 +13,76 @@ def replace_eval(js_expr): def checkHTMLHeader(url): try: - for _ in xrange(3): + for _i in xrange(3): header = getURL(url, just_header=True) + for line in header.splitlines(): line = line.lower() + if 'location' in line: url = line.split(':', 1)[1].strip() if 'error.php?errno=320' in url: return url, 1 + if not url.startswith('http://'): url = 'http://www.mediafire.com' + url + break + elif 'content-disposition' in line: return url, 2 else: break except: return url, 3 - - return url, 0 + else: + return url, 0 def getInfo(urls): for url in urls: location, status = checkHTMLHeader(url) + if status: file_info = (url, 0, status, url) else: file_info = parseFileInfo(MediafireCom, url, getURL(url, decode=True)) + yield file_info class MediafireCom(SimpleHoster): - __name__ = "MediafireCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?mediafire\.com/(file/|(view/?|download.php)?\?)(\w{11}|\w{15})($|/)' - __version__ = "0.79" + __name__ = "MediafireCom" + __type__ = "hoster" + __version__ = "0.82" + + __pattern__ = r'http://(?:www\.)?mediafire\.com/(file/|(view/?|download\.php)?\?)(\w{11}|\w{15})($|/)' + __description__ = """Mediafire.com hoster plugin""" - __author_name__ = ("zoidberg", "stickell") - __author_mail__ = ("zoidberg@mujmail.cz", "l.stickell@yahoo.it") - - DOWNLOAD_LINK_PATTERN = r'<div class="download_link"[^>]*(?:z-index:(?P<zindex>\d+))?[^>]*>\s*<a href="(?P<href>http://[^"]+)"' - JS_KEY_PATTERN = r"DoShow\('mfpromo1'\);[^{]*{((\w+)='';.*?)eval\(\2\);" - JS_ZMODULO_PATTERN = r"\('z-index'\)\) \% (\d+)\)\);" - SOLVEMEDIA_PATTERN = r'http://api\.solvemedia\.com/papi/challenge\.noscript\?k=([^"]+)' - PAGE1_ACTION_PATTERN = r'<link rel="canonical" href="([^"]+)"/>' + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it")] + + + NAME_PATTERN = r'<META NAME="description" CONTENT="(?P<N>[^"]+)"/>' + INFO_PATTERN = r'oFileSharePopup\.ald\(\'(?P<ID>[^\']*)\',\'(?P<N>[^\']*)\',\'(?P<S>[^\']*)\',\'\',\'(?P<H>[^\']*)\'\)' + OFFLINE_PATTERN = r'class="error_msg_title"> Invalid or Deleted File. </div>' + PASSWORD_PATTERN = r'<form name="form_password"' - FILE_NAME_PATTERN = r'<META NAME="description" CONTENT="(?P<N>[^"]+)"/>' - FILE_INFO_PATTERN = r"oFileSharePopup\.ald\('(?P<ID>[^']*)','(?P<N>[^']*)','(?P<S>[^']*)','','(?P<sha256>[^']*)'\)" - FILE_OFFLINE_PATTERN = r'class="error_msg_title"> Invalid or Deleted File. </div>' def setup(self): self.multiDL = False + def process(self, pyfile): pyfile.url = re.sub(r'/view/?\?', '/?', pyfile.url) - self.url, result = checkHTMLHeader(pyfile.url) - self.logDebug('Location (%d): %s' % (result, self.url)) + self.link, result = checkHTMLHeader(pyfile.url) + self.logDebug("Location (%d): %s" % (result, self.link)) if result == 0: - self.html = self.load(self.url, decode=True) + self.html = self.load(self.link, decode=True) self.checkCaptcha() self.multiDL = True self.check_data = self.getFileInfo() @@ -103,36 +95,34 @@ class MediafireCom(SimpleHoster): self.offline() else: self.multiDL = True - self.download(self.url, disposition=True) + self.download(self.link, disposition=True) + def handleFree(self): - passwords = self.getPassword().splitlines() - while self.PASSWORD_PATTERN in self.html: - if len(passwords): - password = passwords.pop(0) - self.logInfo("Password protected link, trying " + password) - self.html = self.load(self.url, post={"downloadp": password}) + if self.PASSWORD_PATTERN in self.html: + password = self.getPassword() + + if password: + self.logInfo(_("Password protected link, trying ") + password) + self.html = self.load(self.link, post={"downloadp": password}) + + if self.PASSWORD_PATTERN in self.html: + self.fail(_("Incorrect password")) else: - self.fail("No or incorrect password") + self.fail(_("No password found")) - found = re.search(r'kNO = "(http://.*?)";', self.html) - if not found: - self.parseError("Download URL") - download_url = found.group(1) - self.logDebug("DOWNLOAD LINK:", download_url) + m = re.search(r'kNO = r"(http://.*?)";', self.html) + if m is None: + self.error(_("No download URL")) + download_url = m.group(1) self.download(download_url) + def checkCaptcha(self): - for _ in xrange(5): - found = re.search(self.SOLVEMEDIA_PATTERN, self.html) - if found: - captcha_key = found.group(1) - solvemedia = SolveMedia(self) - captcha_challenge, captcha_response = solvemedia.challenge(captcha_key) - self.html = self.load(self.url, post={"adcopy_challenge": captcha_challenge, - "adcopy_response": captcha_response}, decode=True) - else: - break - else: - self.fail("No valid recaptcha solution received") + solvemedia = SolveMedia(self) + challenge, response = solvemedia.challenge() + self.html = self.load(self.link, + post={'adcopy_challenge': challenge, + 'adcopy_response' : response}, + decode=True) diff --git a/module/plugins/hoster/MegaCoNz.py b/module/plugins/hoster/MegaCoNz.py new file mode 100644 index 000000000..00f38ff06 --- /dev/null +++ b/module/plugins/hoster/MegaCoNz.py @@ -0,0 +1,191 @@ +# -*- coding: utf-8 -*- + +import random +import re + +from array import array +from base64 import standard_b64decode +from os import remove + +from Crypto.Cipher import AES +from Crypto.Util import Counter +# from pycurl import SSL_CIPHER_LIST + +from module.common.json_layer import json_loads, json_dumps +from module.plugins.Hoster import Hoster + + +############################ General errors ################################### +# EINTERNAL (-1): An internal error has occurred. Please submit a bug report, detailing the exact circumstances in which this error occurred +# EARGS (-2): You have passed invalid arguments to this command +# EAGAIN (-3): (always at the request level) A temporary congestion or server malfunction prevented your request from being processed. No data was altered. Retry. Retries must be spaced with exponential backoff +# ERATELIMIT (-4): You have exceeded your command weight per time quota. Please wait a few seconds, then try again (this should never happen in sane real-life applications) +# +############################ Upload errors #################################### +# EFAILED (-5): The upload failed. Please restart it from scratch +# ETOOMANY (-6): Too many concurrent IP addresses are accessing this upload target URL +# ERANGE (-7): The upload file packet is out of range or not starting and ending on a chunk boundary +# EEXPIRED (-8): The upload target URL you are trying to access has expired. Please request a fresh one +# +############################ Stream/System errors ############################# +# ENOENT (-9): Object (typically, node or user) not found +# ECIRCULAR (-10): Circular linkage attempted +# EACCESS (-11): Access violation (e.g., trying to write to a read-only share) +# EEXIST (-12): Trying to create an object that already exists +# EINCOMPLETE (-13): Trying to access an incomplete resource +# EKEY (-14): A decryption operation failed (never returned by the API) +# ESID (-15): Invalid or expired user session, please relogin +# EBLOCKED (-16): User blocked +# EOVERQUOTA (-17): Request over quota +# ETEMPUNAVAIL (-18): Resource temporarily not available, please try again later +# ETOOMANYCONNECTIONS (-19): Too many connections on this resource +# EWRITE (-20): Write failed +# EREAD (-21): Read failed +# EAPPKEY (-22): Invalid application key; request not processed + + +class MegaCoNz(Hoster): + __name__ = "MegaCoNz" + __type__ = "hoster" + __version__ = "0.21" + + __pattern__ = r'https?://(?:www\.)?mega\.co\.nz/#(?P<TYPE>N)?!(?P<ID>[\w^_]+)!(?P<KEY>[\w,\\-]+)' + + __description__ = """Mega.co.nz hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("RaNaN", "ranan@pyload.org"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + API_URL = "https://eu.api.mega.co.nz/cs" + FILE_SUFFIX = ".crypted" + + + def b64_decode(self, data): + data = data.replace("-", "+").replace("_", "/") + return standard_b64decode(data + '=' * (-len(data) % 4)) + + + def getCipherKey(self, key): + """ Construct the cipher key from the given data """ + key = self.b64_decode(key) + + k = key[0] ^ key[4], key[1] ^ key[5], key[2] ^ key[6], key[3] ^ key[7] + iv = key[4:6] + (0, 0) + meta_mac = key[6:8] + + return k, iv, meta_mac + + + def api_response(self, **kwargs): + """ Dispatch a call to the api, see https://mega.co.nz/#developers """ + + # generate a session id, no idea where to obtain elsewhere + uid = random.randint(10 << 9, 10 ** 10) + + res = self.load(self.API_URL, get={'id': uid}, post=json_dumps([kwargs])) + self.logDebug("Api Response: " + res) + return json_loads(res) + + + def decryptAttr(self, data, key): + k, iv, meta_mac = self.getCipherKey(key) + cbc = AES.new(k, AES.MODE_CBC, "\0" * 16) + attr = cbc.decrypt(self.b64_decode(data)) + + self.logDebug("Decrypted Attr: " + attr) + if not attr.startswith("MEGA"): + self.fail(_("Decryption failed")) + + # Data is padded, 0-bytes must be stripped + return json_loads(re.search(r'{.+?}', attr).group(0)) + + + def decryptFile(self, key): + """ Decrypts the file at lastDownload` """ + + # upper 64 bit of counter start + n = self.b64_decode(key)[16:24] + + # convert counter to long and shift bytes + k, iv, meta_mac = self.getCipherKey(key) + ctr = Counter.new(128, initial_value=long(n.encode("hex"), 16) << 64) + cipher = AES.new(k, AES.MODE_CTR, counter=ctr) + + self.pyfile.setStatus("decrypting") + + file_crypted = self.lastDownload + file_decrypted = file_crypted.rsplit(self.FILE_SUFFIX)[0] + + try: + f = open(file_crypted, "rb") + df = open(file_decrypted, "wb") + + except IOError, e: + self.fail(str(e)) + + chunk_size = 2 ** 15 # buffer size, 32k + # file_mac = [0, 0, 0, 0] # calculate CBC-MAC for checksum + + while True: + buf = f.read(chunk_size) + if not buf: + break + + chunk = cipher.decrypt(buf) + df.write(chunk) + + f.close() + df.close() + + remove(file_crypted) + self.lastDownload = file_decrypted + + + def checkError(self, code): + ecode = abs(code) + + if ecode in (9, 16, 21): + self.offline() + + elif ecode in (3, 13, 17, 18, 19): + self.tempOffline() + + elif ecode in (1, 4, 6, 10, 15, 21): + self.retry(5, 30, _("Error code: [%s]") % -ecode) + + else: + self.fail(_("Error code: [%s]") % -ecode) + + + def process(self, pyfile): + pattern = re.match(self.__pattern__, pyfile.url).groupdict() + id = pattern['ID'] + key = pattern['KEY'] + public = 'TYPE' not in pattern + + self.logDebug("ID: %s" % id, "Key: %s" % key, "Type: %s" % ("public" if public else "node")) + + # g is for requesting a download url + # this is similar to the calls in the mega js app, documentation is very bad + if public: + mega = self.api_response(a="g", g=1, p=id, ssl=1)[0] + else: + mega = self.api_response(a="g", g=1, n=id, ssl=1)[0] + + if "e" in mega: + self.checkError(mega['e']) + + attr = self.decryptAttr(mega['at'], key) + + pyfile.name = attr['n'] + self.FILE_SUFFIX + pyfile.size = mega['s'] + + # self.req.http.c.setopt(SSL_CIPHER_LIST, "RC4-MD5:DEFAULT") + + self.download(mega['g']) + + self.decryptFile(key) + + # Everything is finished and final name can be set + pyfile.name = attr['n'] diff --git a/module/plugins/hoster/MegaDebridEu.py b/module/plugins/hoster/MegaDebridEu.py index 46eb0eb11..6e24cc7ba 100644 --- a/module/plugins/hoster/MegaDebridEu.py +++ b/module/plugins/hoster/MegaDebridEu.py @@ -1,61 +1,46 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################ import re + from urllib import unquote_plus -from module.plugins.Hoster import Hoster from module.common.json_layer import json_loads +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo + + +class MegaDebridEu(MultiHoster): + __name__ = "MegaDebridEu" + __type__ = "hoster" + __version__ = "0.45" + __pattern__ = r'http://((?:www\d+\.|s\d+\.)?mega-debrid\.eu|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/download/file/[\w^_]+' -class MegaDebridEu(Hoster): - __name__ = "MegaDebridEu" - __version__ = "0.3" - __type__ = "hoster" - __pattern__ = r'^https?://(?:w{3}\d+\.mega-debrid.eu|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/download/file/[^/]+/.+$' __description__ = """mega-debrid.eu hoster plugin""" - __author_name__ = "D.Ducatel" - __author_mail__ = "dducatel@je-geek.fr" + __license__ = "GPLv3" + __authors__ = [("D.Ducatel", "dducatel@je-geek.fr")] + - # Define the base URL of MegaDebrid api API_URL = "https://www.mega-debrid.eu/api.php" + def getFilename(self, url): try: return unquote_plus(url.rsplit("/", 1)[1]) except IndexError: return "" - def process(self, pyfile): - if re.match(self.__pattern__, pyfile.url): - new_url = pyfile.url - elif not self.account: - self.exitOnFail(_("Please enter your %s account or deactivate this plugin") % "Mega-debrid.eu") - else: - if not self.connectToApi(): - self.exitOnFail(_("Impossible to connect to %s") % "Mega-debrid.eu") - self.logDebug("Old URL: %s" % pyfile.url) - new_url = self.debridLink(pyfile.url) - self.logDebug("New URL: " + new_url) + def handlePremium(self): + if not self.connectToApi(): + self.exitOnFail("Unable to connect to Mega-debrid.eu") - filename = self.getFilename(new_url) + self.link = self.debridLink(self.pyfile.url) + self.logDebug("New URL: " + self.link) + + filename = self.getFilename(self.link) if filename != "": - pyfile.name = filename - self.download(new_url, disposition=True) + self.pyfile.name = filename + def connectToApi(self): """ @@ -64,15 +49,16 @@ class MegaDebridEu(Hoster): """ user, data = self.account.selectAccount() jsonResponse = self.load(self.API_URL, - get={'action': 'connectUser', 'login': user, 'password': data["password"]}) - response = json_loads(jsonResponse) + get={'action': 'connectUser', 'login': user, 'password': data['password']}) + res = json_loads(jsonResponse) - if response["response_code"] == "ok": - self.token = response["token"] + if res['response_code'] == "ok": + self.token = res['token'] return True else: return False + def debridLink(self, linkToDebrid): """ Debrid a link @@ -80,13 +66,14 @@ class MegaDebridEu(Hoster): """ jsonResponse = self.load(self.API_URL, get={'action': 'getLink', 'token': self.token}, post={"link": linkToDebrid}) - response = json_loads(jsonResponse) + res = json_loads(jsonResponse) - if response["response_code"] == "ok": - debridedLink = response["debridLink"][1:-1] + if res['response_code'] == "ok": + debridedLink = res['debridLink'][1:-1] return debridedLink else: - self.exitOnFail(_("Impossible to debrid %s") % linkToDebrid) + self.exitOnFail("Unable to debrid %s" % linkToDebrid) + def exitOnFail(self, msg): """ @@ -94,7 +81,10 @@ class MegaDebridEu(Hoster): And display the reason of this failure """ if self.getConfig("unloadFailing"): - self.logError(msg) + self.logError(_(msg)) self.resetAccount() else: - self.fail(msg) + self.fail(_(msg)) + + +getInfo = create_getInfo(MegaDebridEu) diff --git a/module/plugins/hoster/MegaFilesSe.py b/module/plugins/hoster/MegaFilesSe.py index 43601bdb1..c3de57914 100644 --- a/module/plugins/hoster/MegaFilesSe.py +++ b/module/plugins/hoster/MegaFilesSe.py @@ -1,21 +1,18 @@ # -*- coding: utf-8 -*- -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo -class MegaFilesSe(XFileSharingPro): - __name__ = "MegaFilesSe" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?megafiles\.se/\w{12}' - __version__ = "0.01" - __description__ = """MegaFiles.se hoster plugin""" - __author_name__ = "t4skforce" - __author_mail__ = "t4skforce1337[AT]gmail[DOT]com" +class MegaFilesSe(DeadHoster): + __name__ = "MegaFilesSe" + __type__ = "hoster" + __version__ = "0.02" - HOSTER_NAME = "megafiles.se" + __pattern__ = r'http://(?:www\.)?megafiles\.se/\w{12}' - FILE_OFFLINE_PATTERN = r'<b><font[^>]*>File Not Found</font></b><br><br>' - FILE_NAME_PATTERN = r'<div[^>]+>\s*<b>(?P<N>[^<]+)</b>\s*</div>' + __description__ = """MegaFiles.se hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("t4skforce", "t4skforce1337[AT]gmail[DOT]com")] getInfo = create_getInfo(MegaFilesSe) diff --git a/module/plugins/hoster/MegaNz.py b/module/plugins/hoster/MegaNz.py deleted file mode 100644 index a55220bc2..000000000 --- a/module/plugins/hoster/MegaNz.py +++ /dev/null @@ -1,132 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -import random -from array import array -from os import remove -from base64 import standard_b64decode - -from Crypto.Cipher import AES -from Crypto.Util import Counter - -from module.common.json_layer import json_loads, json_dumps -from module.plugins.Hoster import Hoster - -#def getInfo(urls): -# pass - - -class MegaNz(Hoster): - __name__ = "MegaNz" - __type__ = "hoster" - __pattern__ = r'https?://([a-z0-9]+\.)?mega\.co\.nz/#!([a-zA-Z0-9!_\-]+)' - __version__ = "0.14" - __description__ = """Mega.co.nz hoster plugin""" - __author_name__ = ("RaNaN", ) - __author_mail__ = ("ranan@pyload.org", ) - - API_URL = "https://g.api.mega.co.nz/cs?id=%d" - FILE_SUFFIX = ".crypted" - - def b64_decode(self, data): - data = data.replace("-", "+").replace("_", "/") - return standard_b64decode(data + '=' * (-len(data) % 4)) - - def getCipherKey(self, key): - """ Construct the cipher key from the given data """ - a = array("I", key) - key_array = array("I", [a[0] ^ a[4], a[1] ^ a[5], a[2] ^ a[6], a[3] ^ a[7]]) - return key_array - - def callApi(self, **kwargs): - """ Dispatch a call to the api, see https://mega.co.nz/#developers """ - # generate a session id, no idea where to obtain elsewhere - uid = random.randint(10 << 9, 10 ** 10) - - resp = self.load(self.API_URL % uid, post=json_dumps([kwargs])) - self.logDebug("Api Response: " + resp) - return json_loads(resp) - - def decryptAttr(self, data, key): - - cbc = AES.new(self.getCipherKey(key), AES.MODE_CBC, "\0" * 16) - attr = cbc.decrypt(self.b64_decode(data)) - self.logDebug("Decrypted Attr: " + attr) - if not attr.startswith("MEGA"): - self.fail(_("Decryption failed")) - - # Data is padded, 0-bytes must be stripped - return json_loads(attr.replace("MEGA", "").rstrip("\0").strip()) - - def decryptFile(self, key): - """ Decrypts the file at lastDownload` """ - - # upper 64 bit of counter start - n = key[16:24] - - # convert counter to long and shift bytes - ctr = Counter.new(128, initial_value=long(n.encode("hex"), 16) << 64) - cipher = AES.new(self.getCipherKey(key), AES.MODE_CTR, counter=ctr) - - self.pyfile.setStatus("decrypting") - - file_crypted = self.lastDownload - file_decrypted = file_crypted.rsplit(self.FILE_SUFFIX)[0] - f = open(file_crypted, "rb") - df = open(file_decrypted, "wb") - - # TODO: calculate CBC-MAC for checksum - - size = 2 ** 15 # buffer size, 32k - while True: - buf = f.read(size) - if not buf: - break - - df.write(cipher.decrypt(buf)) - - f.close() - df.close() - remove(file_crypted) - - self.lastDownload = file_decrypted - - def process(self, pyfile): - - key = None - - # match is guaranteed because plugin was chosen to handle url - node = re.match(self.__pattern__, pyfile.url).group(2) - if "!" in node: - node, key = node.split("!") - - self.logDebug("File id: %s | Key: %s" % (node, key)) - - if not key: - self.fail(_("No file key provided in the URL")) - - # g is for requesting a download url - # this is similar to the calls in the mega js app, documentation is very bad - dl = self.callApi(a="g", g=1, p=node, ssl=1)[0] - - if "e" in dl: - e = dl["e"] - # ETEMPUNAVAIL (-18): Resource temporarily not available, please try again later - if e == -18: - self.retry() - else: - self.fail(_("Error code:") + e) - - # TODO: map other error codes, e.g - # EACCESS (-11): Access violation (e.g., trying to write to a read-only share) - - key = self.b64_decode(key) - attr = self.decryptAttr(dl["at"], key) - - pyfile.name = attr["n"] + self.FILE_SUFFIX - - self.download(dl["g"]) - self.decryptFile(key) - - # Everything is finished and final name can be set - pyfile.name = attr["n"] diff --git a/module/plugins/hoster/MegaRapidCz.py b/module/plugins/hoster/MegaRapidCz.py new file mode 100644 index 000000000..37732ade6 --- /dev/null +++ b/module/plugins/hoster/MegaRapidCz.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- + +import re + +from pycurl import HTTPHEADER + +from module.network.RequestFactory import getRequest +from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo + + +def getInfo(urls): + h = getRequest() + h.c.setopt(HTTPHEADER, + ["Accept: text/html", + "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0"]) + + for url in urls: + html = h.load(url, decode=True) + yield parseFileInfo(MegaRapidCz, url, html) + + +class MegaRapidCz(SimpleHoster): + __name__ = "MegaRapidCz" + __type__ = "hoster" + __version__ = "0.55" + + __pattern__ = r'http://(?:www\.)?(share|mega)rapid\.cz/soubor/\d+/.+' + + __description__ = """MegaRapid.cz hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("MikyWoW", "mikywow@seznam.cz"), + ("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + NAME_PATTERN = r'<h1[^>]*><span[^>]*>(?:<a[^>]*>)?(?P<N>[^<]+)' + SIZE_PATTERN = r'<td class="i">Velikost:</td>\s*<td class="h"><strong>\s*(?P<S>[\d.,]+) (?P<U>[\w^_]+)</strong></td>' + OFFLINE_PATTERN = ur'Nastala chyba 404|Soubor byl smazán' + + CHECK_TRAFFIC = True + + LINK_PATTERN = r'<a href="([^"]+)" title="Stahnout">([^<]+)</a>' + ERR_LOGIN_PATTERN = ur'<div class="error_div"><strong>Stahování je přístupné pouze přihlášeným uživatelům' + ERR_CREDIT_PATTERN = ur'<div class="error_div"><strong>Stahování zdarma je možné jen přes náš' + + + def setup(self): + self.chunkLimit = 1 + + + def handlePremium(self): + try: + self.html = self.load(self.pyfile.url, decode=True) + except BadHeader, e: + self.account.relogin(self.user) + self.retry(wait_time=60, reason=str(e)) + + m = re.search(self.LINK_PATTERN, self.html) + if m: + link = m.group(1) + self.logDebug("Premium link: %s" % link) + self.download(link, disposition=True) + else: + if re.search(self.ERR_LOGIN_PATTERN, self.html): + self.relogin(self.user) + self.retry(wait_time=60, reason=_("User login failed")) + elif re.search(self.ERR_CREDIT_PATTERN, self.html): + self.fail(_("Not enough credit left")) + else: + self.fail(_("Download link not found")) diff --git a/module/plugins/hoster/MegacrypterCom.py b/module/plugins/hoster/MegacrypterCom.py index 8b72606ce..4034f7d32 100644 --- a/module/plugins/hoster/MegacrypterCom.py +++ b/module/plugins/hoster/MegacrypterCom.py @@ -3,27 +3,33 @@ import re from module.common.json_layer import json_loads, json_dumps -from module.plugins.hoster.MegaNz import MegaNz +from module.plugins.hoster.MegaCoNz import MegaCoNz + + +class MegacrypterCom(MegaCoNz): + __name__ = "MegacrypterCom" + __type__ = "hoster" + __version__ = "0.21" + + __pattern__ = r'(https?://\w{0,10}\.?megacrypter\.com/[\w!-]+)' -class MegacrypterCom(MegaNz): - __name__ = "MegacrypterCom" - __type__ = "hoster" - __pattern__ = r'(https?://[a-z0-9]{0,10}\.?megacrypter\.com/[a-zA-Z0-9!_\-]+)' - __version__ = "0.2" __description__ = """Megacrypter.com decrypter plugin""" - __author_name__ = ("GonzaloSR", ) - __author_mail__ = ("gonzalo@gonzalosr.com", ) + __license__ = "GPLv3" + __authors__ = [("GonzaloSR", "gonzalo@gonzalosr.com")] + API_URL = "http://megacrypter.com/api" FILE_SUFFIX = ".crypted" + def callApi(self, **kwargs): """ Dispatch a call to the api, see megacrypter.com/api_doc """ self.logDebug("JSON request: " + json_dumps(kwargs)) - resp = self.load(self.API_URL, post=json_dumps(kwargs)) - self.logDebug("API Response: " + resp) - return json_loads(resp) + res = self.load(self.API_URL, post=json_dumps(kwargs)) + self.logDebug("API Response: " + res) + return json_loads(res) + def process(self, pyfile): # match is guaranteed because plugin was chosen to handle url @@ -36,15 +42,15 @@ class MegacrypterCom(MegaNz): dl = self.callApi(link=node, m="dl") # TODO: map error codes, implement password protection - # if info["pass"] == true: - # crypted_file_key, md5_file_key = info["key"].split("#") + # if info['pass'] is True: + # crypted_file_key, md5_file_key = info['key'].split("#") - key = self.b64_decode(info["key"]) + key = self.b64_decode(info['key']) - pyfile.name = info["name"] + self.FILE_SUFFIX + pyfile.name = info['name'] + self.FILE_SUFFIX - self.download(dl["url"]) + self.download(dl['url']) self.decryptFile(key) # Everything is finished and final name can be set - pyfile.name = info["name"] + pyfile.name = info['name'] diff --git a/module/plugins/hoster/MegareleaseOrg.py b/module/plugins/hoster/MegareleaseOrg.py index cb8c7aa01..60796c1ee 100644 --- a/module/plugins/hoster/MegareleaseOrg.py +++ b/module/plugins/hoster/MegareleaseOrg.py @@ -1,33 +1,19 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################ -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo -class MegareleaseOrg(XFileSharingPro): - __name__ = "MegareleaseOrg" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?megarelease.org/\w{12}' - __version__ = "0.01" - __description__ = """Megarelease.org hoster plugin""" - __author_name__ = ("derek3x", "stickell") - __author_mail__ = ("derek3x@vmail.me", "l.stickell@yahoo.it") +class MegareleaseOrg(DeadHoster): + __name__ = "MegareleaseOrg" + __type__ = "hoster" + __version__ = "0.02" + + __pattern__ = r'https?://(?:www\.)?megarelease\.org/\w{12}' - HOSTER_NAME = "megarelease.org" + __description__ = """Megarelease.org hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("derek3x", "derek3x@vmail.me"), + ("stickell", "l.stickell@yahoo.it")] - FILE_INFO_PATTERN = r'<font color="red">%s/(?P<N>.+)</font> \((?P<S>[^)]+)\)</font>' % __pattern__ getInfo = create_getInfo(MegareleaseOrg) diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py index b73b4943c..9d8441c6f 100644 --- a/module/plugins/hoster/MegasharesCom.py +++ b/module/plugins/hoster/MegasharesCom.py @@ -1,113 +1,111 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re + from time import time + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class MegasharesCom(SimpleHoster): - __name__ = "MegasharesCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?megashares.com/.*' - __version__ = "0.24" + __name__ = "MegasharesCom" + __type__ = "hoster" + __version__ = "0.27" + + __pattern__ = r'http://(?:www\.)?(d\d{2}\.)?megashares\.com/((index\.php)?\?d\d{2}=|dl/)\w+' + __description__ = """Megashares.com hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" - - FILE_NAME_PATTERN = '<h1 class="black xxl"[^>]*title="(?P<N>[^"]+)">' - FILE_SIZE_PATTERN = '<strong><span class="black">Filesize:</span></strong> (?P<S>[0-9.]+) (?P<U>[kKMG])i?B<br />' - DOWNLOAD_URL_PATTERN = r'<div id="show_download_button_%d"[^>]*>\s*<a href="([^"]+)">' - PASSPORT_LEFT_PATTERN = r'Your Download Passport is: <[^>]*>(\w+).*\s*You have\s*<[^>]*>\s*([0-9.]+) ([kKMG]i?B)' - PASSPORT_RENEW_PATTERN = r'Your download passport will renew in\s*<strong>(\d+)</strong>:<strong>(\d+)</strong>:<strong>(\d+)</strong>' + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + NAME_PATTERN = r'<h1 class="black xxl"[^>]*title="(?P<N>[^"]+)">' + SIZE_PATTERN = r'<strong><span class="black">Filesize:</span></strong> (?P<S>[\d.,]+) (?P<U>[\w^_]+)' + OFFLINE_PATTERN = r'<dd class="red">(Invalid Link Request|Link has been deleted|Invalid link)' + + LINK_PATTERN = r'<div id="show_download_button_%d"[^>]*>\s*<a href="([^"]+)">' + + PASSPORT_LEFT_PATTERN = r'Your Download Passport is: <[^>]*>(\w+).*?You have.*?<[^>]*>.*?([\d.]+) (\w+)' + PASSPORT_RENEW_PATTERN = r'(\d+):<strong>(\d+)</strong>:<strong>(\d+)</strong>' REACTIVATE_NUM_PATTERN = r'<input[^>]*id="random_num" value="(\d+)" />' REACTIVATE_PASSPORT_PATTERN = r'<input[^>]*id="passport_num" value="(\w+)" />' REQUEST_URI_PATTERN = r'var request_uri = "([^"]+)";' NO_SLOTS_PATTERN = r'<dd class="red">All download slots for this link are currently filled' - FILE_OFFLINE_PATTERN = r'<dd class="red">(Invalid Link Request|Link has been deleted)' + def setup(self): self.resumeDownload = True - self.multiDL = self.premium + self.multiDL = self.premium + def handlePremium(self): self.handleDownload(True) - def handleFree(self): - self.html = self.load(self.pyfile.url, decode=True) + def handleFree(self): if self.NO_SLOTS_PATTERN in self.html: self.retry(wait_time=5 * 60) - self.getFileInfo() - #if self.pyfile.size > 576716800: self.fail("This file is too large for free download") - - # Reactivate passport if needed - found = re.search(self.REACTIVATE_PASSPORT_PATTERN, self.html) - if found: - passport_num = found.group(1) + m = re.search(self.REACTIVATE_PASSPORT_PATTERN, self.html) + if m: + passport_num = m.group(1) request_uri = re.search(self.REQUEST_URI_PATTERN, self.html).group(1) - for _ in xrange(5): + for _i in xrange(5): random_num = re.search(self.REACTIVATE_NUM_PATTERN, self.html).group(1) - verifyinput = self.decryptCaptcha( - "http://d01.megashares.com/index.php?secgfx=gfx&random_num=%s" % random_num) - self.logInfo("Reactivating passport %s: %s %s" % (passport_num, random_num, verifyinput)) + verifyinput = self.decryptCaptcha("http://d01.megashares.com/index.php", + get={'secgfx': "gfx", 'random_num': random_num}) + + self.logInfo(_("Reactivating passport %s: %s %s") % (passport_num, random_num, verifyinput)) - url = ("http://d01.megashares.com%s&rs=check_passport_renewal" % request_uri + - "&rsargs[]=%s&rsargs[]=%s&rsargs[]=%s" % (verifyinput, random_num, passport_num) + - "&rsargs[]=replace_sec_pprenewal&rsrnd=%s" % str(int(time() * 1000))) - self.logDebug(url) - response = self.load(url) + res = self.load("http://d01.megashares.com%s" % request_uri, + get={'rs' : "check_passport_renewal", + 'rsargs[]': verifyinput, + 'rsargs[]': random_num, + 'rsargs[]': passport_num, + 'rsargs[]': "replace_sec_pprenewal", + 'rsrnd[]' : str(int(time() * 1000))}) - if 'Thank you for reactivating your passport.' in response: + if 'Thank you for reactivating your passport.' in res: self.correctCaptcha() self.retry() else: self.invalidCaptcha() else: - self.fail("Failed to reactivate passport") + self.fail(_("Failed to reactivate passport")) + + m = re.search(self.PASSPORT_RENEW_PATTERN, self.html) + if m: + time = [int(x) for x in m.groups()] + renew = time[0] + (time[1] * 60) + (time[2] * 60) + self.logDebug("Waiting %d seconds for a new passport" % renew) + self.retry(wait_time=renew, reason=_("Passport renewal")) # Check traffic left on passport - found = re.search(self.PASSPORT_LEFT_PATTERN, self.html) - if not found: - self.fail('Passport not found') - self.logInfo("Download passport: %s" % found.group(1)) - data_left = float(found.group(2)) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[found.group(3)] - self.logInfo("Data left: %s %s (%d MB needed)" % (found.group(2), found.group(3), self.pyfile.size / 1048576)) + m = re.search(self.PASSPORT_LEFT_PATTERN, self.html, re.M | re.S) + if m is None: + self.fail(_("Passport not found")) + + self.logInfo(_("Download passport: %s") % m.group(1)) + data_left = float(m.group(2)) * 1024 ** {'B': 0, 'KB': 1, 'MB': 2, 'GB': 3}[m.group(3)] + self.logInfo(_("Data left: %s %s (%d MB needed)") % (m.group(2), m.group(3), self.pyfile.size / 1048576)) if not data_left: - found = re.search(self.PASSPORT_RENEW_PATTERN, self.html) - renew = found.group(1) + found.group(2) + found.group(3) * 60 * 60 if found else 10 * 60 - self.retry(max_tries=15, wait_time=renew, reason="Unable to get passport") + self.retry(wait_time=600, reason=_("Passport renewal")) self.handleDownload(False) + def handleDownload(self, premium=False): # Find download link; - found = re.search(self.DOWNLOAD_URL_PATTERN % (1 if premium else 2), self.html) - msg = '%s download URL' % ('Premium' if premium else 'Free') - if not found: - self.parseError(msg) + m = re.search(self.LINK_PATTERN % (1 if premium else 2), self.html) + msg = _('%s download URL' % ('Premium' if premium else 'Free')) + if m is None: + self.error(msg) - download_url = found.group(1) + download_url = m.group(1) self.logDebug("%s: %s" % (msg, download_url)) self.download(download_url) diff --git a/module/plugins/hoster/MegauploadCom.py b/module/plugins/hoster/MegauploadCom.py new file mode 100644 index 000000000..7f51a8a46 --- /dev/null +++ b/module/plugins/hoster/MegauploadCom.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo + + +class MegauploadCom(DeadHoster): + __name__ = "MegauploadCom" + __type__ = "hoster" + __version__ = "0.31" + + __pattern__ = r'http://(?:www\.)?megaupload\.com/\?.*&?(d|v)=\w+' + + __description__ = """Megaupload.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("spoob", "spoob@pyload.org")] + + +getInfo = create_getInfo(MegauploadCom) diff --git a/module/plugins/hoster/MegavideoCom.py b/module/plugins/hoster/MegavideoCom.py new file mode 100644 index 000000000..24905ce62 --- /dev/null +++ b/module/plugins/hoster/MegavideoCom.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo + + +class MegavideoCom(DeadHoster): + __name__ = "MegavideoCom" + __type__ = "hoster" + __version__ = "0.21" + + __pattern__ = r'http://(?:www\.)?megavideo\.com/\?.*&?(d|v)=\w+' + + __description__ = """Megavideo.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("jeix", "jeix@hasnomail.de"), + ("mkaay", "mkaay@mkaay.de")] + + +getInfo = create_getInfo(MegavideoCom) diff --git a/module/plugins/hoster/MovReelCom.py b/module/plugins/hoster/MovReelCom.py index 2dedcf13d..9bb63701c 100644 --- a/module/plugins/hoster/MovReelCom.py +++ b/module/plugins/hoster/MovReelCom.py @@ -1,27 +1,23 @@ # -*- coding: utf-8 -*- -#import re -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo -#from pycurl import FOLLOWLOCATION, LOW_SPEED_TIME +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo -class MovReelCom(XFileSharingPro): - __name__ = "MovReelCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?movreel.com/.*' - __version__ = "1.20" +class MovReelCom(XFSHoster): + __name__ = "MovReelCom" + __type__ = "hoster" + __version__ = "1.24" + + __pattern__ = r'http://(?:www\.)?movreel\.com/\w{12}' + __description__ = """MovReel.com hoster plugin""" - __author_name__ = "JorisV83" - __author_mail__ = "jorisv83-pyload@yahoo.com" + __license__ = "GPLv3" + __authors__ = [("JorisV83", "jorisv83-pyload@yahoo.com")] + - HOSTER_NAME = "movreel.com" + HOSTER_DOMAIN = "movreel.com" - #FILE_NAME_PATTERN = r'<b>Filename:</b>(?P<N>.*?)<br>' - #FILE_SIZE_PATTERN = r'<b>Size:</b>(?P<S>.*?)<br>' - FILE_INFO_PATTERN = r'<h3>(?P<N>.+?) <small><sup>(?P<S>[\d.]+) (?P<U>..)</sup> </small></h3>' - FILE_OFFLINE_PATTERN = r'<b>File Not Found</b><br><br>' - DIRECT_LINK_PATTERN = r'<a href="(http://[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*/.*)">Download Link</a>' - #OVR_DOWNLOAD_LINK_PATTERN = "var file_link = '(.*)';" + LINK_PATTERN = r'<a href="([^"]+)">Download Link' getInfo = create_getInfo(MovReelCom) diff --git a/module/plugins/hoster/MultiDebridCom.py b/module/plugins/hoster/MultiDebridCom.py deleted file mode 100644 index 71f3df908..000000000 --- a/module/plugins/hoster/MultiDebridCom.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################ - -import re - -from module.plugins.Hoster import Hoster -from module.common.json_layer import json_loads - - -class MultiDebridCom(Hoster): - __name__ = "MultiDebridCom" - __version__ = "0.03" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/dl/' - __description__ = """Multi-debrid.com hoster plugin""" - __author_name__ = "stickell" - __author_mail__ = "l.stickell@yahoo.it" - - def setup(self): - self.chunkLimit = -1 - self.resumeDownload = True - - def process(self, pyfile): - if re.match(self.__pattern__, pyfile.url): - new_url = pyfile.url - elif not self.account: - self.logError(_("Please enter your %s account or deactivate this plugin") % "Multi-debrid.com") - self.fail("No Multi-debrid.com account provided") - else: - self.logDebug("Original URL: %s" % pyfile.url) - page = self.req.load('http://multi-debrid.com/api.php', - get={'user': self.user, 'pass': self.account.getAccountData(self.user)['password'], - 'link': pyfile.url}) - self.logDebug("JSON data: " + page) - page = json_loads(page) - if page['status'] != 'ok': - self.fail('Unable to unrestrict link') - new_url = page['link'] - - if new_url != pyfile.url: - self.logDebug("Unrestricted URL: " + new_url) - - self.download(new_url, disposition=True) diff --git a/module/plugins/hoster/MultihostersCom.py b/module/plugins/hoster/MultihostersCom.py new file mode 100644 index 000000000..04192cd8e --- /dev/null +++ b/module/plugins/hoster/MultihostersCom.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- + +import re +from module.plugins.Hoster import Hoster + +class MultihostersCom(Hoster): + __name__ = "MultihostersCom" + __version__ = "0.01" + __type__ = "hoster" + __pattern__ = r'http://(?:www\.)?multihosters.com/.*' + __description__ = """Multihosters.com hoster plugin""" + __author_name__ = "tjeh" + __author_mail__ = "tjeh@gmx.net" + + def setup(self): + self.resumeDownload = self.multiDL = True + self.chunkLimit = 1 + + def process(self, pyfile): + if re.match(self.__pattern__, pyfile.url): + new_url = pyfile.url + elif not self.account: + self.logError(("Please enter your %s account or deactivate this plugin") % "multihosters.com") + self.fail("No multihosters.com account provided") + else: + self.logDebug("Old URL: %s" % pyfile.url) + new_url = "http://multihosters.com/getFiles.aspx?ourl=" + pyfile.url + pyfile.url = new_url + self.logDebug("New URL: %s" % new_url) + + if self.account.getAPIData(self.req, cmd="checklink", olink=pyfile.url) != "Alive": + self.fail("Offline or not downloadable - contact Multihosters support") + + header = self.account.getAPIData(self.req, just_header=True, cmd="generatedownloaddirect", olink=pyfile.url) + if not "location" in header: + self.fail("Unable to initialize download - contact Multihosters support") + self.download(header['location'], disposition=True) + + check = self.checkDownload({"error": 'action="ErrorDownload.aspx'}) + if check == "error": + self.fail("Error response received - contact Multihosters support") diff --git a/module/plugins/hoster/MultishareCz.py b/module/plugins/hoster/MultishareCz.py index e38bd048f..adbae2da4 100644 --- a/module/plugins/hoster/MultishareCz.py +++ b/module/plugins/hoster/MultishareCz.py @@ -1,84 +1,67 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re + from random import random + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class MultishareCz(SimpleHoster): - __name__ = "MultishareCz" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?multishare.cz/stahnout/(?P<ID>\d+).*' - __version__ = "0.34" + __name__ = "MultishareCz" + __type__ = "hoster" + __version__ = "0.36" + + __pattern__ = r'http://(?:www\.)?multishare\.cz/stahnout/(?P<ID>\d+)' + __description__ = """MultiShare.cz hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" - - FILE_INFO_PATTERN = ur'(?:<li>Název|Soubor): <strong>(?P<N>[^<]+)</strong><(?:/li><li|br)>Velikost: <strong>(?P<S>[^<]+)</strong>' - FILE_OFFLINE_PATTERN = ur'<h1>Stáhnout soubor</h1><p><strong>Požadovaný soubor neexistuje.</strong></p>' - FILE_SIZE_REPLACEMENTS = [(' ', '')] - - def process(self, pyfile): - msurl = re.match(self.__pattern__, pyfile.url) - if msurl: - self.fileID = msurl.group('ID') - self.html = self.load(pyfile.url, decode=True) - self.getFileInfo() - - if self.premium: - self.handlePremium() - else: - self.handleFree() - else: - self.handleOverriden() + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + + SIZE_REPLACEMENTS = [(' ', '')] + + MULTI_HOSTER = True + + INFO_PATTERN = ur'(?:<li>Název|Soubor): <strong>(?P<N>[^<]+)</strong><(?:/li><li|br)>Velikost: <strong>(?P<S>[^<]+)</strong>' + OFFLINE_PATTERN = ur'<h1>Stáhnout soubor</h1><p><strong>Požadovaný soubor neexistuje.</strong></p>' + def handleFree(self): - self.download("http://www.multishare.cz/html/download_free.php?ID=%s" % self.fileID) + self.download("http://www.multishare.cz/html/download_free.php?ID=%s" % self.info['pattern']['ID']) + def handlePremium(self): if not self.checkCredit(): - self.logWarning("Not enough credit left to download file") + self.logWarning(_("Not enough credit left to download file")) self.resetAccount() - self.download("http://www.multishare.cz/html/download_premium.php?ID=%s" % self.fileID) + self.download("http://www.multishare.cz/html/download_premium.php?ID=%s" % self.info['pattern']['ID']) - def handleOverriden(self): - if not self.premium: - self.fail("Only premium users can download from other hosters") + def handleMulti(self): self.html = self.load('http://www.multishare.cz/html/mms_ajax.php', post={"link": self.pyfile.url}, decode=True) - self.getFileInfo() + + self.checkInfo() if not self.checkCredit(): - self.fail("Not enough credit left to download file") + self.fail(_("Not enough credit left to download file")) + + url = "http://dl%d.mms.multishare.cz/html/mms_process.php" % round(random() * 10000 * random()) + params = {"u_ID": self.acc_info['u_ID'], "u_hash": self.acc_info['u_hash'], "link": self.pyfile.url} - url = "http://dl%d.mms.multishare.cz/html/mms_process.php" % round(random() * 10000 * random()) - params = {"u_ID": self.acc_info["u_ID"], "u_hash": self.acc_info["u_hash"], "link": self.pyfile.url} self.logDebug(url, params) + + self.link = True self.download(url, get=params) + def checkCredit(self): self.acc_info = self.account.getAccountInfo(self.user, True) - self.logInfo("User %s has %i MB left" % (self.user, self.acc_info["trafficleft"] / 1024)) - return self.pyfile.size / 1024 <= self.acc_info["trafficleft"] + self.logInfo(_("User %s has %i MB left") % (self.user, self.acc_info['trafficleft'] / 1024)) + + return self.pyfile.size / 1024 <= self.acc_info['trafficleft'] getInfo = create_getInfo(MultishareCz) diff --git a/module/plugins/hoster/MyfastfileCom.py b/module/plugins/hoster/MyfastfileCom.py new file mode 100644 index 000000000..b5b9ec820 --- /dev/null +++ b/module/plugins/hoster/MyfastfileCom.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- + +import re + +from module.common.json_layer import json_loads +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo + + +class MyfastfileCom(MultiHoster): + __name__ = "MyfastfileCom" + __type__ = "hoster" + __version__ = "0.07" + + __pattern__ = r'http://\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/dl/' + + __description__ = """Myfastfile.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it")] + + + def setup(self): + self.chunkLimit = -1 + self.resumeDownload = True + + + def handlePremium(self): + self.logDebug("Original URL: %s" % self.pyfile.url) + + page = self.load('http://myfastfile.com/api.php', + get={'user': self.user, 'pass': self.account.getAccountData(self.user)['password'], + 'link': self.pyfile.url}) + self.logDebug("JSON data: " + page) + page = json_loads(page) + if page['status'] != 'ok': + self.fail(_("Unable to unrestrict link")) + self.link = page['link'] + + if self.link != self.pyfile.url: + self.logDebug("Unrestricted URL: " + self.link) + + +getInfo = create_getInfo(MyfastfileCom) diff --git a/module/plugins/hoster/MyvideoDe.py b/module/plugins/hoster/MyvideoDe.py index 21d95d092..8af4a9a61 100644 --- a/module/plugins/hoster/MyvideoDe.py +++ b/module/plugins/hoster/MyvideoDe.py @@ -1,18 +1,22 @@ # -*- coding: utf-8 -*- import re + from module.plugins.Hoster import Hoster from module.unescape import unescape class MyvideoDe(Hoster): - __name__ = "MyvideoDe" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?myvideo.de/watch/' - __version__ = "0.9" + __name__ = "MyvideoDe" + __type__ = "hoster" + __version__ = "0.90" + + __pattern__ = r'http://(?:www\.)?myvideo\.de/watch/' + __description__ = """Myvideo.de hoster plugin""" - __author_name__ = "spoob" - __author_mail__ = "spoob@pyload.org" + __license__ = "GPLv3" + __authors__ = [("spoob", "spoob@pyload.org")] + def process(self, pyfile): self.pyfile = pyfile @@ -20,19 +24,23 @@ class MyvideoDe(Hoster): pyfile.name = self.get_file_name() self.download(self.get_file_url()) + def download_html(self): self.html = self.load(self.pyfile.url) + def get_file_url(self): videoId = re.search(r"addVariable\('_videoid','(.*)'\);p.addParam\('quality'", self.html).group(1) videoServer = re.search("rel='image_src' href='(.*)thumbs/.*' />", self.html).group(1) file_url = videoServer + videoId + ".flv" return file_url + def get_file_name(self): - file_name_pattern = r"<h1 class='globalHd'>(.*)</h1>" + file_name_pattern = r'<h1 class=\'globalHd\'>(.*)</h1>' return unescape(re.search(file_name_pattern, self.html).group(1).replace("/", "") + '.flv') + def file_exists(self): self.download_html() self.load(str(self.pyfile.url), cookies=False, just_header=True) diff --git a/module/plugins/hoster/NahrajCz.py b/module/plugins/hoster/NahrajCz.py new file mode 100644 index 000000000..6b5699408 --- /dev/null +++ b/module/plugins/hoster/NahrajCz.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo + + +class NahrajCz(DeadHoster): + __name__ = "NahrajCz" + __type__ = "hoster" + __version__ = "0.21" + + __pattern__ = r'http://(?:www\.)?nahraj\.cz/content/download/.+' + + __description__ = """Nahraj.cz hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + +getInfo = create_getInfo(NahrajCz) diff --git a/module/plugins/hoster/NarodRu.py b/module/plugins/hoster/NarodRu.py index 6f08e6207..21d4e3e3d 100644 --- a/module/plugins/hoster/NarodRu.py +++ b/module/plugins/hoster/NarodRu.py @@ -1,71 +1,59 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re + from random import random + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class NarodRu(SimpleHoster): - __name__ = "NarodRu" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?narod(\.yandex)?\.ru/(disk|start/[0-9]+\.\w+-narod\.yandex\.ru)/(?P<ID>\d+)/.+' - __version__ = "0.1" + __name__ = "NarodRu" + __type__ = "hoster" + __version__ = "0.11" + + __pattern__ = r'http://(?:www\.)?narod(\.yandex)?\.ru/(disk|start/\d+\.\w+-narod\.yandex\.ru)/(?P<ID>\d+)/.+' + __description__ = """Narod.ru hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - FILE_NAME_PATTERN = r'<dt class="name">(?:<[^<]*>)*(?P<N>[^<]+)</dt>' - FILE_SIZE_PATTERN = r'<dd class="size">(?P<S>\d[^<]*)</dd>' - FILE_OFFLINE_PATTERN = r'<title>404</title>|Файл удален с сервиса|Закончился срок хранения файла\.' - FILE_SIZE_REPLACEMENTS = [(u'КБ', 'KB'), (u'МБ', 'MB'), (u'ГБ', 'GB')] - FILE_URL_REPLACEMENTS = [("narod.yandex.ru/", "narod.ru/"), - (r"/start/[0-9]+\.\w+-narod\.yandex\.ru/([0-9]{6,15})/\w+/(\w+)", r"/disk/\1/\2")] + NAME_PATTERN = r'<dt class="name">(?:<[^<]*>)*(?P<N>[^<]+)</dt>' + SIZE_PATTERN = r'<dd class="size">(?P<S>\d[^<]*)</dd>' + OFFLINE_PATTERN = r'<title>404</title>|Файл удален с сервиса|Закончился срок хранения файла\.' + + SIZE_REPLACEMENTS = [(u'КБ', 'KB'), (u'МБ', 'MB'), (u'ГБ', 'GB')] + URL_REPLACEMENTS = [("narod.yandex.ru/", "narod.ru/"), + (r"/start/\d+\.\w+-narod\.yandex\.ru/(\d{6,15})/\w+/(\w+)", r"/disk/\1/\2")] CAPTCHA_PATTERN = r'<number url="(.*?)">(\w+)</number>' - DOWNLOAD_LINK_PATTERN = r'<a class="h-link" rel="yandex_bar" href="(.+?)">' + LINK_PATTERN = r'<a class="h-link" rel="yandex_bar" href="(.+?)">' + def handleFree(self): - for _ in xrange(5): + for _i in xrange(5): self.html = self.load('http://narod.ru/disk/getcapchaxml/?rnd=%d' % int(random() * 777)) - found = re.search(self.CAPTCHA_PATTERN, self.html) - if not found: - self.parseError('Captcha') + m = re.search(self.CAPTCHA_PATTERN, self.html) + if m is None: + self.error(_("Captcha")) post_data = {"action": "sendcapcha"} - captcha_url, post_data['key'] = found.groups() + captcha_url, post_data['key'] = m.groups() post_data['rep'] = self.decryptCaptcha(captcha_url) self.html = self.load(self.pyfile.url, post=post_data, decode=True) - found = re.search(self.DOWNLOAD_LINK_PATTERN, self.html) - if found: - url = 'http://narod.ru' + found.group(1) + m = re.search(self.LINK_PATTERN, self.html) + if m: + url = 'http://narod.ru' + m.group(1) self.correctCaptcha() break elif u'<b class="error-msg"><strong>Ошиблись?</strong>' in self.html: self.invalidCaptcha() else: - self.parseError('Download link') + self.error(_("Download link")) else: - self.fail("No valid captcha code entered") + self.fail(_("No valid captcha code entered")) - self.logDebug('Download link: ' + url) self.download(url) diff --git a/module/plugins/hoster/NetloadIn.py b/module/plugins/hoster/NetloadIn.py index 4b8842d18..f5c5ee802 100644 --- a/module/plugins/hoster/NetloadIn.py +++ b/module/plugins/hoster/NetloadIn.py @@ -1,17 +1,20 @@ # -*- coding: utf-8 -*- import re + +from urlparse import urljoin from time import sleep, time -from module.plugins.Hoster import Hoster from module.network.RequestFactory import getURL +from module.plugins.Hoster import Hoster from module.plugins.Plugin import chunks +from module.plugins.internal.CaptchaService import ReCaptcha def getInfo(urls): ## returns list of tupels (name, size (in bytes), status (see FileDatabase), url) - apiurl = "http://api.netload.in/info.php?auth=Zf9SnQh9WiReEsb18akjvQGqT0I830e8&bz=1&md5=1&file_id=" + apiurl = "http://api.netload.in/info.php" id_regex = re.compile(NetloadIn.__pattern__) urls_per_query = 80 @@ -22,13 +25,19 @@ def getInfo(urls): if match: ids = ids + match.group(1) + ";" - api = getURL(apiurl + ids, decode=True) + api = getURL(apiurl, + get={'auth' : "Zf9SnQh9WiReEsb18akjvQGqT0I830e8", + 'bz' : 1, + 'md5' : 1, + 'file_id': ids}, + decode=True) if api is None or len(api) < 10: - print "Netload prefetch: failed " + self.logDebug("Prefetch failed") return + if api.find("unknown_auth") >= 0: - print "Netload prefetch: Outdated auth code " + self.logDebug("Outdated auth code") return result = [] @@ -36,45 +45,59 @@ def getInfo(urls): for i, r in enumerate(api.splitlines()): try: tmp = r.split(";") + try: size = int(tmp[2]) - except: + except Exception: size = 0 - result.append((tmp[1], size, 2 if tmp[3] == "online" else 1, chunk[i])) - except: - print "Netload prefetch: Error while processing response: " - print r + + result.append((tmp[1], size, 2 if tmp[3] == "online" else 1, chunk[i] )) + + except Exception: + self.logDebug("Error while processing response: %s" % r) yield result class NetloadIn(Hoster): - __name__ = "NetloadIn" - __type__ = "hoster" - __pattern__ = r'https?://(?:[^/]*\.)?netload\.in/(?:datei(.*?)(?:\.htm|/)|index.php?id=10&file_id=)' - __version__ = "0.45" + __name__ = "NetloadIn" + __type__ = "hoster" + __version__ = "0.47" + + __pattern__ = r'https?://(?:[^/]*\.)?netload\.in/(?:datei(.*?)(?:\.htm|/)|index\.php?id=10&file_id=)' + __description__ = """Netload.in hoster plugin""" - __author_name__ = ("spoob", "RaNaN", "Gregy") - __author_mail__ = ("spoob@pyload.org", "ranan@pyload.org", "gregy@gregy.cz") + __license__ = "GPLv3" + __authors__ = [("spoob", "spoob@pyload.org"), + ("RaNaN", "ranan@pyload.org"), + ("Gregy", "gregy@gregy.cz")] + def setup(self): self.multiDL = self.resumeDownload = self.premium + def process(self, pyfile): self.url = pyfile.url + self.prepare() + pyfile.setStatus("downloading") + self.proceed(self.url) + def prepare(self): self.download_api_data() - if self.api_data and self.api_data["filename"]: - self.pyfile.name = self.api_data["filename"] + if self.api_data and self.api_data['filename']: + self.pyfile.name = self.api_data['filename'] if self.premium: - self.logDebug("Netload: Use Premium Account") - settings = self.load("http://www.netload.in/index.php?id=2&lang=en") + self.logDebug("Use Premium Account") + + settings = self.load("http://www.netload.in/index.php", get={'id': 2, 'lang': "en"}) + if '<option value="2" selected="selected">Direkter Download' in settings: self.logDebug("Using direct download") return True @@ -84,13 +107,14 @@ class NetloadIn(Hoster): if self.download_html(): return True else: - self.fail("Failed") + self.fail(_("Failed")) return False + def download_api_data(self, n=0): - url = self.url + url = self.url id_regex = re.compile(self.__pattern__) - match = id_regex.search(url) + match = id_regex.search(url) if match: #normalize url @@ -101,25 +125,28 @@ class NetloadIn(Hoster): return apiurl = "http://api.netload.in/info.php" - src = self.load(apiurl, cookies=False, + html = self.load(apiurl, cookies=False, get={"file_id": match.group(1), "auth": "Zf9SnQh9WiReEsb18akjvQGqT0I830e8", "bz": "1", "md5": "1"}, decode=True).strip() - if not src and n <= 3: + if not html and n <= 3: sleep(0.2) self.download_api_data(n + 1) return - self.logDebug("Netload: APIDATA: " + src) + self.logDebug("APIDATA: " + html) + self.api_data = {} - if src and ";" in src and src not in ("unknown file_data", "unknown_server_data", "No input file specified."): - lines = src.split(";") - self.api_data["exists"] = True - self.api_data["fileid"] = lines[0] - self.api_data["filename"] = lines[1] - self.api_data["size"] = lines[2] - self.api_data["status"] = lines[3] - if self.api_data["status"] == "online": - self.api_data["checksum"] = lines[4].strip() + + if html and ";" in html and html not in ("unknown file_data", "unknown_server_data", "No input file specified."): + lines = html.split(";") + self.api_data['exists'] = True + self.api_data['fileid'] = lines[0] + self.api_data['filename'] = lines[1] + self.api_data['size'] = lines[2] + self.api_data['status'] = lines[3] + + if self.api_data['status'] == "online": + self.api_data['checksum'] = lines[4].strip() else: self.api_data = False # check manually since api data is useless sometimes @@ -128,20 +155,34 @@ class NetloadIn(Hoster): else: self.api_data = False + def final_wait(self, page): wait_time = self.get_wait_time(page) + self.setWait(wait_time) - self.logDebug("Netload: final wait %d seconds" % wait_time) + + self.logDebug("Final wait %d seconds" % wait_time) + self.wait() + self.url = self.get_file_url(page) + + def check_free_wait(self,page): + if ">An access request has been made from IP address <" in page: + self.wantReconnect = True + self.setWait(self.get_wait_time(page) or 30) + self.wait() + return True + else: + return False + + def download_html(self): - self.logDebug("Netload: Entering download_html") page = self.load(self.url, decode=True) - t = time() + 30 if "/share/templates/download_hddcrash.tpl" in page: - self.logError("Netload HDD Crash") + self.logError(_("Netload HDD Crash")) self.fail(_("File temporarily not available")) if not self.api_data: @@ -150,105 +191,104 @@ class NetloadIn(Hoster): if "* The file was deleted" in page: self.offline() - name = re.search(r'class="dl_first_filename">([^<]+)', page, re.MULTILINE) - # the found filename is not truncated + name = re.search(r'class="dl_first_filename">([^<]+)', page, re.M) + # the found filename is not truncated if name: name = name.group(1).strip() if not name.endswith(".."): self.pyfile.name = name captchawaited = False - for i in xrange(10): + for i in xrange(5): if not page: page = self.load(self.url) t = time() + 30 if "/share/templates/download_hddcrash.tpl" in page: - self.logError("Netload HDD Crash") + self.logError(_("Netload HDD Crash")) self.fail(_("File temporarily not available")) - self.logDebug("Netload: try number %d " % i) + self.logDebug("Try number %d " % i) if ">Your download is being prepared.<" in page: - self.logDebug("Netload: We will prepare your download") + self.logDebug("We will prepare your download") self.final_wait(page) return True - if ">An access request has been made from IP address <" in page: - wait = self.get_wait_time(page) - if wait == 0: - self.logDebug("Netload: Wait was 0 setting 30") - wait = 30 - self.logInfo(_("Netload: waiting between downloads %d s." % wait)) - self.wantReconnect = True - self.setWait(wait) - self.wait() - return self.download_html() - - self.logDebug("Netload: Trying to find captcha") + self.logDebug("Trying to find captcha") try: - url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&.*&captcha=1)', - page).group(1).replace("amp;", "") - except: + url_captcha_html = re.search(r'(index.php\?id=10&.*&captcha=1)', page).group(1).replace("amp;", "") + + except Exception, e: + self.logDebug("Exception during Captcha regex: %s" % e.message) page = None - continue - try: - page = self.load(url_captcha_html, cookies=True) - captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', page).group(1) - except: - self.logDebug("Netload: Could not find captcha, try again from beginning") - captchawaited = False - continue - - file_id = re.search('<input name="file_id" type="hidden" value="(.*)" />', page).group(1) - if not captchawaited: - wait = self.get_wait_time(page) - if i == 0: - self.pyfile.waitUntil = time() # dont wait contrary to time on website - else: - self.pyfile.waitUntil = t - self.logInfo(_("Netload: waiting for captcha %d s.") % (self.pyfile.waitUntil - time())) - #self.setWait(wait) + else: + url_captcha_html = urljoin("http://netload.in/", url_captcha_html) + break + + self.html = self.load(url_captcha_html) + + recaptcha = ReCaptcha(self) + + for _i in xrange(5): + challenge, response = recaptcha.challenge() + + response_page = self.load("http://www.netload.in/index.php?id=10", + post={'captcha_check' : '1', + 'recaptcha_challenge_field': challenge, + 'recaptcha_response_field' : response, + 'file_id' : self.api_data['fileid'], + 'Download_Next' : ''}) + if "Orange_Link" in response_page: + break + + if self.check_free_wait(response_page): + self.logDebug("Had to wait for next free slot, trying again") + return self.download_html() + + else: + download_url = self.get_file_url(response_page) + self.logDebug("Download URL after get_file: " + download_url) + if not download_url.startswith("http://"): + self.error("download url: %s" % download_url) self.wait() - captchawaited = True - captcha = self.decryptCaptcha(captcha_url) - page = self.load("http://netload.in/index.php?id=10", post={"file_id": file_id, "captcha_check": captcha}, - cookies=True) + self.url = download_url + return True - return False def get_file_url(self, page): try: - file_url_pattern = r"<a class=\"Orange_Link\" href=\"(http://.+)\".?>Or click here" + file_url_pattern = r'<a class="Orange_Link" href="(http://.+)".?>Or click here' attempt = re.search(file_url_pattern, page) if attempt is not None: return attempt.group(1) else: - self.logDebug("Netload: Backup try for final link") - file_url_pattern = r"<a href=\"(.+)\" class=\"Orange_Link\">Click here" + self.logDebug("Backup try for final link") + file_url_pattern = r'<a href="(.+)" class="Orange_Link">Click here' attempt = re.search(file_url_pattern, page) return "http://netload.in/" + attempt.group(1) - except: - self.logDebug("Netload: Getting final link failed") + + except Exception, e: + self.logDebug("Getting final link failed", e.message) return None + def get_wait_time(self, page): - wait_seconds = int(re.search(r"countdown\((.+),'change\(\)'\)", page).group(1)) / 100 - return wait_seconds + return int(re.search(r"countdown\((.+),'change\(\)'\)", page).group(1)) / 100 - def proceed(self, url): - self.logDebug("Netload: Downloading..") + def proceed(self, url): self.download(url, disposition=True) - check = self.checkDownload({"empty": re.compile(r"^$"), "offline": re.compile("The file was deleted")}) - + check = self.checkDownload({'empty' : re.compile(r'^$'), + 'offline': re.compile("The file was deleted")}) if check == "empty": self.logInfo(_("Downloaded File was empty")) self.retry() + elif check == "offline": self.offline() diff --git a/module/plugins/hoster/NoPremiumPl.py b/module/plugins/hoster/NoPremiumPl.py new file mode 100644 index 000000000..f4f7ba56a --- /dev/null +++ b/module/plugins/hoster/NoPremiumPl.py @@ -0,0 +1,104 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.SimpleHoster import SimpleHoster +from module.common.json_layer import json_loads as loads + + +class NoPremiumPl(SimpleHoster): + __name__ = "NoPremiumPl" + __version__ = "0.01" + __type__ = "hoster" + + __pattern__ = r"https?://direct\.nopremium\.pl.*" + __description__ = "NoPremium.pl hoster plugin" + __license__ = "GPLv3" + __authors__ = [("goddie", "dev@nopremium.pl")] + + _api_url = "http://crypt.nopremium.pl" + + _api_query = {"site": "nopremium", + "output": "json", + "username": "", + "password": "", + "url": ""} + + _error_codes = { + 0: "[%s] Incorrect login credentials", + 1: "[%s] Not enough transfer to download - top-up your account", + 2: "[%s] Incorrect / dead link", + 3: "[%s] Error connecting to hosting, try again later", + 9: "[%s] Premium account has expired", + 15: "[%s] Hosting no longer supported", + 80: "[%s] Too many incorrect login attempts, account blocked for 24h" + } + + _usr = False + _pwd = False + + def setup(self): + self.resumeDownload = True + self.multiDL = True + + def get_username_password(self): + if not self.account: + self.fail(_("Please enter your %s account or deactivate this plugin") % "NoPremium.pl") + else: + self._usr = self.account.getAccountData(self.user).get('usr') + self._pwd = self.account.getAccountData(self.user).get('pwd') + + def runFileQuery(self, url, mode=None): + query = self._api_query.copy() + query["username"] = self._usr + query["password"] = self._pwd + query["url"] = url + + if mode == "fileinfo": + query['check'] = 2 + query['loc'] = 1 + self.logDebug(query) + + return self.load(self._api_url, post=query) + + def process(self, pyfile): + self.get_username_password() + try: + data = self.runFileQuery(pyfile.url, 'fileinfo') + except Exception: + self.logDebug("runFileQuery error") + self.tempOffline() + + try: + parsed = loads(data) + except Exception: + self.logDebug("loads error") + self.tempOffline() + + self.logDebug(parsed) + + if "errno" in parsed.keys(): + if parsed["errno"] in self._error_codes: + # error code in known + self.fail(self._error_codes[parsed["errno"]] % self.__name__) + else: + # error code isn't yet added to plugin + self.fail( + parsed["errstring"] + or "Unknown error (code: %s)" % parsed["errno"] + ) + + if "sdownload" in parsed: + if parsed["sdownload"] == "1": + self.fail( + "Download from %s is possible only using NoPremium.pl webiste \ + directly. Update this plugin." % parsed["hosting"]) + + pyfile.name = parsed["filename"] + pyfile.size = parsed["filesize"] + + try: + result_dl = self.runFileQuery(pyfile.url, 'filedownload') + except Exception: + self.logDebug("runFileQuery error #2") + self.tempOffline() + + self.download(result_dl, disposition=True) diff --git a/module/plugins/hoster/NosuploadCom.py b/module/plugins/hoster/NosuploadCom.py index 1de734222..8a03d7090 100644 --- a/module/plugins/hoster/NosuploadCom.py +++ b/module/plugins/hoster/NosuploadCom.py @@ -2,24 +2,29 @@ import re -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo -class NosuploadCom(XFileSharingPro): - __name__ = "NosuploadCom" - __type__ = "hoster" - __version__ = "0.1" +class NosuploadCom(XFSHoster): + __name__ = "NosuploadCom" + __type__ = "hoster" + __version__ = "0.31" + __pattern__ = r'http://(?:www\.)?nosupload\.com/\?d=\w{12}' + __description__ = """Nosupload.com hoster plugin""" - __author_name__ = "igel" - __author_mail__ = "igelkun@myopera.com" + __license__ = "GPLv3" + __authors__ = [("igel", "igelkun@myopera.com")] + - HOSTER_NAME = "nosupload.com" + HOSTER_DOMAIN = "nosupload.com" + + SIZE_PATTERN = r'<p><strong>Size:</strong> (?P<S>[\d.,]+) (?P<U>[\w^_]+)</p>' + LINK_PATTERN = r'<a class="select" href="(http://.+?)">Download</a>' - FILE_SIZE_PATTERN = r'<p><strong>Size:</strong> (?P<S>[0-9\.]+) (?P<U>[kKMG]?B)</p>' - DIRECT_LINK_PATTERN = r'<a class="select" href="(http://.+?)">Download</a>' WAIT_PATTERN = r'Please wait.*?>(\d+)</span>' + def getDownloadLink(self): # stage1: press the "Free Download" button data = self.getPostParameters() @@ -27,13 +32,13 @@ class NosuploadCom(XFileSharingPro): # stage2: wait some time and press the "Download File" button data = self.getPostParameters() - wait_time = re.search(self.WAIT_PATTERN, self.html, re.MULTILINE | re.DOTALL).group(1) - self.logDebug("hoster told us to wait %s seconds" % wait_time) + wait_time = re.search(self.WAIT_PATTERN, self.html, re.M | re.S).group(1) + self.logDebug("Hoster told us to wait %s seconds" % wait_time) self.wait(wait_time) self.html = self.load(self.pyfile.url, post=data, ref=True, decode=True) # stage3: get the download link - return re.search(self.DIRECT_LINK_PATTERN, self.html, re.S).group(1) + return re.search(self.LINK_PATTERN, self.html, re.S).group(1) getInfo = create_getInfo(NosuploadCom) diff --git a/module/plugins/hoster/NovafileCom.py b/module/plugins/hoster/NovafileCom.py index c552c166c..9754ceed1 100644 --- a/module/plugins/hoster/NovafileCom.py +++ b/module/plugins/hoster/NovafileCom.py @@ -1,30 +1,31 @@ # -*- coding: utf-8 -*- - -# Test links (random.bin): +# +# Test links: # http://novafile.com/vfun4z6o2cit # http://novafile.com/s6zrr5wemuz4 -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo + +class NovafileCom(XFSHoster): + __name__ = "NovafileCom" + __type__ = "hoster" + __version__ = "0.05" -class NovafileCom(XFileSharingPro): - __name__ = "NovafileCom" - __type__ = "hoster" __pattern__ = r'http://(?:www\.)?novafile\.com/\w{12}' - __version__ = "0.02" + __description__ = """Novafile.com hoster plugin""" - __author_name__ = ("zoidberg", "stickell") - __author_mail__ = ("zoidberg@mujmail.cz", "l.stickell@yahoo.it") + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it")] + - HOSTER_NAME = "novafile.com" + HOSTER_DOMAIN = "novafile.com" - FILE_SIZE_PATTERN = r'<div class="size">(?P<S>.+?)</div>' ERROR_PATTERN = r'class="alert[^"]*alert-separate"[^>]*>\s*(?:<p>)?(.*?)\s*</' - DIRECT_LINK_PATTERN = r'<a href="(http://s\d+\.novafile\.com/.*?)" class="btn btn-green">Download File</a>' - WAIT_PATTERN = r'<p>Please wait <span id="count"[^>]*>(\d+)</span> seconds</p>' + WAIT_PATTERN = r'<p>Please wait <span id="count"[^>]*>(\d+)</span> seconds</p>' - def setup(self): - self.multiDL = False + LINK_PATTERN = r'<a href="(http://s\d+\.novafile\.com/.*?)" class="btn btn-green">Download File</a>' getInfo = create_getInfo(NovafileCom) diff --git a/module/plugins/hoster/NowDownloadEu.py b/module/plugins/hoster/NowDownloadEu.py deleted file mode 100644 index cc1a10da0..000000000 --- a/module/plugins/hoster/NowDownloadEu.py +++ /dev/null @@ -1,72 +0,0 @@ -# -*- coding: utf-8 -*- - -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - -import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.utils import fixup - - -class NowDownloadEu(SimpleHoster): - __name__ = "NowDownloadEu" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?nowdownload\.(ch|co|eu|sx)/(dl/|download\.php\?id=)(?P<ID>\w+)' - __version__ = "0.05" - __description__ = """NowDownload.ch hoster plugin""" - __author_name__ = ("godofdream", "Walter Purcaro") - __author_mail__ = ("soilfiction@gmail.com", "vuolter@gmail.com") - - FILE_INFO_PATTERN = r'Downloading</span> <br> (?P<N>.*) (?P<S>[0-9,.]+) (?P<U>[kKMG])i?B </h4>' - FILE_OFFLINE_PATTERN = r'(This file does not exist!)' - FILE_TOKEN_PATTERN = r'"(/api/token\.php\?token=[a-z0-9]+)"' - FILE_CONTINUE_PATTERN = r'"(/dl2/[a-z0-9]+/[a-z0-9]+)"' - FILE_WAIT_PATTERN = r'\.countdown\(\{until: \+(\d+),' - FILE_DOWNLOAD_LINK = r'"(http://f\d+\.nowdownload\.ch/dl/[a-z0-9]+/[a-z0-9]+/[^<>"]*?)"' - - FILE_NAME_REPLACEMENTS = [("&#?\w+;", fixup), (r'<[^>]*>', '')] - - def setup(self): - self.multiDL = self.resumeDownload = True - self.chunkLimit = -1 - - def handleFree(self): - tokenlink = re.search(self.FILE_TOKEN_PATTERN, self.html) - continuelink = re.search(self.FILE_CONTINUE_PATTERN, self.html) - if not tokenlink or not continuelink: - self.fail('Plugin out of Date') - - found = re.search(self.FILE_WAIT_PATTERN, self.html) - if found: - wait = int(found.group(1)) - else: - wait = 60 - - baseurl = "http://www.nowdownload.ch" - self.html = self.load(baseurl + str(tokenlink.group(1))) - self.wait(wait) - - self.html = self.load(baseurl + str(continuelink.group(1))) - - url = re.search(self.FILE_DOWNLOAD_LINK, self.html) - if not url: - self.fail('Download Link not Found (Plugin out of Date?)') - self.logDebug('Download link: ' + str(url.group(1))) - self.download(str(url.group(1))) - - -getInfo = create_getInfo(NowDownloadEu) diff --git a/module/plugins/hoster/NowDownloadSx.py b/module/plugins/hoster/NowDownloadSx.py new file mode 100644 index 000000000..d2ae08954 --- /dev/null +++ b/module/plugins/hoster/NowDownloadSx.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.utils import fixup + + +class NowDownloadSx(SimpleHoster): + __name__ = "NowDownloadSx" + __type__ = "hoster" + __version__ = "0.05" + + __pattern__ = r'http://(?:www\.)?nowdownload\.(at|ch|co|eu|sx)/(dl/|download\.php\?id=)\w+' + + __description__ = """NowDownload.sx hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("godofdream", "soilfiction@gmail.com"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + INFO_PATTERN = r'Downloading</span> <br> (?P<N>.*) (?P<S>[\d.,]+) (?P<U>[\w^_]+) </h4>' + OFFLINE_PATTERN = r'>This file does not exist' + + TOKEN_PATTERN = r'"(/api/token\.php\?token=\w+)"' + CONTINUE_PATTERN = r'"(/dl2/\w+/\w+)"' + WAIT_PATTERN = r'\.countdown\(\{until: \+(\d+),' + LINK_PATTERN = r'(http://s\d+\.coolcdn\.info/nowdownload/.+?)["\']' + + NAME_REPLACEMENTS = [("&#?\w+;", fixup), (r'<[^>]*>', '')] + + + def setup(self): + self.resumeDownload = True + self.multiDL = True + self.chunkLimit = -1 + + + def handleFree(self): + tokenlink = re.search(self.TOKEN_PATTERN, self.html) + continuelink = re.search(self.CONTINUE_PATTERN, self.html) + if tokenlink is None or continuelink is None: + self.error() + + m = re.search(self.WAIT_PATTERN, self.html) + if m: + wait = int(m.group(1)) + else: + wait = 60 + + baseurl = "http://www.nowdownload.at" + self.html = self.load(baseurl + str(tokenlink.group(1))) + self.wait(wait) + + self.html = self.load(baseurl + str(continuelink.group(1))) + + url = re.search(self.LINK_PATTERN, self.html) + if url is None: + self.error(_("Download link not found")) + + self.download(str(url.group(1))) + + +getInfo = create_getInfo(NowDownloadSx) diff --git a/module/plugins/hoster/NowVideoSx.py b/module/plugins/hoster/NowVideoSx.py new file mode 100644 index 000000000..d0777ca4b --- /dev/null +++ b/module/plugins/hoster/NowVideoSx.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + + +class NowVideoSx(SimpleHoster): + __name__ = "NowVideoSx" + __type__ = "hoster" + __version__ = "0.08" + + __pattern__ = r'http://(?:www\.)?nowvideo\.(at|ch|co|eu|sx)/(video|mobile/#/videos)/(?P<ID>\w+)' + + __description__ = """NowVideo.sx hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + URL_REPLACEMENTS = [(__pattern__ + ".*", r'http://www.nowvideo.sx/video/\g<ID>')] + + NAME_PATTERN = r'<h4>(?P<N>.+?)<' + OFFLINE_PATTERN = r'>This file no longer exists' + + LINK_FREE_PATTERN = r'<source src="(.+?)"' + LINK_PREMIUM_PATTERN = r'<div id="content_player" >\s*<a href="(.+?)"' + + + def setup(self): + self.resumeDownload = True + self.multiDL = True + + + def handleFree(self): + self.html = self.load("http://www.nowvideo.sx/mobile/video.php", get={'id': self.info['pattern']['ID']}) + + m = re.search(self.LINK_FREE_PATTERN, self.html) + if m is None: + self.error(_("Free download link not found")) + + self.download(m.group(1)) + + +getInfo = create_getInfo(NowVideoSx) diff --git a/module/plugins/hoster/OboomCom.py b/module/plugins/hoster/OboomCom.py index 1e0508d32..588d8f64a 100644 --- a/module/plugins/hoster/OboomCom.py +++ b/module/plugins/hoster/OboomCom.py @@ -1,52 +1,79 @@ # -*- coding: utf-8 -*- - -# Test link: +# +# Test links: # https://www.oboom.com/B7CYZIEB/10Mio.dat import re +from module.common.json_layer import json_loads from module.plugins.Hoster import Hoster from module.plugins.internal.CaptchaService import ReCaptcha -from module.common.json_layer import json_loads class OboomCom(Hoster): - __name__ = "OboomCom" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?oboom\.com/(#(id=|/)?)?(?P<ID>[A-Z0-9]{8})' - __version__ = "0.1" + __name__ = "OboomCom" + __type__ = "hoster" + __version__ = "0.30" + + __pattern__ = r'https?://(?:www\.)?oboom\.com/(#(id=|/)?)?(?P<ID>\w{8})' + __description__ = """oboom.com hoster plugin""" - __author_name__ = "stanley" - __author_mail__ = "stanley.foerster@gmail.com" + __license__ = "GPLv3" + __authors__ = [("stanley", "stanley.foerster@gmail.com")] + RECAPTCHA_KEY = "6LdqpO0SAAAAAJGHXo63HyalP7H4qlRs_vff0kJX" + + def setup(self): + self.chunkLimit = 1 + self.multiDL = self.resumeDownload = self.premium + + + def process(self, pyfile): + self.pyfile.url.replace(".com/#id=", ".com/#") + self.pyfile.url.replace(".com/#/", ".com/#") + self.getFileId(self.pyfile.url) + self.getSessionToken() + self.getFileInfo(self.sessionToken, self.fileId) + self.pyfile.name = self.fileName + self.pyfile.size = self.fileSize + if not self.premium: + self.solveCaptcha() + self.getDownloadTicket() + self.download("https://%s/1.0/dlh" % self.downloadDomain, get={"ticket": self.downloadTicket, "http_errors": 0}) + + def loadUrl(self, url, get=None): - if not get: + if get is None: get = dict() return json_loads(self.load(url, get, decode=True)) + def getFileId(self, url): self.fileId = re.match(OboomCom.__pattern__, url).group('ID') + def getSessionToken(self): if self.premium: accountInfo = self.account.getAccountInfo(self.user, True) if "session" in accountInfo: - self.sessionToken = accountInfo["session"] + self.sessionToken = accountInfo['session'] else: - self.fail("Could not retrieve premium session") + self.fail(_("Could not retrieve premium session")) else: apiUrl = "https://www.oboom.com/1.0/guestsession" result = self.loadUrl(apiUrl) if result[0] == 200: self.sessionToken = result[1] else: - self.fail("Could not retrieve token for guest session. Error code %s" % result[0]) + self.fail(_("Could not retrieve token for guest session. Error code: %s") % result[0]) + def solveCaptcha(self): recaptcha = ReCaptcha(self) - for _ in xrange(5): + + for _i in xrange(5): challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY) apiUrl = "https://www.oboom.com/1.0/download/ticket" params = {"recaptcha_challenge_field": challenge, @@ -62,23 +89,26 @@ class OboomCom(Hoster): self.setWait(30) self.wait() break + elif result[0] == 400: if result[1] == "incorrect-captcha-sol": self.invalidCaptcha() elif result[1] == "captcha-timeout": self.invalidCaptcha() elif result[1] == "forbidden": - self.retry(5, 15 * 60, "Service unavailable") + self.retry(5, 15 * 60, _("Service unavailable")) + elif result[0] == 403: if result[1] == -1: # another download is running self.setWait(15 * 60) else: - self.setWait(result[1], reconnect=True) + self.setWait(result[1], True) self.wait() self.retry(5) else: self.invalidCaptcha() - self.fail("Received invalid captcha 5 times") + self.fail(_("Received invalid captcha 5 times")) + def getFileInfo(self, token, fileId): apiUrl = "https://api.oboom.com/1.0/info" @@ -87,43 +117,29 @@ class OboomCom(Hoster): result = self.loadUrl(apiUrl, params) if result[0] == 200: item = result[1][0] - if item["state"] == "online": - self.fileSize = item["size"] - self.fileName = item["name"] + if item['state'] == "online": + self.fileSize = item['size'] + self.fileName = item['name'] else: self.offline() else: - self.fail("Could not retrieve file info. Error code %s: %s" % (result[0], result[1])) + self.fail(_("Could not retrieve file info. Error code %s: %s") % (result[0], result[1])) + def getDownloadTicket(self): - apiUrl = "https://api.oboom.com/1.0/dl" + apiUrl = "https://api.oboom.com/1/dl" params = {"item": self.fileId, "http_errors": 0} if self.premium: - params["token"] = self.sessionToken + params['token'] = self.sessionToken else: - params["token"] = self.downloadToken - params["auth"] = self.downloadAuth + params['token'] = self.downloadToken + params['auth'] = self.downloadAuth result = self.loadUrl(apiUrl, params) if result[0] == 200: self.downloadDomain = result[1] self.downloadTicket = result[2] + elif result[0] == 421: + self.retry(wait_time=result[2] + 60, reason=_("Connection limit exceeded")) else: - self.fail("Could not retrieve download ticket. Error code %s" % result[0]) - - def setup(self): - self.chunkLimit = 1 - self.multiDL = self.premium - - def process(self, pyfile): - self.pyfile.url.replace(".com/#id=", ".com/#") - self.pyfile.url.replace(".com/#/", ".com/#") - self.getFileId(self.pyfile.url) - self.getSessionToken() - self.getFileInfo(self.sessionToken, self.fileId) - self.pyfile.name = self.fileName - self.pyfile.size = self.fileSize - if not self.premium: - self.solveCaptcha() - self.getDownloadTicket() - self.download("https://%s/1.0/dlh" % self.downloadDomain, get={"ticket": self.downloadTicket, "http_errors": 0}) + self.fail(_("Could not retrieve download ticket. Error code: %s") % result[0]) diff --git a/module/plugins/hoster/OneFichierCom.py b/module/plugins/hoster/OneFichierCom.py index 41f3e4b11..f0e16a101 100644 --- a/module/plugins/hoster/OneFichierCom.py +++ b/module/plugins/hoster/OneFichierCom.py @@ -1,86 +1,60 @@ # -*- coding: utf-8 -*- -# Test links (random.bin): -# http://5pnm24ltcw.1fichier.com/ - import re from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class OneFichierCom(SimpleHoster): - __name__ = "OneFichierCom" - __type__ = "hoster" - __pattern__ = r'(http://(?P<id>\w+)\.(?P<host>(1fichier|d(es)?fichiers|pjointe)\.(com|fr|net|org)|(cjoint|mesfichiers|piecejointe|oi)\.(org|net)|tenvoi\.(com|org|net)|dl4free\.com|alterupload\.com|megadl.fr))/?' - __version__ = "0.61" - __description__ = """1fichier.com hoster plugin""" - __author_name__ = ("fragonib", "the-razer", "zoidberg", "imclem", "stickell", "Elrick69") - __author_mail__ = ("fragonib[AT]yahoo[DOT]es", "daniel_ AT gmx DOT net", "zoidberg@mujmail.cz", - "imclem on github", "l.stickell@yahoo.it", "elrick69[AT]rocketmail[DOT]com") + __name__ = "OneFichierCom" + __type__ = "hoster" + __version__ = "0.75" - FILE_NAME_PATTERN = r'">Filename :</th>\s*<td>(?P<N>[^<]+)</td>' - FILE_SIZE_PATTERN = r'<th>Size :</th>\s*<td>(?P<S>[^<]+)</td>' - FILE_OFFLINE_PATTERN = r'The (requested)? file (could not be found|has been deleted)' + __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+))?' - FILE_URL_REPLACEMENTS = [(__pattern__, r'http://\g<id>.\g<host>/en/')] + __description__ = """1fichier.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("fragonib", "fragonib[AT]yahoo[DOT]es"), + ("the-razer", "daniel_ AT gmx DOT net"), + ("zoidberg", "zoidberg@mujmail.cz"), + ("imclem", None), + ("stickell", "l.stickell@yahoo.it"), + ("Elrick69", "elrick69[AT]rocketmail[DOT]com"), + ("Walter Purcaro", "vuolter@gmail.com")] - WAITING_PATTERN = "Warning ! Without premium status, you must wait between each downloads" - NOT_PARALLEL = r"Warning ! Without premium status, you can download only one file at a time" - WAIT_TIME = 10 * 60 # Retry time between each free download - RETRY_TIME = 15 * 60 # Default retry time in seconds (if detected parallel download) - def setup(self): - self.multiDL = self.premium - self.resumeDownload = True + NAME_PATTERN = r'>FileName :</td>\s*<td.*>(?P<N>.+?)<' + SIZE_PATTERN = r'>Size :</td>\s*<td.*>(?P<S>[\d.,]+) (?P<U>[\w^_]+)' - def handleFree(self): - self.html = self.load(self.pyfile.url, decode=True) + OFFLINE_PATTERN = r'File not found !\s*<' - if self.WAITING_PATTERN in self.html: - self.logInfo('You have to wait been each free download! Retrying in %d seconds.' % self.WAIT_TIME) - self.waitAndRetry(self.WAIT_TIME) - else: # detect parallel download - found = re.search(self.NOT_PARALLEL, self.html) - if found: - self.waitAndRetry(self.RETRY_TIME) + COOKIES = [("1fichier.com", "LG", "en")] - url, inputs = self.parseHtmlForm('action="http://%s' % self.file_info['id']) - if not url: - self.parseError("Download link not found") + WAIT_PATTERN = r'>You must wait (\d+) minutes' - # Check for protection - if "pass" in inputs: - inputs['pass'] = self.getPassword() - inputs['submit'] = "Download" - self.download(url, post=inputs) + def setup(self): + self.multiDL = self.premium + self.resumeDownload = True - # Check download - self.checkDownloadedFile() - def handlePremium(self): - url, inputs = self.parseHtmlForm('action="http://%s' % self.file_info['id']) + def handleFree(self): + id = self.info['pattern']['ID1'] or self.info['pattern']['ID2'] + url, inputs = self.parseHtmlForm('action="https://1fichier.com/\?%s' % id) + if not url: - self.parseError("Download link not found") + self.fail(_("Download link not found")) - # Check for protection if "pass" in inputs: inputs['pass'] = self.getPassword() + inputs['submit'] = "Download" self.download(url, post=inputs) - # Check download - self.checkDownloadedFile() - def checkDownloadedFile(self): - check = self.checkDownload({"wait": self.WAITING_PATTERN}) - if check == "wait": - self.waitAndRetry(int(self.lastcheck.group(1)) * 60) - - def waitAndRetry(self, wait_time): - self.wait(wait_time, True) - self.retry() + def handlePremium(self): + return self.handleFree() getInfo = create_getInfo(OneFichierCom) diff --git a/module/plugins/hoster/OronCom.py b/module/plugins/hoster/OronCom.py new file mode 100644 index 000000000..7e8423ec9 --- /dev/null +++ b/module/plugins/hoster/OronCom.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo + + +class OronCom(DeadHoster): + __name__ = "OronCom" + __type__ = "hoster" + __version__ = "0.14" + + __pattern__ = r'https?://(?:www\.)?oron\.com/\w{12}' + + __description__ = """Oron.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("chrox", "chrox@pyload.org"), + ("DHMH", "DHMH@pyload.org")] + + +getInfo = create_getInfo(OronCom) diff --git a/module/plugins/hoster/OverLoadMe.py b/module/plugins/hoster/OverLoadMe.py index aaa1442e4..54f869635 100644 --- a/module/plugins/hoster/OverLoadMe.py +++ b/module/plugins/hoster/OverLoadMe.py @@ -1,78 +1,82 @@ # -*- coding: utf-8 -*- import re -from urllib import unquote + from random import randrange +from urllib import unquote -from module.plugins.Hoster import Hoster from module.common.json_layer import json_loads +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo from module.utils import parseFileSize -class OverLoadMe(Hoster): - __name__ = "OverLoadMe" - __version__ = "0.01" - __type__ = "hoster" - __pattern__ = r'https?://.*overload\.me.*' +class OverLoadMe(MultiHoster): + __name__ = "OverLoadMe" + __type__ = "hoster" + __version__ = "0.06" + + __pattern__ = r'https?://.*overload\.me/.+' + __description__ = """Over-Load.me hoster plugin""" - __author_name__ = "marley" - __author_mail__ = "marley@over-load.me" + __license__ = "GPLv3" + __authors__ = [("marley", "marley@over-load.me")] + def getFilename(self, url): try: name = unquote(url.rsplit("/", 1)[1]) except IndexError: name = "Unknown_Filename..." - if name.endswith("..."): # incomplete filename, append random stuff + if name.endswith("..."): #: incomplete filename, append random stuff name += "%s.tmp" % randrange(100, 999) return name + def setup(self): - self.chunkLimit = 5 + self.chunkLimit = 5 self.resumeDownload = True - def process(self, pyfile): - if re.match(self.__pattern__, pyfile.url): - new_url = pyfile.url - elif not self.account: - self.logError(_("Please enter your %s account or deactivate this plugin") % "Over-Load") - self.fail("No Over-Load account provided") - else: - self.logDebug("Old URL: %s" % pyfile.url) - data = self.account.getAccountData(self.user) - page = self.load("https://api.over-load.me/getdownload.php", - get={"auth": data["password"], "link": pyfile.url}) - data = json_loads(page) + def handlePremium(self): + data = self.account.getAccountData(self.user) + + page = self.load("https://api.over-load.me/getdownload.php", + get={"auth": data['password'], "link": self.pyfile.url}) + data = json_loads(page) - self.logDebug("Returned Data: %s" % data) + self.logDebug("Returned Data: %s" % data) - if data["err"] == 1: - self.logWarning(data["msg"]) - self.tempOffline() - else: - if pyfile.name is not None and pyfile.name.endswith('.tmp') and data["filename"]: - pyfile.name = data["filename"] - pyfile.size = parseFileSize(data["filesize"]) - new_url = data["downloadlink"] + if data['error'] == 1: + self.logWarning(data['msg']) + self.tempOffline() + else: + if self.pyfile.name is not None and self.pyfile.name.endswith('.tmp') and data['filename']: + self.pyfile.name = data['filename'] + self.pyfile.size = parseFileSize(data['filesize']) + self.link = data['downloadlink'] if self.getConfig("https"): - new_url = new_url.replace("http://", "https://") + self.link = self.link.replace("http://", "https://") else: - new_url = new_url.replace("https://", "http://") + self.link = self.link.replace("https://", "http://") - if new_url != pyfile.url: - self.logDebug("New URL: %s" % new_url) + if self.link != self.pyfile.url: + self.logDebug("New URL: %s" % self.link) - if pyfile.name.startswith("http") or pyfile.name.startswith("Unknown") or pyfile.name.endswith('..'): + if self.pyfile.name.startswith("http") or self.pyfile.name.startswith("Unknown") or self.pyfile.name.endswith('..'): # only use when name wasn't already set - pyfile.name = self.getFilename(new_url) + self.pyfile.name = self.getFilename(self.link) - self.download(new_url, disposition=True) + + def checkFile(self): + super(OverLoadMe, self).checkFile() check = self.checkDownload( {"error": "<title>An error occured while processing your request</title>"}) if check == "error": # usual this download can safely be retried - self.retry(reason="An error occured while generating link.", wait_time=60) + self.retry(wait_time=60, reason=_("An error occured while generating link.")) + + +getInfo = create_getInfo(OverLoadMe) diff --git a/module/plugins/hoster/PandaPlanet.py b/module/plugins/hoster/PandaPlanet.py deleted file mode 100644 index b6aa77b03..000000000 --- a/module/plugins/hoster/PandaPlanet.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- - -# Test links: -# test.bin - 214 B - http://pandapla.net/pew1cz3ot586 -# BigBuckBunny_320x180.mp4 - 61.7 Mb - http://pandapla.net/tz0rgjfyyoh7 - -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo - - -class PandaPlanet(XFileSharingPro): - __name__ = "PandaPlanet" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?pandapla\.net/\w{12}' - __version__ = "0.01" - __description__ = """Pandapla.net hoster plugin""" - __author_name__ = "t4skforce" - __author_mail__ = "t4skforce1337[AT]gmail[DOT]com" - - HOSTER_NAME = "pandapla.net" - - FILE_SIZE_PATTERN = r'File Size:</b>\s*</td>\s*<td[^>]*>(?P<S>[^<]+)</td>\s*</tr>' - FILE_NAME_PATTERN = r'File Name:</b>\s*</td>\s*<td[^>]*>(?P<N>[^<]+)</td>\s*</tr>' - DIRECT_LINK_PATTERN = r'(http://([^/]*?%s|\d+\.\d+\.\d+\.\d+)(:\d+)?(/d/|(?:/files)?/\d+/\w+/)[^"\'<]+\/(?!video\.mp4)[^"\'<]+)' % HOSTER_NAME - - -getInfo = create_getInfo(PandaPlanet) diff --git a/module/plugins/hoster/PandaplaNet.py b/module/plugins/hoster/PandaplaNet.py new file mode 100644 index 000000000..78a1ed177 --- /dev/null +++ b/module/plugins/hoster/PandaplaNet.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo + + +class PandaplaNet(DeadHoster): + __name__ = "PandaplaNet" + __type__ = "hoster" + __version__ = "0.03" + + __pattern__ = r'http://(?:www\.)?pandapla\.net/\w{12}' + + __description__ = """Pandapla.net hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("t4skforce", "t4skforce1337[AT]gmail[DOT]com")] + + +getInfo = create_getInfo(PandaplaNet) diff --git a/module/plugins/hoster/PornhostCom.py b/module/plugins/hoster/PornhostCom.py index 61b382c81..71342f3e0 100644 --- a/module/plugins/hoster/PornhostCom.py +++ b/module/plugins/hoster/PornhostCom.py @@ -1,17 +1,21 @@ # -*- coding: utf-8 -*- import re + from module.plugins.Hoster import Hoster class PornhostCom(Hoster): - __name__ = "PornhostCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?pornhost\.com/([0-9]+/[0-9]+\.html|[0-9]+)' - __version__ = "0.2" + __name__ = "PornhostCom" + __type__ = "hoster" + __version__ = "0.20" + + __pattern__ = r'http://(?:www\.)?pornhost\.com/(\d+/\d+\.html|\d+)' + __description__ = """Pornhost.com hoster plugin""" - __author_name__ = "jeix" - __author_mail__ = "jeix@hasnomail.de" + __license__ = "GPLv3" + __authors__ = [("jeix", "jeix@hasnomail.de")] + def process(self, pyfile): self.download_html() @@ -21,50 +25,52 @@ class PornhostCom(Hoster): pyfile.name = self.get_file_name() self.download(self.get_file_url()) - ### old interface + + # Old interface def download_html(self): url = self.pyfile.url self.html = self.load(url) + def get_file_url(self): """ returns the absolute downloadable filepath """ - if self.html is None: + if not self.html: self.download_html() - file_url = re.search(r'download this file</label>.*?<a href="(.*?)"', self.html) - if not file_url: - file_url = re.search(r'"(http://dl[0-9]+\.pornhost\.com/files/.*?/.*?/.*?/.*?/.*?/.*?\..*?)"', self.html) - if not file_url: - file_url = re.search(r'width: 894px; height: 675px">.*?<img src="(.*?)"', self.html) - if not file_url: - file_url = re.search(r'"http://file[0-9]+\.pornhost\.com/[0-9]+/.*?"', - self.html) # TODO: fix this one since it doesn't match + url = re.search(r'download this file</label>.*?<a href="(.*?)"', self.html) + if url is None: + url = re.search(r'"(http://dl\d+\.pornhost\.com/files/.*?/.*?/.*?/.*?/.*?/.*?\..*?)"', self.html) + if url is None: + url = re.search(r'width: 894px; height: 675px">.*?<img src="(.*?)"', self.html) + if url is None: + url = re.search(r'"http://file\d+\.pornhost\.com/\d+/.*?"', + self.html) # TODO: fix this one since it doesn't match - file_url = file_url.group(1).strip() + return url.group(1).strip() - return file_url def get_file_name(self): - if self.html is None: + if not self.html: self.download_html() name = re.search(r'<title>pornhost\.com - free file hosting with a twist - gallery(.*?)</title>', self.html) - if not name: + if name is None: name = re.search(r'id="url" value="http://www\.pornhost\.com/(.*?)/"', self.html) - if not name: + if name is None: name = re.search(r'<title>pornhost\.com - free file hosting with a twist -(.*?)</title>', self.html) - if not name: - name = re.search(r'"http://file[0-9]+\.pornhost\.com/.*?/(.*?)"', self.html) + if name is None: + name = re.search(r'"http://file\d+\.pornhost\.com/.*?/(.*?)"', self.html) name = name.group(1).strip() + ".flv" return name + def file_exists(self): """ returns True or False """ - if self.html is None: + if not self.html: self.download_html() if (re.search(r'gallery not found', self.html) is not None or diff --git a/module/plugins/hoster/PornhubCom.py b/module/plugins/hoster/PornhubCom.py index 29205b381..1bb787f09 100644 --- a/module/plugins/hoster/PornhubCom.py +++ b/module/plugins/hoster/PornhubCom.py @@ -1,17 +1,21 @@ # -*- coding: utf-8 -*- import re + from module.plugins.Hoster import Hoster class PornhubCom(Hoster): - __name__ = "PornhubCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?pornhub\.com/view_video\.php\?viewkey=[\w\d]+' - __version__ = "0.5" + __name__ = "PornhubCom" + __type__ = "hoster" + __version__ = "0.50" + + __pattern__ = r'http://(?:www\.)?pornhub\.com/view_video\.php\?viewkey=\w+' + __description__ = """Pornhub.com hoster plugin""" - __author_name__ = "jeix" - __author_mail__ = "jeix@hasnomail.de" + __license__ = "GPLv3" + __authors__ = [("jeix", "jeix@hasnomail.de")] + def process(self, pyfile): self.download_html() @@ -21,14 +25,16 @@ class PornhubCom(Hoster): pyfile.name = self.get_file_name() self.download(self.get_file_url()) + def download_html(self): url = self.pyfile.url self.html = self.load(url) + def get_file_url(self): """ returns the absolute downloadable filepath """ - if self.html is None: + if not self.html: self.download_html() url = "http://www.pornhub.com//gateway.php" @@ -40,7 +46,7 @@ class PornhubCom(Hoster): post_data += "\x02\x00\x02\x2d\x31\x02\x00\x20" post_data += "add299463d4410c6d1b1c418868225f7" - content = self.req.load(url, post=str(post_data)) + content = self.load(url, post=str(post_data)) new_content = "" for x in content: @@ -51,17 +57,16 @@ class PornhubCom(Hoster): content = new_content - file_url = re.search(r'flv_url.*(http.*?)##post_roll', content).group(1) + return re.search(r'flv_url.*(http.*?)##post_roll', content).group(1) - return file_url def get_file_name(self): - if self.html is None: + if not self.html: self.download_html() - match = re.search(r'<title[^>]+>([^<]+) - ', self.html) - if match: - name = match.group(1) + m = re.search(r'<title[^>]+>([^<]+) - ', self.html) + if m: + name = m.group(1) else: matches = re.findall('<h1>(.*?)</h1>', self.html) if len(matches) > 1: @@ -71,10 +76,11 @@ class PornhubCom(Hoster): return name + '.flv' + def file_exists(self): """ returns True or False """ - if self.html is None: + if not self.html: self.download_html() if re.search(r'This video is no longer in our database or is in conversion', self.html) is not None: diff --git a/module/plugins/hoster/PotloadCom.py b/module/plugins/hoster/PotloadCom.py index ffcfad1a5..d6261af3a 100644 --- a/module/plugins/hoster/PotloadCom.py +++ b/module/plugins/hoster/PotloadCom.py @@ -1,18 +1,18 @@ # -*- coding: utf-8 -*- -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo -class PotloadCom(XFileSharingPro): - __name__ = "PotloadCom" - __type__ = "hoster" - __pattern__ = r"http://(?:www\.)?potload\.com/\w{12}" - __version__ = "0.01" - __description__ = """billionuploads.com hoster plugin""" - __author_name__ = ("stickell") - __author_mail__ = ("l.stickell@yahoo.it") - FILE_INFO_PATTERN = r'<h[1-6]>(?P<N>.+) \((?P<S>\d+) (?P<U>\w+)\)</h' - HOSTER_NAME = "potload.com" +class PotloadCom(DeadHoster): + __name__ = "PotloadCom" + __type__ = "hoster" + __version__ = "0.02" + + __pattern__ = r'http://(?:www\.)?potload\.com/\w{12}' + + __description__ = """Potload.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it")] getInfo = create_getInfo(PotloadCom) diff --git a/module/plugins/hoster/Premium4Me.py b/module/plugins/hoster/Premium4Me.py deleted file mode 100644 index e66e76ce1..000000000 --- a/module/plugins/hoster/Premium4Me.py +++ /dev/null @@ -1,70 +0,0 @@ -# -*- coding: utf-8 -*- - -from urllib import quote -from os.path import exists -from os import remove - -from module.plugins.Hoster import Hoster -from module.utils import fs_encode - - -class Premium4Me(Hoster): - __name__ = "Premium4Me" - __version__ = "0.08" - __type__ = "hoster" - - __pattern__ = r'http://(?:www\.)?premium.to/.*' - __description__ = """Premium.to hoster plugin""" - __author_name__ = ("RaNaN", "zoidberg", "stickell") - __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz", "l.stickell@yahoo.it") - - def setup(self): - self.resumeDownload = True - self.chunkLimit = 1 - - def process(self, pyfile): - if not self.account: - self.logError(_("Please enter your %s account or deactivate this plugin") % "premium.to") - self.fail("No premium.to account provided") - - self.logDebug("premium.to: Old URL: %s" % pyfile.url) - - tra = self.getTraffic() - - #raise timeout to 2min - self.req.setOption("timeout", 120) - - self.download( - "http://premium.to/api/getfile.php?authcode=%s&link=%s" % (self.account.authcode, quote(pyfile.url, "")), - disposition=True) - - check = self.checkDownload({"nopremium": "No premium account available"}) - - if check == "nopremium": - self.retry(60, 5 * 60, "No premium account available") - - err = '' - if self.req.http.code == '420': - # Custom error code send - fail - lastDownload = fs_encode(self.lastDownload) - - if exists(lastDownload): - f = open(lastDownload, "rb") - err = f.read(256).strip() - f.close() - remove(lastDownload) - else: - err = 'File does not exist' - - trb = self.getTraffic() - self.logInfo("Filesize: %d, Traffic used %d, traffic left %d" % (pyfile.size, tra - trb, trb)) - - if err: - self.fail(err) - - def getTraffic(self): - try: - traffic = int(self.load("http://premium.to/api/traffic.php?authcode=%s" % self.account.authcode)) - except: - traffic = 0 - return traffic diff --git a/module/plugins/hoster/PremiumTo.py b/module/plugins/hoster/PremiumTo.py new file mode 100644 index 000000000..fa4caad5a --- /dev/null +++ b/module/plugins/hoster/PremiumTo.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- + +from __future__ import with_statement + +from os import remove +from os.path import exists +from urllib import quote + +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo +from module.utils import fs_encode + + +class PremiumTo(MultiHoster): + __name__ = "PremiumTo" + __type__ = "hoster" + __version__ = "0.16" + + __pattern__ = r'https?://(?:www\.)?premium\.to/.+' + + __description__ = """Premium.to hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("RaNaN", "RaNaN@pyload.org"), + ("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it")] + + + def setup(self): + self.resumeDownload = True + self.chunkLimit = 1 + + + def handlePremium(self): + #raise timeout to 2min + self.req.setOption("timeout", 120) + + self.link = True + self.download("http://premium.to/api/getfile.php", + get={'username': self.account.username, + 'password': self.account.password, + 'link' : quote(self.pyfile.url, "")}, + disposition=True) + + + def checkFile(self): + super(PremiumTo, self).checkFile() + + check = self.checkDownload({"nopremium": "No premium account available"}) + + if check == "nopremium": + self.retry(60, 5 * 60, "No premium account available") + + err = '' + if self.req.http.code == '420': + # Custom error code send - fail + lastDownload = fs_encode(self.lastDownload) + with open(lastDownload, "rb") as f: + err = f.read(256).strip() + remove(lastDownload) + + if err: + self.fail(err) + + +getInfo = create_getInfo(PremiumTo) diff --git a/module/plugins/hoster/PremiumizeMe.py b/module/plugins/hoster/PremiumizeMe.py index 7e646fdf9..07536062f 100644 --- a/module/plugins/hoster/PremiumizeMe.py +++ b/module/plugins/hoster/PremiumizeMe.py @@ -1,57 +1,60 @@ # -*- coding: utf-8 -*- -from module.plugins.Hoster import Hoster - from module.common.json_layer import json_loads +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -class PremiumizeMe(Hoster): - __name__ = "PremiumizeMe" - __version__ = "0.12" - __type__ = "hoster" - __description__ = """Premiumize.me hoster plugin""" +class PremiumizeMe(MultiHoster): + __name__ = "PremiumizeMe" + __type__ = "hoster" + __version__ = "0.15" - # Since we want to allow the user to specify the list of hoster to use we let MultiHoster.coreReady - # create the regex patterns for us using getHosters in our PremiumizeMe hook. - __pattern__ = None + __pattern__ = r'^unmatchable$' #: Since we want to allow the user to specify the list of hoster to use we let MultiHoster.coreReady - __author_name__ = "Florian Franzen" - __author_mail__ = "FlorianFranzen@gmail.com" + __description__ = """Premiumize.me hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("Florian Franzen", "FlorianFranzen@gmail.com")] - def process(self, pyfile): - # Check account - if not self.account or not self.account.canUse(): - self.logError(_("Please enter your %s account or deactivate this plugin") % "premiumize.me") - self.fail("No valid premiumize.me account provided") + def handlePremium(self): # In some cases hostsers do not supply us with a filename at download, so we # are going to set a fall back filename (e.g. for freakshare or xfileshare) - pyfile.name = pyfile.name.split('/').pop() # Remove everthing before last slash + self.pyfile.name = self.pyfile.name.split('/').pop() # Remove everthing before last slash # Correction for automatic assigned filename: Removing html at end if needed suffix_to_remove = ["html", "htm", "php", "php3", "asp", "shtm", "shtml", "cfml", "cfm"] - temp = pyfile.name.split('.') + temp = self.pyfile.name.split('.') if temp.pop() in suffix_to_remove: - pyfile.name = ".".join(temp) + self.pyfile.name = ".".join(temp) # Get account data - (user, data) = self.account.selectAccount() + user, data = self.account.selectAccount() # Get rewritten link using the premiumize.me api v1 (see https://secure.premiumize.me/?show=api) - answer = self.load( - "https://api.premiumize.me/pm-api/v1.php?method=directdownloadlink¶ms[login]=%s¶ms[pass]=%s¶ms[link]=%s" % ( - user, data['password'], pyfile.url)) - data = json_loads(answer) + data = json_loads(self.load("https://api.premiumize.me/pm-api/v1.php", + get={'method' : "directdownloadlink", + 'params[login]': user, + 'params[pass]' : data['password'], + 'params[link]' : self.pyfile.url})) # Check status and decide what to do status = data['status'] + if status == 200: - self.download(data['result']['location'], disposition=True) + self.link = data['result']['location'] + return + elif status == 400: - self.fail("Invalid link") + self.fail(_("Invalid link")) + elif status == 404: self.offline() + elif status >= 500: self.tempOffline() + else: self.fail(data['statusmessage']) + + +getInfo = create_getInfo(PremiumizeMe) diff --git a/module/plugins/hoster/PromptfileCom.py b/module/plugins/hoster/PromptfileCom.py index 3580a9509..af38c4e15 100644 --- a/module/plugins/hoster/PromptfileCom.py +++ b/module/plugins/hoster/PromptfileCom.py @@ -1,56 +1,45 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################ - import re from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class PromptfileCom(SimpleHoster): - __name__ = "PromptfileCom" - __type__ = "hoster" - __pattern__ = r"https?://(?:www\.)?promptfile\.com/" - __version__ = "0.1" - __description__ = """Promptfile.Com File Download Hoster""" - __author_name__ = ("igel") + __name__ = "PromptfileCom" + __type__ = "hoster" + __version__ = "0.12" + + __pattern__ = r'https?://(?:www\.)?promptfile\.com/' + + __description__ = """Promptfile.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("igel", "igelkun@myopera.com")] - FILE_INFO_PATTERN = r'<span style="[^"]*" title="[^"]*">(?P<N>.*?) \((?P<S>[\d.]+) (?P<U>\w+)\)</span>' - FILE_OFFLINE_PATTERN = r'<span style="[^"]*" title="File Not Found">File Not Found</span>' + + INFO_PATTERN = r'<span style="[^"]*" title="[^"]*">(?P<N>.*?) \((?P<S>[\d.,]+) (?P<U>[\w^_]+)\)</span>' + OFFLINE_PATTERN = r'<span style="[^"]*" title="File Not Found">File Not Found</span>' CHASH_PATTERN = r'<input type="hidden" name="chash" value="([^"]*)" />' - DIRECT_LINK_PATTERN = r"clip: {\s*url: '(https?://(?:www\.)promptfile[^']*)'," + LINK_PATTERN = r'<a href=\"(.+)\" target=\"_blank\" class=\"view_dl_link\">Download File</a>' + def handleFree(self): # STAGE 1: get link to continue m = re.search(self.CHASH_PATTERN, self.html) - if not m: - self.parseError("Unable to detect chash") + if m is None: + self.error(_("CHASH_PATTERN not found")) chash = m.group(1) - self.logDebug("read chash %s" % chash) + self.logDebug("Read chash %s" % chash) # continue to stage2 self.html = self.load(self.pyfile.url, decode=True, post={'chash': chash}) # STAGE 2: get the direct link - m = re.search(self.DIRECT_LINK_PATTERN, self.html, re.MULTILINE | re.DOTALL) - if not m: - self.parseError("Unable to detect direct link") - direct = m.group(1) - self.logDebug('found direct link: ' + direct) - self.download(direct, disposition=True) + m = re.search(self.LINK_PATTERN, self.html) + if m is None: + self.error(_("LINK_PATTERN not found")) + + self.download(m.group(1), disposition=True) getInfo = create_getInfo(PromptfileCom) diff --git a/module/plugins/hoster/PrzeklejPl.py b/module/plugins/hoster/PrzeklejPl.py new file mode 100644 index 000000000..3a59a2c9e --- /dev/null +++ b/module/plugins/hoster/PrzeklejPl.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo + + +class PrzeklejPl(DeadHoster): + __name__ = "PrzeklejPl" + __type__ = "hoster" + __version__ = "0.11" + + __pattern__ = r'http://(?:www\.)?przeklej\.pl/plik/.+' + + __description__ = """Przeklej.pl hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + +getInfo = create_getInfo(PrzeklejPl) diff --git a/module/plugins/hoster/PutlockerCom.py b/module/plugins/hoster/PutlockerCom.py deleted file mode 100644 index a453eaf62..000000000 --- a/module/plugins/hoster/PutlockerCom.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################### -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -# @author: Walter Purcaro -############################################################################### - -import re - -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo - - -class PutlockerCom(SimpleHoster): - __name__ = "PutlockerCom" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?(firedrive|putlocker)\.com/(mobile/)?(file|embed)/(?P<ID>\w+)' - __version__ = "0.33" - __description__ = """Firedrive.com hoster plugin""" - __author_name__ = "Walter Purcaro" - __author_mail__ = "vuolter@gmail.com" - - FILE_NAME_PATTERN = r'<b>Name:</b> (?P<N>.+) <br>' - FILE_SIZE_PATTERN = r'<b>Size:</b> (?P<S>[\d.]+) (?P<U>[a-zA-Z]+) <br>' - FILE_OFFLINE_PATTERN = r"<div class=\"sad_face_image\">" - - FILE_URL_REPLACEMENTS = [(__pattern__, r'http://www.firedrive.com/file/\g<ID>')] - - def setup(self): - self.multiDL = self.resumeDownload = True - self.chunkLimit = -1 - - def handleFree(self): - link = self._getLink() - self.logDebug("Direct link: " + link) - self.download(link, disposition=True) - - def _getLink(self): - self.html = self.load(self.pyfile.url, post={"confirm": re.search(r'name="confirm" value="(.*)"', self.html).group(1)}) - return re.search(r'<a href="(https?://dl\.firedrive\.com/.*?)"', self.html).group(1) - - -getInfo = create_getInfo(PutlockerCom) diff --git a/module/plugins/hoster/QuickshareCz.py b/module/plugins/hoster/QuickshareCz.py index 46639444e..85c25f6f0 100644 --- a/module/plugins/hoster/QuickshareCz.py +++ b/module/plugins/hoster/QuickshareCz.py @@ -1,47 +1,35 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re + from pycurl import FOLLOWLOCATION from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class QuickshareCz(SimpleHoster): - __name__ = "QuickshareCz" - __type__ = "hoster" - __pattern__ = r'http://(?:[^/]*\.)?quickshare.cz/stahnout-soubor/.*' - __version__ = "0.54" + __name__ = "QuickshareCz" + __type__ = "hoster" + __version__ = "0.55" + + __pattern__ = r'http://(?:[^/]*\.)?quickshare\.cz/stahnout-soubor/.+' + __description__ = """Quickshare.cz hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + + NAME_PATTERN = r'<th width="145px">Název:</th>\s*<td style="word-wrap:break-word;">(?P<N>[^<]+)</td>' + SIZE_PATTERN = r'<th>Velikost:</th>\s*<td>(?P<S>[\d.,]+) (?P<U>[\w^_]+)</td>' + OFFLINE_PATTERN = r'<script type="text/javascript">location\.href=\'/chyba\';</script>' - FILE_NAME_PATTERN = r'<th width="145px">Název:</th>\s*<td style="word-wrap:break-word;">(?P<N>[^<]+)</td>' - FILE_SIZE_PATTERN = r'<th>Velikost:</th>\s*<td>(?P<S>[0-9.]+) (?P<U>[kKMG])i?B</td>' - FILE_OFFLINE_PATTERN = r'<script type="text/javascript">location.href=\'/chyba\';</script>' def process(self, pyfile): self.html = self.load(pyfile.url, decode=True) self.getFileInfo() # parse js variables - self.jsvars = dict((x, y.strip("'")) for x, y in re.findall(r"var (\w+) = ([0-9.]+|'[^']*')", self.html)) + self.jsvars = dict((x, y.strip("'")) for x, y in re.findall(r"var (\w+) = ([\d.]+|'[^']*')", self.html)) self.logDebug(self.jsvars) pyfile.name = self.jsvars['ID3'] @@ -49,11 +37,11 @@ class QuickshareCz(SimpleHoster): if self.premium: if 'UU_prihlasen' in self.jsvars: if self.jsvars['UU_prihlasen'] == '0': - self.logWarning('User not logged in') + self.logWarning(_("User not logged in")) self.relogin(self.user) self.retry() elif float(self.jsvars['UU_kredit']) < float(self.jsvars['kredit_odecet']): - self.logWarning('Not enough credit left') + self.logWarning(_("Not enough credit left")) self.premium = False if self.premium: @@ -63,12 +51,13 @@ class QuickshareCz(SimpleHoster): check = self.checkDownload({"err": re.compile(r"\AChyba!")}, max_size=100) if check == "err": - self.fail("File not found or plugin defect") + self.fail(_("File not m or plugin defect")) + def handleFree(self): # get download url download_url = '%s/download.php' % self.jsvars['server'] - data = dict((x, self.jsvars[x]) for x in self.jsvars if x in ('ID1', 'ID2', 'ID3', 'ID4')) + data = dict((x, self.jsvars[x]) for x in self.jsvars if x in ("ID1", "ID2", "ID3", "ID4")) self.logDebug("FREE URL1:" + download_url, data) self.req.http.c.setopt(FOLLOWLOCATION, 0) @@ -76,29 +65,29 @@ class QuickshareCz(SimpleHoster): self.header = self.req.http.header self.req.http.c.setopt(FOLLOWLOCATION, 1) - found = re.search("Location\s*:\s*(.*)", self.header, re.I) - if not found: - self.fail('File not found') - download_url = found.group(1) + m = re.search(r'Location\s*:\s*(.+)', self.header, re.I) + if m is None: + self.fail(_("File not found")) + download_url = m.group(1).rstrip() #@TODO: Remove .rstrip() in 0.4.10 self.logDebug("FREE URL2:" + download_url) # check errors - found = re.search(r'/chyba/(\d+)', download_url) - if found: - if found.group(1) == '1': + m = re.search(r'/chyba/(\d+)', download_url) + if m: + if m.group(1) == '1': self.retry(60, 2 * 60, "This IP is already downloading") - elif found.group(1) == '2': + elif m.group(1) == '2': self.retry(60, 60, "No free slots available") else: - self.fail('Error %d' % found.group(1)) + self.fail(_("Error %d") % m.group(1)) # download file self.download(download_url) + def handlePremium(self): download_url = '%s/download_premium.php' % self.jsvars['server'] - data = dict((x, self.jsvars[x]) for x in self.jsvars if x in ('ID1', 'ID2', 'ID4', 'ID5')) - self.logDebug("PREMIUM URL:" + download_url, data) + data = dict((x, self.jsvars[x]) for x in self.jsvars if x in ("ID1", "ID2", "ID4", "ID5")) self.download(download_url, get=data) diff --git a/module/plugins/hoster/RPNetBiz.py b/module/plugins/hoster/RPNetBiz.py index 57c22698d..bffa5ef85 100644 --- a/module/plugins/hoster/RPNetBiz.py +++ b/module/plugins/hoster/RPNetBiz.py @@ -2,77 +2,81 @@ import re -from module.plugins.Hoster import Hoster +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo from module.common.json_layer import json_loads -class RPNetBiz(Hoster): - __name__ = "RPNetBiz" - __version__ = "0.1" - __type__ = "hoster" +class RPNetBiz(MultiHoster): + __name__ = "RPNetBiz" + __type__ = "hoster" + __version__ = "0.13" + __description__ = """RPNet.biz hoster plugin""" - __pattern__ = r'https?://.*rpnet\.biz' - __author_name__ = "Dman" - __author_mail__ = "dmanugm@gmail.com" + __license__ = "GPLv3" + + __pattern__ = r'https?://.+rpnet\.biz' + __authors__ = [("Dman", "dmanugm@gmail.com")] + def setup(self): - self.chunkLimit = -1 + self.chunkLimit = -1 self.resumeDownload = True - def process(self, pyfile): - if re.match(self.__pattern__, pyfile.url): - link_status = {'generated': pyfile.url} - elif not self.account: - # Check account - self.logError(_("Please enter your %s account or deactivate this plugin") % "rpnet") - self.fail("No rpnet account provided") - else: - (user, data) = self.account.selectAccount() + def handlePremium(self): + user, data = self.account.selectAccount() + + self.logDebug("Original URL: %s" % self.pyfile.url) + # Get the download link + res = self.load("https://premium.rpnet.biz/client_api.php", + get={"username": user, + "password": data['password'], + "action": "generate", + "links": self.pyfile.url}) - self.logDebug("Original URL: %s" % pyfile.url) - # Get the download link - response = self.load("https://premium.rpnet.biz/client_api.php", - get={"username": user, "password": data['password'], - "action": "generate", "links": pyfile.url}) + self.logDebug("JSON data: %s" % res) + link_status = json_loads(res)['links'][0] # get the first link... since we only queried one - self.logDebug("JSON data: %s" % response) - link_status = json_loads(response)['links'][0] # get the first link... since we only queried one + # Check if we only have an id as a HDD link + if 'id' in link_status: + self.logDebug("Need to wait at least 30 seconds before requery") + self.setWait(30) # wait for 30 seconds + self.wait() + # Lets query the server again asking for the status on the link, + # we need to keep doing this until we reach 100 + max_tries = 30 + my_try = 0 + while (my_try <= max_tries): + self.logDebug("Try: %d ; Max Tries: %d" % (my_try, max_tries)) + res = self.load("https://premium.rpnet.biz/client_api.php", + get={"username": user, + "password": data['password'], + "action": "downloadInformation", + "id": link_status['id']}) + self.logDebug("JSON data hdd query: %s" % res) + download_status = json_loads(res)['download'] - # Check if we only have an id as a HDD link - if 'id' in link_status: - self.logDebug("Need to wait at least 30 seconds before requery") - self.setWait(30) # wait for 30 seconds + if download_status['status'] == '100': + link_status['generated'] = download_status['rpnet_link'] + self.logDebug("Successfully downloaded to rpnet HDD: %s" % link_status['generated']) + break + else: + self.logDebug("At %s%% for the file download" % download_status['status']) + + self.setWait(30) self.wait() - # Lets query the server again asking for the status on the link, - # we need to keep doing this until we reach 100 - max_tries = 30 - my_try = 0 - while (my_try <= max_tries): - self.logDebug("Try: %d ; Max Tries: %d" % (my_try, max_tries)) - response = self.load("https://premium.rpnet.biz/client_api.php", - get={"username": user, "password": data['password'], - "action": "downloadInformation", "id": link_status['id']}) - self.logDebug("JSON data hdd query: %s" % response) - download_status = json_loads(response)['download'] - - if download_status['status'] == '100': - link_status['generated'] = download_status['rpnet_link'] - self.logDebug("Successfully downloaded to rpnet HDD: %s" % link_status['generated']) - break - else: - self.logDebug("At %s%% for the file download" % download_status['status']) - - self.setWait(30) - self.wait() - my_try += 1 - - if my_try > max_tries: # We went over the limit! - self.fail("Waited for about 15 minutes for download to finish but failed") + my_try += 1 + + if my_try > max_tries: # We went over the limit! + self.fail(_("Waited for about 15 minutes for download to finish but failed")) if 'generated' in link_status: - self.download(link_status['generated'], disposition=True) + self.link = link_status['generated'] + return elif 'error' in link_status: self.fail(link_status['error']) else: - self.fail("Something went wrong, not supposed to enter here") + self.fail(_("Something went wrong, not supposed to enter here")) + + +getInfo = create_getInfo(RPNetBiz) diff --git a/module/plugins/hoster/RapideoPl.py b/module/plugins/hoster/RapideoPl.py new file mode 100644 index 000000000..9fd20e69e --- /dev/null +++ b/module/plugins/hoster/RapideoPl.py @@ -0,0 +1,102 @@ +# -*- coding: utf-8 -*- + +from module.common.json_layer import json_loads as loads +from module.plugins.internal.SimpleHoster import SimpleHoster + + +class RapideoPl(SimpleHoster): + __name__ = "RapideoPl" + __version__ = "0.01" + __type__ = "hoster" + __description__ = "Rapideo.pl hoster plugin" + __license__ = "GPLv3" + __authors__ = [("goddie", "dev@rapideo.pl")] + + _api_url = "http://enc.rapideo.pl" + + _api_query = {"site": "newrd", + "output": "json", + "username": "", + "password": "", + "url": ""} + + _error_codes = { + 0: "[%s] Incorrect login credentials", + 1: "[%s] Not enough transfer to download - top-up your account", + 2: "[%s] Incorrect / dead link", + 3: "[%s] Error connecting to hosting, try again later", + 9: "[%s] Premium account has expired", + 15: "[%s] Hosting no longer supported", + 80: "[%s] Too many incorrect login attempts, account blocked for 24h" + } + + _usr = False + _pwd = False + + def setup(self): + self.resumeDownload = True + self.multiDL = True + + def get_username_password(self): + if not self.account: + self.fail(_("Please enter your %s account or deactivate this plugin") % "Rapideo.pl") + else: + self._usr = self.account.getAccountData(self.user).get('usr') + self._pwd = self.account.getAccountData(self.user).get('pwd') + + def runFileQuery(self, url, mode=None): + query = self._api_query.copy() + query["username"] = self._usr + query["password"] = self._pwd + query["url"] = url + + if mode == "fileinfo": + query['check'] = 2 + query['loc'] = 1 + + self.logDebug(query) + return self.load(self._api_url, post=query) + + def process(self, pyfile): + self.get_username_password() + try: + data = self.runFileQuery(pyfile.url, 'fileinfo') + except Exception: + self.logDebug("RunFileQuery error") + self.tempOffline() + + try: + parsed = loads(data) + except Exception: + self.logDebug("Loads error") + self.tempOffline() + + self.logDebug(parsed) + + if "errno" in parsed.keys(): + if parsed["errno"] in self._error_codes: + # error code in known + self.fail(self._error_codes[parsed["errno"]] % self.__name__) + else: + # error code isn't yet added to plugin + self.fail( + parsed["errstring"] + or "Unknown error (code: %s)" % parsed["errno"] + ) + + if "sdownload" in parsed: + if parsed["sdownload"] == "1": + self.fail( + "Download from %s is possible only using Rapideo.pl webiste \ + directly. Update this plugin." % parsed["hosting"]) + + pyfile.name = parsed["filename"] + pyfile.size = parsed["filesize"] + + try: + result_dl = self.runFileQuery(pyfile.url, 'filedownload') + except Exception: + self.logDebug("runFileQuery error #2") + self.tempOffline() + + self.download(result_dl, disposition=True) diff --git a/module/plugins/hoster/RapidfileshareNet.py b/module/plugins/hoster/RapidfileshareNet.py new file mode 100644 index 000000000..14d62ee74 --- /dev/null +++ b/module/plugins/hoster/RapidfileshareNet.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo + + +class RapidfileshareNet(XFSHoster): + __name__ = "RapidfileshareNet" + __type__ = "hoster" + __version__ = "0.02" + + __pattern__ = r'http://(?:www\.)?rapidfileshare\.net/\w{12}' + + __description__ = """Rapidfileshare.net hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("guidobelix", "guidobelix@hotmail.it")] + + + HOSTER_DOMAIN = "rapidfileshare.net" + + NAME_PATTERN = r'<input type="hidden" name="fname" value="(?P<N>.+?)">' + SIZE_PATTERN = r'>http://www.rapidfileshare.net/\w+?</font> \((?P<S>[\d.,]+) (?P<U>[\w^_]+)\)</font>' + + OFFLINE_PATTERN = r'>No such file with this filename' + TEMP_OFFLINE_PATTERN = r'The page may have been renamed, removed or be temporarily unavailable.<' + + + def handlePremium(self): + self.fail(_("Premium download not implemented")) + + +getInfo = create_getInfo(RapidfileshareNet) diff --git a/module/plugins/hoster/RapidgatorNet.py b/module/plugins/hoster/RapidgatorNet.py index b966fd1d6..ba6cfcd5c 100644 --- a/module/plugins/hoster/RapidgatorNet.py +++ b/module/plugins/hoster/RapidgatorNet.py @@ -1,93 +1,89 @@ # -*- coding: utf-8 -*- -############################################################################### -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -# @author: zoidberg -############################################################################### import re + from pycurl import HTTPHEADER from module.common.json_layer import json_loads from module.network.HTTPRequest import BadHeader -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.plugins.internal.CaptchaService import ReCaptcha, SolveMedia, AdsCaptcha +from module.plugins.internal.CaptchaService import AdsCaptcha, ReCaptcha, SolveMedia +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, secondsToMidnight class RapidgatorNet(SimpleHoster): - __name__ = "RapidgatorNet" - __type__ = "hoster" + __name__ = "RapidgatorNet" + __type__ = "hoster" + __version__ = "0.27" + __pattern__ = r'http://(?:www\.)?(rapidgator\.net|rg\.to)/file/\w+' - __version__ = "0.21" + __description__ = """Rapidgator.net hoster plugin""" - __author_name__ = ("zoidberg", "chrox", "stickell", "Walter Purcaro") - __author_mail__ = ("zoidberg@mujmail.cz", "", "l.stickell@yahoo.it", "vuolter@gmail.com") + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("chrox", None), + ("stickell", "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com")] - API_URL = 'http://rapidgator.net/api/file' - FILE_NAME_PATTERN = r'<title>Download file (?P<N>.*)</title>' - FILE_SIZE_PATTERN = r'File size:\s*<strong>(?P<S>[\d\.]+) (?P<U>\w+)</strong>' - FILE_OFFLINE_PATTERN = r'>(File not found|Error 404)' + API_URL = "http://rapidgator.net/api/file" - JSVARS_PATTERN = r"\s+var\s*(startTimerUrl|getDownloadUrl|captchaUrl|fid|secs)\s*=\s*'?(.*?)'?;" + COOKIES = [("rapidgator.net", "lang", "en")] + + NAME_PATTERN = r'<title>Download file (?P<N>.*)</title>' + SIZE_PATTERN = r'File size:\s*<strong>(?P<S>[\d.,]+) (?P<U>[\w^_]+)</strong>' + OFFLINE_PATTERN = r'>(File not found|Error 404)' + + JSVARS_PATTERN = r'\s+var\s*(startTimerUrl|getDownloadUrl|captchaUrl|fid|secs)\s*=\s*\'?(.*?)\'?;' PREMIUM_ONLY_ERROR_PATTERN = r'You can download files up to|This file can be downloaded by premium only<' DOWNLOAD_LIMIT_ERROR_PATTERN = r'You have reached your (daily|hourly) downloads limit' WAIT_PATTERN = r'(?:Delay between downloads must be not less than|Try again in)\s*(\d+)\s*(hour|min)' - DOWNLOAD_LINK_PATTERN = r"return '(http://\w+.rapidgator.net/.*)';" + LINK_PATTERN = r'return \'(http://\w+.rapidgator.net/.*)\';' - RECAPTCHA_KEY_PATTERN = r'"http://api\.recaptcha\.net/challenge\?k=(.*?)"' - ADSCAPTCHA_SRC_PATTERN = r'(http://api\.adscaptcha\.com/Get\.aspx[^"\']*)' + RECAPTCHA_PATTERN = r'"http://api\.recaptcha\.net/challenge\?k=(.*?)"' + ADSCAPTCHA_PATTERN = r'(http://api\.adscaptcha\.com/Get\.aspx[^"\']*)' SOLVEMEDIA_PATTERN = r'http://api\.solvemedia\.com/papi/challenge\.script\?k=(.*?)"' - def setup(self): - self.resumeDownload = self.multiDL = self.premium - self.sid = None - self.chunkLimit = 1 - self.req.setOption("timeout", 120) - def process(self, pyfile): + def setup(self): if self.account: self.sid = self.account.getAccountData(self.user).get('SID', None) + else: + self.sid = None if self.sid: - self.handlePremium() - else: - self.handleFree() + self.premium = True + + self.resumeDownload = self.multiDL = self.premium + self.chunkLimit = 1 + def api_response(self, cmd): try: json = self.load('%s/%s' % (self.API_URL, cmd), get={'sid': self.sid, 'url': self.pyfile.url}, decode=True) - self.logDebug('API:%s' % cmd, json, "SID: %s" % self.sid) + self.logDebug("API:%s" % cmd, json, "SID: %s" % self.sid) json = json_loads(json) status = json['response_status'] msg = json['response_details'] + except BadHeader, e: - self.logError('API:%s' % cmd, e, "SID: %s" % self.sid) + self.logError("API: %s" % cmd, e, "SID: %s" % self.sid) status = e.code msg = e if status == 200: return json['response'] + elif status == 423: self.account.empty(self.user) self.retry() + else: self.account.relogin(self.user) self.retry(wait_time=60) + def handlePremium(self): #self.logDebug("ACCOUNT_DATA", self.account.getAccountData(self.user)) self.api_data = self.api_response('info') @@ -97,9 +93,8 @@ class RapidgatorNet(SimpleHoster): url = self.api_response('download')['url'] self.download(url) - def handleFree(self): - self.html = self.load(self.pyfile.url, decode=True) + def handleFree(self): self.checkFree() jsvars = dict(re.findall(self.JSVARS_PATTERN, self.html)) @@ -109,13 +104,13 @@ class RapidgatorNet(SimpleHoster): self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) url = "http://rapidgator.net%s?fid=%s" % ( - jsvars.get('startTimerUrl', '/download/AjaxStartTimer'), jsvars["fid"]) + jsvars.get('startTimerUrl', '/download/AjaxStartTimer'), jsvars['fid']) jsvars.update(self.getJsonResponse(url)) - self.wait(int(jsvars.get('secs', 45)) + 1, False) + self.wait(int(jsvars.get('secs', 45)), False) url = "http://rapidgator.net%s?sid=%s" % ( - jsvars.get('getDownloadUrl', '/download/AjaxGetDownload'), jsvars["sid"]) + jsvars.get('getDownloadUrl', '/download/AjaxGetDownload'), jsvars['sid']) jsvars.update(self.getJsonResponse(url)) self.req.http.lastURL = self.pyfile.url @@ -124,78 +119,80 @@ class RapidgatorNet(SimpleHoster): url = "http://rapidgator.net%s" % jsvars.get('captchaUrl', '/download/captcha') self.html = self.load(url) - for _ in xrange(5): - found = re.search(self.DOWNLOAD_LINK_PATTERN, self.html) - if found: - link = found.group(1) + for _i in xrange(5): + m = re.search(self.LINK_PATTERN, self.html) + if m: + link = m.group(1) self.logDebug(link) self.download(link, disposition=True) break else: captcha, captcha_key = self.getCaptcha() - captcha_challenge, captcha_response = captcha.challenge(captcha_key) + challenge, response = captcha.challenge(captcha_key) - self.html = self.load(url, post={ - "DownloadCaptchaForm[captcha]": "", - "adcopy_challenge": captcha_challenge, - "adcopy_response": captcha_response - }) + self.html = self.load(url, post={'DownloadCaptchaForm[captcha]': "", + 'adcopy_challenge' : challenge, + 'adcopy_response' : response}) if "The verification code is incorrect" in self.html: self.invalidCaptcha() else: self.correctCaptcha() else: - self.parseError("Download link") + self.error(_("Download link")) + def getCaptcha(self): - found = re.search(self.ADSCAPTCHA_SRC_PATTERN, self.html) - if found: - captcha_key = found.group(1) + m = re.search(self.ADSCAPTCHA_PATTERN, self.html) + if m: + captcha_key = m.group(1) captcha = AdsCaptcha(self) else: - found = re.search(self.RECAPTCHA_KEY_PATTERN, self.html) - if found: - captcha_key = found.group(1) + m = re.search(self.RECAPTCHA_PATTERN, self.html) + if m: + captcha_key = m.group(1) captcha = ReCaptcha(self) else: - found = re.search(self.SOLVEMEDIA_PATTERN, self.html) - if found: - captcha_key = found.group(1) + m = re.search(self.SOLVEMEDIA_PATTERN, self.html) + if m: + captcha_key = m.group(1) captcha = SolveMedia(self) else: - self.parseError("Captcha") + self.error(_("Captcha")) return captcha, captcha_key + def checkFree(self): - found = re.search(self.PREMIUM_ONLY_ERROR_PATTERN, self.html) - if found: - self.fail("Premium account needed for download") + m = re.search(self.PREMIUM_ONLY_ERROR_PATTERN, self.html) + if m: + self.fail(_("Premium account needed for download")) else: - found = re.search(self.WAIT_PATTERN, self.html) + m = re.search(self.WAIT_PATTERN, self.html) - if found: - wait_time = int(found.group(1)) * {"hour": 60, "min": 1}[found.group(2)] + if m: + wait_time = int(m.group(1)) * {"hour": 60, "min": 1}[m.group(2)] else: - found = re.search(self.DOWNLOAD_LIMIT_ERROR_PATTERN, self.html) - if not found: + m = re.search(self.DOWNLOAD_LIMIT_ERROR_PATTERN, self.html) + if m is None: return - elif found.group(1) == "daily": - wait_time = 60 + elif m.group(1) == "daily": + self.logWarning(_("You have reached your daily downloads limit for today")) + wait_time = secondsToMidnight(gmt=2) else: - wait_time = 24 * 60 + wait_time = 1 * 60 * 60 - self.logDebug("Waiting %d minutes" % wait_time) - self.wait(wait_time * 60, True) + self.logDebug("Waiting %d minutes" % wait_time / 60) + self.wait(wait_time, True) self.retry() + def getJsonResponse(self, url): - response = self.load(url, decode=True) - if not response.startswith('{'): + res = self.load(url, decode=True) + if not res.startswith('{'): self.retry() - self.logDebug(url, response) - return json_loads(response) + self.logDebug(url, res) + return json_loads(res) getInfo = create_getInfo(RapidgatorNet) diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py deleted file mode 100644 index e5ab6b445..000000000 --- a/module/plugins/hoster/RapidshareCom.py +++ /dev/null @@ -1,228 +0,0 @@ -# -*- coding: utf-8 -*- - -# v1.36 -# * fixed call checkfiles subroutine -# v1.35 -# * fixed rs-urls in handleFree(..) and freeWait(..) -# * removed getInfo(..) function as it was not used anywhere (in this file) -# * removed some (old?) comment blocks - -import re - -from module.network.RequestFactory import getURL -from module.plugins.Hoster import Hoster - - -def getInfo(urls): - ids = "" - names = "" - - p = re.compile(RapidshareCom.__pattern__) - - for url in urls: - r = p.search(url) - if r.group("name"): - ids += "," + r.group("id") - names += "," + r.group("name") - elif r.group("name_new"): - ids += "," + r.group("id_new") - names += "," + r.group("name_new") - - url = "http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles&files=%s&filenames=%s" % (ids[1:], names[1:]) - - api = getURL(url) - result = [] - i = 0 - for res in api.split(): - tmp = res.split(",") - if tmp[4] in ("0", "4", "5"): - status = 1 - elif tmp[4] == "1": - status = 2 - else: - status = 3 - - result.append((tmp[1], tmp[2], status, urls[i])) - i += 1 - - yield result - - -class RapidshareCom(Hoster): - __name__ = "RapidshareCom" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?rapidshare.com/(?:files/(?P<id>\d*?)/(?P<name>[^?]+)|#!download\|(?:\w+)\|(?P<id_new>\d+)\|(?P<name_new>[^|]+))' - __version__ = "1.39" - __description__ = """Rapidshare.com hoster plugin""" - __config__ = [("server", - "Cogent;Deutsche Telekom;Level(3);Level(3) #2;GlobalCrossing;Level(3) #3;Teleglobe;GlobalCrossing #2;TeliaSonera #2;Teleglobe #2;TeliaSonera #3;TeliaSonera", - "Preferred Server", "None")] - __author_name__ = ("spoob", "RaNaN", "mkaay") - __author_mail__ = ("spoob@pyload.org", "ranan@pyload.org", "mkaay@mkaay.de") - - def setup(self): - self.no_download = True - self.api_data = None - self.offset = 0 - self.dl_dict = {} - - self.id = None - self.name = None - - self.chunkLimit = -1 if self.premium else 1 - self.multiDL = self.resumeDownload = self.premium - - def process(self, pyfile): - self.url = pyfile.url - self.prepare() - - def prepare(self): - m = re.match(self.__pattern__, self.url) - - if m.group("name"): - self.id = m.group("id") - self.name = m.group("name") - else: - self.id = m.group("id_new") - self.name = m.group("name_new") - - self.download_api_data() - if self.api_data["status"] == "1": - self.pyfile.name = self.get_file_name() - - if self.premium: - self.handlePremium() - else: - self.handleFree() - - elif self.api_data["status"] == "2": - self.logInfo(_("Rapidshare: Traffic Share (direct download)")) - self.pyfile.name = self.get_file_name() - - self.download(self.pyfile.url, get={"directstart": 1}) - - elif self.api_data["status"] in ("0", "4", "5"): - self.offline() - elif self.api_data["status"] == "3": - self.tempOffline() - else: - self.fail("Unknown response code.") - - def handleFree(self): - - while self.no_download: - self.dl_dict = self.freeWait() - - #tmp = "#!download|%(server)s|%(id)s|%(name)s|%(size)s" - download = "http://%(host)s/cgi-bin/rsapi.cgi?sub=download&editparentlocation=0&bin=1&fileid=%(id)s&filename=%(name)s&dlauth=%(auth)s" % self.dl_dict - - self.logDebug("RS API Request: %s" % download) - self.download(download, ref=False) - - check = self.checkDownload({"ip": "You need RapidPro to download more files from your IP address", - "auth": "Download auth invalid"}) - if check == "ip": - self.setWait(60) - self.logInfo(_("Already downloading from this ip address, waiting 60 seconds")) - self.wait() - self.handleFree() - elif check == "auth": - self.logInfo(_("Invalid Auth Code, download will be restarted")) - self.offset += 5 - self.handleFree() - - def handlePremium(self): - info = self.account.getAccountInfo(self.user, True) - self.logDebug("%s: Use Premium Account" % self.__name__) - url = self.api_data["mirror"] - self.download(url, get={"directstart": 1}) - - def download_api_data(self, force=False): - """ - http://images.rapidshare.com/apidoc.txt - """ - if self.api_data and not force: - return - api_url_base = "http://api.rapidshare.com/cgi-bin/rsapi.cgi" - api_param_file = {"sub": "checkfiles", "incmd5": "1", "files": self.id, "filenames": self.name} - src = self.load(api_url_base, cookies=False, get=api_param_file).strip() - self.logDebug("RS INFO API: %s" % src) - if src.startswith("ERROR"): - return - fields = src.split(",") - - # status codes: - # 0=File not found - # 1=File OK (Anonymous downloading) - # 3=Server down - # 4=File marked as illegal - # 5=Anonymous file locked, because it has more than 10 downloads already - # 50+n=File OK (TrafficShare direct download type "n" without any logging.) - # 100+n=File OK (TrafficShare direct download type "n" with logging. - # Read our privacy policy to see what is logged.) - - self.api_data = {"fileid": fields[0], "filename": fields[1], "size": int(fields[2]), "serverid": fields[3], - "status": fields[4], "shorthost": fields[5], "checksum": fields[6].strip().lower()} - - if int(self.api_data["status"]) > 100: - self.api_data["status"] = str(int(self.api_data["status"]) - 100) - elif int(self.api_data["status"]) > 50: - self.api_data["status"] = str(int(self.api_data["status"]) - 50) - - self.api_data["mirror"] = "http://rs%(serverid)s%(shorthost)s.rapidshare.com/files/%(fileid)s/%(filename)s" % self.api_data - - def freeWait(self): - """downloads html with the important information - """ - self.no_download = True - - id = self.id - name = self.name - - prepare = "https://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&fileid=%(id)s&filename=%(name)s&try=1&cbf=RSAPIDispatcher&cbid=1" % { - "name": name, "id": id} - - self.logDebug("RS API Request: %s" % prepare) - result = self.load(prepare, ref=False) - self.logDebug("RS API Result: %s" % result) - - between_wait = re.search("You need to wait (\d+) seconds", result) - - if "You need RapidPro to download more files from your IP address" in result: - self.setWait(60) - self.logInfo(_("Already downloading from this ip address, waiting 60 seconds")) - self.wait() - elif ("Too many users downloading from this server right now" in result or - "All free download slots are full" in result): - self.setWait(120) - self.logInfo(_("RapidShareCom: No free slots")) - self.wait() - elif "This file is too big to download it for free" in result: - self.fail(_("You need a premium account for this file")) - elif "Filename invalid." in result: - self.fail(_("Filename reported invalid")) - elif between_wait: - self.setWait(int(between_wait.group(1))) - self.wantReconnect = True - self.wait() - else: - self.no_download = False - - tmp, info = result.split(":") - data = info.split(",") - - dl_dict = {"id": id, - "name": name, - "host": data[0], - "auth": data[1], - "server": self.api_data["serverid"], - "size": self.api_data["size"]} - self.setWait(int(data[2]) + 2 + self.offset) - self.wait() - - return dl_dict - - def get_file_name(self): - if self.api_data["filename"]: - return self.api_data["filename"] - return self.url.split("/")[-1] diff --git a/module/plugins/hoster/RapiduNet.py b/module/plugins/hoster/RapiduNet.py new file mode 100644 index 000000000..a3b2cffcd --- /dev/null +++ b/module/plugins/hoster/RapiduNet.py @@ -0,0 +1,82 @@ +# -*- coding: utf-8 -*- + +import re + +from pycurl import HTTPHEADER +from time import time, altzone + +from module.common.json_layer import json_loads +from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + + +class RapiduNet(SimpleHoster): + __name__ = "RapiduNet" + __type__ = "hoster" + __version__ = "0.02" + + __pattern__ = r'https?://(?:www\.)?rapidu\.net/(?P<ID>\d{10})' + + __description__ = """Rapidu.net hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("prOq", None)] + + + COOKIES = [("rapidu.net", "rapidu_lang", "en")] + + FILE_INFO_PATTERN = r'<h1 title="(?P<N>.*)">.*</h1>\s*<small>(?P<S>\d+(\.\d+)?)\s(?P<U>\w+)</small>' + OFFLINE_PATTERN = r'404 - File not found' + + ERROR_PATTERN = r'<div class="error">' + + RECAPTCHA_KEY = r'6Ld12ewSAAAAAHoE6WVP_pSfCdJcBQScVweQh8Io' + + + def setup(self): + self.resumeDownload = True + self.multiDL = True + self.limitDL = 0 if self.premium else 2 + + + def handleFree(self): + self.req.http.lastURL = self.pyfile.url + self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) + + jsvars = self.getJsonResponse("https://rapidu.net/ajax.php?a=getLoadTimeToDownload", {'_go': None}) + + if str(jsvars['timeToDownload']) is "stop": + t = (24 * 60 * 60) - (int(time()) % (24 *60 * 60)) + altzone + + self.logInfo("You've reach your daily download transfer") + + self.retry(10, 10 if t < 1 else None, "Try tomorrow again") #@NOTE: check t in case of not synchronised clock + + else: + self.wait(int(jsvars['timeToDownload']) - int(time())) + + recaptcha = ReCaptcha(self) + + for _i in xrange(10): + challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY) + + jsvars = self.getJsonResponse("https://rapidu.net/ajax.php?a=getCheckCaptcha", + {'_go' : None, + 'captcha1': challenge, + 'captcha2': response, + 'fileId' : self.info['ID']}) + if jsvars['message'] == 'success': + self.download(jsvars['url']) + break + + + def getJsonResponse(self, url, post_data): + res = self.load(url, post=post_data, decode=True) + if not res.startswith('{'): + self.retry() + + self.logDebug(url, res) + + return json_loads(res) + + +getInfo = create_getInfo(RapiduNet) diff --git a/module/plugins/hoster/RarefileNet.py b/module/plugins/hoster/RarefileNet.py index 8f2aacbcf..2be952efe 100644 --- a/module/plugins/hoster/RarefileNet.py +++ b/module/plugins/hoster/RarefileNet.py @@ -2,35 +2,24 @@ import re -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo -from module.utils import html_unescape +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo -class RarefileNet(XFileSharingPro): - __name__ = "RarefileNet" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?rarefile.net/\w{12}' - __version__ = "0.03" - __description__ = """Rarefile.net hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" +class RarefileNet(XFSHoster): + __name__ = "RarefileNet" + __type__ = "hoster" + __version__ = "0.09" + + __pattern__ = r'http://(?:www\.)?rarefile\.net/\w{12}' - HOSTER_NAME = "rarefile.net" + __description__ = """Rarefile.net hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - FILE_NAME_PATTERN = r'<td><font color="red">(?P<N>.*?)</font></td>' - FILE_SIZE_PATTERN = r'<td>Size : (?P<S>.+?) ' - DIRECT_LINK_PATTERN = r'<a href="(?P<link>[^"]+)">(?P=link)</a>' - def setup(self): - self.resumeDownload = self.multiDL = self.premium + HOSTER_DOMAIN = "rarefile.net" - def handleCaptcha(self, inputs): - captcha_div = re.search(r'<b>Enter code.*?<div.*?>(.*?)</div>', self.html, re.S).group(1) - self.logDebug(captcha_div) - numerals = re.findall('<span.*?padding-left\s*:\s*(\d+).*?>(\d)</span>', html_unescape(captcha_div)) - inputs['code'] = "".join([a[1] for a in sorted(numerals, key=lambda num: int(num[0]))]) - self.logDebug("CAPTCHA", inputs['code'], numerals) - return 3 + LINK_PATTERN = r'<a href="(.+?)">\1</a>' getInfo = create_getInfo(RarefileNet) diff --git a/module/plugins/hoster/RealdebridCom.py b/module/plugins/hoster/RealdebridCom.py index 36fcd194c..0332ae9da 100644 --- a/module/plugins/hoster/RealdebridCom.py +++ b/module/plugins/hoster/RealdebridCom.py @@ -1,88 +1,86 @@ # -*- coding: utf-8 -*- import re -from time import time -from urllib import quote, unquote + from random import randrange +from urllib import quote, unquote +from time import time -from module.utils import parseFileSize from module.common.json_layer import json_loads -from module.plugins.Hoster import Hoster +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo +from module.utils import parseFileSize + +class RealdebridCom(MultiHoster): + __name__ = "RealdebridCom" + __type__ = "hoster" + __version__ = "0.62" -class RealdebridCom(Hoster): - __name__ = "RealdebridCom" - __version__ = "0.53" - __type__ = "hoster" + __pattern__ = r'https?://((?:www\.|s\d+\.)?real-debrid\.com/dl/|[\w^_]\.rdb\.so/d/)[\w^_]+' - __pattern__ = r'https?://(?:[^/]*\.)?real-debrid\..*' __description__ = """Real-Debrid.com hoster plugin""" - __author_name__ = "Devirex Hazzard" - __author_mail__ = "naibaf_11@yahoo.de" + __license__ = "GPLv3" + __authors__ = [("Devirex Hazzard", "naibaf_11@yahoo.de")] + def getFilename(self, url): try: name = unquote(url.rsplit("/", 1)[1]) except IndexError: name = "Unknown_Filename..." - if not name or name.endswith(".."): # incomplete filename, append random stuff + if not name or name.endswith(".."): #: incomplete filename, append random stuff name += "%s.tmp" % randrange(100, 999) return name + def setup(self): - self.chunkLimit = 3 + self.chunkLimit = 3 self.resumeDownload = True - def process(self, pyfile): - if re.match(self.__pattern__, pyfile.url): - new_url = pyfile.url - elif not self.account: - self.logError(_("Please enter your %s account or deactivate this plugin") % "Real-debrid") - self.fail("No Real-debrid account provided") - else: - self.logDebug("Old URL: %s" % pyfile.url) - password = self.getPassword().splitlines() - if not password: - password = "" - else: - password = password[0] - url = "https://real-debrid.com/ajax/unrestrict.php?lang=en&link=%s&password=%s&time=%s" % ( - quote(pyfile.url, ""), password, int(time() * 1000)) - page = self.load(url) - data = json_loads(page) + def handlePremium(self): + data = json_loads(self.load("https://real-debrid.com/ajax/unrestrict.php", + get={'lang' : "en", + 'link' : self.pyfile.url, + 'password': self.getPassword(), + 'time' : int(time() * 1000)})) - self.logDebug("Returned Data: %s" % data) + self.logDebug("Returned Data: %s" % data) - if data["error"] != 0: - if data["message"] == "Your file is unavailable on the hoster.": - self.offline() - else: - self.logWarning(data["message"]) - self.tempOffline() + if data['error'] != 0: + if data['message'] == "Your file is unavailable on the hoster.": + self.offline() else: - if pyfile.name is not None and pyfile.name.endswith('.tmp') and data["file_name"]: - pyfile.name = data["file_name"] - pyfile.size = parseFileSize(data["file_size"]) - new_url = data['generated_links'][0][-1] + self.logWarning(data['message']) + self.tempOffline() + else: + if self.pyfile.name is not None and self.pyfile.name.endswith('.tmp') and data['file_name']: + self.pyfile.name = data['file_name'] + self.pyfile.size = parseFileSize(data['file_size']) + self.link = data['generated_links'][0][-1] if self.getConfig("https"): - new_url = new_url.replace("http://", "https://") + self.link = self.link.replace("http://", "https://") else: - new_url = new_url.replace("https://", "http://") + self.link = self.link.replace("https://", "http://") - if new_url != pyfile.url: - self.logDebug("New URL: %s" % new_url) + if self.link != self.pyfile.url: + self.logDebug("New URL: %s" % self.link) - if pyfile.name.startswith("http") or pyfile.name.startswith("Unknown") or pyfile.name.endswith('..'): + if self.pyfile.name.startswith("http") or self.pyfile.name.startswith("Unknown") or self.pyfile.name.endswith('..'): #only use when name wasnt already set - pyfile.name = self.getFilename(new_url) + self.pyfile.name = self.getFilename(self.link) + - self.download(new_url, disposition=True) + def checkFile(self): + super(RealdebridCom, self).checkFile() check = self.checkDownload( {"error": "<title>An error occured while processing your request</title>"}) if check == "error": #usual this download can safely be retried - self.retry(wait_time=60, reason="An error occured while generating link.") + self.retry(wait_time=60, reason=_("An error occured while generating link")) + + +getInfo = create_getInfo(RealdebridCom) diff --git a/module/plugins/hoster/RedtubeCom.py b/module/plugins/hoster/RedtubeCom.py index a2bbf3883..d68fbe262 100644 --- a/module/plugins/hoster/RedtubeCom.py +++ b/module/plugins/hoster/RedtubeCom.py @@ -1,18 +1,22 @@ # -*- coding: utf-8 -*- import re + from module.plugins.Hoster import Hoster from module.unescape import unescape class RedtubeCom(Hoster): - __name__ = "RedtubeCom" - __type__ = "hoster" + __name__ = "RedtubeCom" + __type__ = "hoster" + __version__ = "0.20" + __pattern__ = r'http://(?:www\.)?redtube\.com/\d+' - __version__ = "0.2" + __description__ = """Redtube.com hoster plugin""" - __author_name__ = "jeix" - __author_mail__ = "jeix@hasnomail.de" + __license__ = "GPLv3" + __authors__ = [("jeix", "jeix@hasnomail.de")] + def process(self, pyfile): self.download_html() @@ -22,31 +26,34 @@ class RedtubeCom(Hoster): pyfile.name = self.get_file_name() self.download(self.get_file_url()) + def download_html(self): url = self.pyfile.url self.html = self.load(url) + def get_file_url(self): """ returns the absolute downloadable filepath """ - if self.html is None: + if not self.html: self.download_html() file_url = unescape(re.search(r'hashlink=(http.*?)"', self.html).group(1)) return file_url + def get_file_name(self): - if self.html is None: + if not self.html: self.download_html() - name = re.search('<title>(.*?)- RedTube - Free Porn Videos</title>', self.html).group(1).strip() + ".flv" - return name + return re.search('<title>(.*?)- RedTube - Free Porn Videos</title>', self.html).group(1).strip() + ".flv" + def file_exists(self): """ returns True or False """ - if self.html is None: + if not self.html: self.download_html() if re.search(r'This video has been removed.', self.html) is not None: diff --git a/module/plugins/hoster/RehostTo.py b/module/plugins/hoster/RehostTo.py index 94e53520a..2971a6781 100644 --- a/module/plugins/hoster/RehostTo.py +++ b/module/plugins/hoster/RehostTo.py @@ -1,37 +1,42 @@ # -*- coding: utf-8 -*- from urllib import quote, unquote -from module.plugins.Hoster import Hoster +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo + + +class RehostTo(MultiHoster): + __name__ = "RehostTo" + __type__ = "hoster" + __version__ = "0.16" + + __pattern__ = r'https?://.*rehost\.to\..+' -class RehostTo(Hoster): - __name__ = "RehostTo" - __version__ = "0.13" - __type__ = "hoster" - __pattern__ = r'https?://.*rehost.to\..*' __description__ = """Rehost.com hoster plugin""" - __author_name__ = "RaNaN" - __author_mail__ = "RaNaN@pyload.org" + __license__ = "GPLv3" + __authors__ = [("RaNaN", "RaNaN@pyload.org")] + def getFilename(self, url): return unquote(url.rsplit("/", 1)[1]) + def setup(self): - self.chunkLimit = 1 + self.chunkLimit = 1 self.resumeDownload = True - def process(self, pyfile): - if not self.account: - self.logError(_("Please enter your %s account or deactivate this plugin") % "rehost.to") - self.fail("No rehost.to account provided") + def handlePremium(self): data = self.account.getAccountInfo(self.user) - long_ses = data["long_ses"] - - self.logDebug("Rehost.to: Old URL: %s" % pyfile.url) - new_url = "http://rehost.to/process_download.php?user=cookie&pass=%s&dl=%s" % (long_ses, quote(pyfile.url, "")) + long_ses = data['long_ses'] #raise timeout to 2min self.req.setOption("timeout", 120) - self.download(new_url, disposition=True) + self.link = True + self.download("http://rehost.to/process_download.php", + get={'user': "cookie", 'pass': long_ses, 'dl': quote(self.pyfile.url, "")}, + disposition=True) + + +getInfo = create_getInfo(RehostTo) diff --git a/module/plugins/hoster/ReloadCc.py b/module/plugins/hoster/ReloadCc.py deleted file mode 100644 index ed1b21aa3..000000000 --- a/module/plugins/hoster/ReloadCc.py +++ /dev/null @@ -1,115 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.plugins.Hoster import Hoster - -from module.common.json_layer import json_loads - -from module.network.HTTPRequest import BadHeader - - -class ReloadCc(Hoster): - __name__ = "ReloadCc" - __version__ = "0.5" - __type__ = "hoster" - __description__ = """Reload.cc hoster plugin""" - - # Since we want to allow the user to specify the list of hoster to use we let MultiHoster.coreReady - # create the regex patterns for us using getHosters in our ReloadCc hook. - __pattern__ = None - - __author_name__ = "Reload Team" - __author_mail__ = "hello@reload.cc" - - def process(self, pyfile): - # Check account - if not self.account or not self.account.canUse(): - self.logError(_("Please enter your %s account or deactivate this plugin") % "reload.cc") - self.fail("No valid reload.cc account provided") - - # In some cases hostsers do not supply us with a filename at download, so we - # are going to set a fall back filename (e.g. for freakshare or xfileshare) - pyfile.name = pyfile.name.split('/').pop() # Remove everthing before last slash - - # Correction for automatic assigned filename: Removing html at end if needed - suffix_to_remove = ["html", "htm", "php", "php3", "asp", "shtm", "shtml", "cfml", "cfm"] - temp = pyfile.name.split('.') - if temp.pop() in suffix_to_remove: - pyfile.name = ".".join(temp) - - # Get account data - (user, data) = self.account.selectAccount() - - query_params = dict( - via='pyload', - v=1, - user=user, - uri=pyfile.url - ) - - try: - query_params.update(dict(hash=self.account.infos[user]['pwdhash'])) - except Exception: - query_params.update(dict(pwd=data['password'])) - - try: - answer = self.load("http://api.reload.cc/dl", get=query_params) - except BadHeader, e: - if e.code == 400: - self.fail("The URI is not supported by Reload.cc.") - elif e.code == 401: - self.fail("Wrong username or password") - elif e.code == 402: - self.fail("Your account is inactive. A payment is required for downloading!") - elif e.code == 403: - self.fail("Your account is disabled. Please contact the Reload.cc support!") - elif e.code == 409: - self.logWarning("The hoster seems to be a limited hoster and you've used your daily traffic for this hoster: %s" % pyfile.url) - # Wait for 6 hours and retry up to 4 times => one day - self.retry(4, 6 * 60 * 60, "Limited hoster traffic limit exceeded") - elif e.code == 429: - # Too many connections, wait 2 minutes and try again - self.retry(5, 2 * 60, "Too many concurrent connections") - elif e.code == 503: - # Retry in 10 minutes - self.retry(wait_time=10 * 60, - reason="Reload.cc is currently in maintenance mode! Please check again later.") - else: - self.fail( - "Internal error within Reload.cc. Please contact the Reload.cc support for further information.") - return - - data = json_loads(answer) - - # Check status and decide what to do - status = data.get('status', None) - if status == "ok": - conn_limit = data.get('msg', 0) - # API says these connections are limited - # Make sure this limit is used - the download will fail if not - if conn_limit > 0: - try: - self.limitDL = int(conn_limit) - except ValueError: - self.limitDL = 1 - else: - self.limitDL = 0 - - try: - self.download(data['link'], disposition=True) - except BadHeader, e: - if e.code == 404: - self.fail("File Not Found") - elif e.code == 412: - self.fail("File access password is wrong") - elif e.code == 417: - self.fail("Password required for file access") - elif e.code == 429: - # Too many connections, wait 2 minutes and try again - self.retry(5, 2 * 60, "Too many concurrent connections") - else: - self.fail( - "Internal error within Reload.cc. Please contact the Reload.cc support for further information." - ) - return - else: - self.fail("Internal error within Reload.cc. Please contact the Reload.cc support for further information.") diff --git a/module/plugins/hoster/RemixshareCom.py b/module/plugins/hoster/RemixshareCom.py new file mode 100644 index 000000000..ed171895e --- /dev/null +++ b/module/plugins/hoster/RemixshareCom.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# +# Test links: +# http://remixshare.com/download/p946u +# +# Note: +# The remixshare.com website is very very slow, so +# if your download not starts because of pycurl timeouts: +# Adjust timeouts in /usr/share/pyload/module/network/HTTPRequest.py + +import re + +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + + +class RemixshareCom(SimpleHoster): + __name__ = "RemixshareCom" + __type__ = "hoster" + __version__ = "0.02" + + __pattern__ = r'https?://remixshare\.com/(download|dl)/\w+' + + __description__ = """Remixshare.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zapp-brannigan", "fuerst.reinje@web.de"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + INFO_PATTERN = r'title=\'.+?\'>(?P<N>.+?)</span><span class=\'light2\'> \((?P<S>\d+) (?P<U>[\w^_]+)\)<' + OFFLINE_PATTERN = r'<h1>Ooops!<' + + LINK_PATTERN = r'(http://remixshare\.com/downloadfinal/.+?)"' + TOKEN_PATTERN = r'var acc = (\d+)' + WAIT_PATTERN = r'var XYZ = r"(\d+)"' + + + def setup(self): + self.multiDL = True + self.chunkLimit = 1 + + + def handleFree(self): + b = re.search(self.LINK_PATTERN, self.html) + if not b: + self.error(_("Cannot parse download url")) + c = re.search(self.TOKEN_PATTERN, self.html) + if not c: + self.error(_("Cannot parse file token")) + dl_url = b.group(1) + c.group(1) + + #Check if we have to wait + seconds = re.search(self.WAIT_PATTERN, self.html) + if seconds: + self.logDebug("Wait " + seconds.group(1)) + self.wait(int(seconds.group(1))) + + # Finally start downloading... + self.download(dl_url, disposition=True) + + +getInfo = create_getInfo(RemixshareCom) diff --git a/module/plugins/hoster/RgHostNet.py b/module/plugins/hoster/RgHostNet.py index 9e37ed87b..aa4830563 100644 --- a/module/plugins/hoster/RgHostNet.py +++ b/module/plugins/hoster/RgHostNet.py @@ -1,27 +1,26 @@ # -*- coding: utf-8 -*- import re + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class RgHostNet(SimpleHoster): - __name__ = "RgHostNet" - __type__ = "hoster" + __name__ = "RgHostNet" + __type__ = "hoster" + __version__ = "0.03" + __pattern__ = r'http://(?:www\.)?rghost\.net/\d+(?:r=\d+)?' - __version__ = "0.01" + __description__ = """RgHost.net hoster plugin""" - __author_name__ = "z00nx" - __author_mail__ = "z00nx0@gmail.com" - - FILE_INFO_PATTERN = r'<h1>\s+(<a[^>]+>)?(?P<N>[^<]+)(</a>)?\s+<small[^>]+>\s+\((?P<S>[^)]+)\)\s+</small>\s+</h1>' - FILE_OFFLINE_PATTERN = r'File is deleted|this page is not found' - DOWNLOAD_LINK_PATTERN = '''<a\s+href="([^"]+)"\s+class="btn\s+large\s+download"[^>]+>Download</a>''' - - def handleFree(self): - found = re.search(self.DOWNLOAD_LINK_PATTERN, self.html) - if not found: - self.parseError("Unable to detect the direct link") - download_link = found.group(1) - self.download(download_link, disposition=True) + __license__ = "GPLv3" + __authors__ = [("z00nx", "z00nx0@gmail.com")] + + + INFO_PATTERN = r'<h1>\s+(<a[^>]+>)?(?P<N>[^<]+)(</a>)?\s+<small[^>]+>\s+\((?P<S>[^)]+)\)\s+</small>\s+</h1>' + OFFLINE_PATTERN = r'File is deleted|this page is not found' + + LINK_FREE_PATTERN = r'<a\s+href="([^"]+)"\s+class="btn\s+large\s+download"[^>]+>Download</a>' + getInfo = create_getInfo(RgHostNet) diff --git a/module/plugins/hoster/RyushareCom.py b/module/plugins/hoster/RyushareCom.py index 4d3e9b7f3..0964c51fc 100644 --- a/module/plugins/hoster/RyushareCom.py +++ b/module/plugins/hoster/RyushareCom.py @@ -1,37 +1,41 @@ # -*- coding: utf-8 -*- - -# Test links (random.bin): +# +# Test links: # http://ryushare.com/cl0jy8ric2js/random.bin import re -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo from module.plugins.internal.CaptchaService import SolveMedia -class RyushareCom(XFileSharingPro): - __name__ = "RyushareCom" - __type__ = "hoster" +class RyushareCom(XFSHoster): + __name__ = "RyushareCom" + __type__ = "hoster" + __version__ = "0.20" + __pattern__ = r'http://(?:www\.)?ryushare\.com/\w+' - __version__ = "0.15" + __description__ = """Ryushare.com hoster plugin""" - __author_name__ = ("zoidberg", "stickell", "quareevo") - __author_mail__ = ("zoidberg@mujmail.cz", "l.stickell@yahoo.it", "quareevo@arcor.de") + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it"), + ("quareevo", "quareevo@arcor.de")] - HOSTER_NAME = "ryushare.com" - FILE_SIZE_PATTERN = r'You have requested <font color="red">[^<]+</font> \((?P<S>[\d\.]+) (?P<U>\w+)' + HOSTER_DOMAIN = "ryushare.com" + + WAIT_PATTERN = r'You have to wait ((?P<H>\d+) hour[s]?, )?((?P<M>\d+) minute[s], )?(?P<S>\d+) second[s]' + + LINK_PATTERN = r'<a href="([^"]+)">Click here to download<' - WAIT_PATTERN = r'You have to wait ((?P<hour>\d+) hour[s]?, )?((?P<min>\d+) minute[s], )?(?P<sec>\d+) second[s]' - DIRECT_LINK_PATTERN = r'(http://([^/]*?ryushare.com|\d+\.\d+\.\d+\.\d+)(:\d+/d/|/files/\w+/\w+/)[^"\'<]+)' - SOLVEMEDIA_PATTERN = r'http:\/\/api\.solvemedia\.com\/papi\/challenge\.script\?k=(.*?)"' def getDownloadLink(self): retry = False self.html = self.load(self.pyfile.url) action, inputs = self.parseHtmlForm(input_names={"op": re.compile("^download")}) if "method_premium" in inputs: - del inputs["method_premium"] + del inputs['method_premium'] self.html = self.load(self.pyfile.url, post=inputs) action, inputs = self.parseHtmlForm('F1') @@ -42,10 +46,10 @@ class RyushareCom(XFileSharingPro): self.setWait(1 * 60 * 60, True) retry = True - match = re.search(self.WAIT_PATTERN, self.html) - if match: - m = match.groupdict(0) - waittime = int(m["hour"]) * 60 * 60 + int(m["min"]) * 60 + int(m["sec"]) + m = re.search(self.WAIT_PATTERN, self.html) + if m: + wait = m.groupdict(0) + waittime = int(wait['H']) * 60 * 60 + int(wait['M']) * 60 + int(wait['S']) self.setWait(waittime, True) retry = True @@ -53,31 +57,24 @@ class RyushareCom(XFileSharingPro): if retry: self.retry() - for _ in xrange(5): - m = re.search(self.SOLVEMEDIA_PATTERN, self.html) - if not m: - self.parseError("Error parsing captcha") - - captchaKey = m.group(1) - captcha = SolveMedia(self) - challenge, response = captcha.challenge(captchaKey) + for _i in xrange(5): + solvemedia = SolveMedia(self) + challenge, response = solvemedia.challenge() - inputs["adcopy_challenge"] = challenge - inputs["adcopy_response"] = response + inputs['adcopy_challenge'] = challenge + inputs['adcopy_response'] = response self.html = self.load(self.pyfile.url, post=inputs) if "WRONG CAPTCHA" in self.html: self.invalidCaptcha() - self.logInfo("Invalid Captcha") else: self.correctCaptcha() break else: - self.fail("You have entered 5 invalid captcha codes") + self.fail(_("You have entered 5 invalid captcha codes")) if "Click here to download" in self.html: - m = re.search(r'<a href="([^"]+)">Click here to download</a>', self.html) - return m.group(1) + return re.search(r'<a href="([^"]+)">Click here to download</a>', self.html).group(1) getInfo = create_getInfo(RyushareCom) diff --git a/module/plugins/hoster/SafesharingEu.py b/module/plugins/hoster/SafesharingEu.py new file mode 100644 index 000000000..bb6e0f646 --- /dev/null +++ b/module/plugins/hoster/SafesharingEu.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo + + +class SafesharingEu(XFSHoster): + __name__ = "SafesharingEu" + __type__ = "hoster" + __version__ = "0.05" + + __pattern__ = r'https?://(?:www\.)?safesharing\.eu/\w{12}' + + __description__ = """Safesharing.eu hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zapp-brannigan", "fuerst.reinje@web.de")] + + + HOSTER_DOMAIN = "safesharing.eu" + + ERROR_PATTERN = r'(?:<div class="alert alert-danger">)(.+?)(?:</div>)' + + +getInfo = create_getInfo(SafesharingEu) diff --git a/module/plugins/hoster/SecureUploadEu.py b/module/plugins/hoster/SecureUploadEu.py index 1b11d691d..64e6456a9 100644 --- a/module/plugins/hoster/SecureUploadEu.py +++ b/module/plugins/hoster/SecureUploadEu.py @@ -1,21 +1,23 @@ # -*- coding: utf-8 -*- -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo -class SecureUploadEu(XFileSharingPro): - __name__ = "SecureUploadEu" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?secureupload\.eu/(\w){12}(/\w+)' - __version__ = "0.01" +class SecureUploadEu(XFSHoster): + __name__ = "SecureUploadEu" + __type__ = "hoster" + __version__ = "0.05" + + __pattern__ = r'https?://(?:www\.)?secureupload\.eu/\w{12}' + __description__ = """SecureUpload.eu hoster plugin""" - __author_name__ = "z00nx" - __author_mail__ = "z00nx0@gmail.com" + __license__ = "GPLv3" + __authors__ = [("z00nx", "z00nx0@gmail.com")] + - HOSTER_NAME = "secureupload.eu" + HOSTER_DOMAIN = "secureupload.eu" - FILE_INFO_PATTERN = '<h3>Downloading (?P<N>[^<]+) \((?P<S>[^<]+)\)</h3>' - FILE_OFFLINE_PATTERN = 'The file was removed|File Not Found' + INFO_PATTERN = r'<h3>Downloading (?P<N>[^<]+) \((?P<S>[^<]+)\)</h3>' getInfo = create_getInfo(SecureUploadEu) diff --git a/module/plugins/hoster/SendmywayCom.py b/module/plugins/hoster/SendmywayCom.py index 6de87e2b3..637098b88 100644 --- a/module/plugins/hoster/SendmywayCom.py +++ b/module/plugins/hoster/SendmywayCom.py @@ -1,21 +1,21 @@ # -*- coding: utf-8 -*- -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo -class SendmywayCom(XFileSharingPro): - __name__ = "SendmywayCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?sendmyway.com/\w{12}' - __version__ = "0.01" - __description__ = """SendMyWay hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" +class SendmywayCom(XFSHoster): + __name__ = "SendmywayCom" + __type__ = "hoster" + __version__ = "0.04" - HOSTER_NAME = "sendmyway.com" + __pattern__ = r'http://(?:www\.)?sendmyway\.com/\w{12}' - FILE_NAME_PATTERN = r'<p class="file-name" ><.*?>\s*(?P<N>.+)' - FILE_SIZE_PATTERN = r'<small>\((?P<S>\d+) bytes\)</small>' + __description__ = """SendMyWay.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + + HOSTER_DOMAIN = "sendmyway.com" getInfo = create_getInfo(SendmywayCom) diff --git a/module/plugins/hoster/SendspaceCom.py b/module/plugins/hoster/SendspaceCom.py index d6eafac0c..12f966e31 100644 --- a/module/plugins/hoster/SendspaceCom.py +++ b/module/plugins/hoster/SendspaceCom.py @@ -1,60 +1,50 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class SendspaceCom(SimpleHoster): - __name__ = "SendspaceCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?sendspace.com/file/.*' - __version__ = "0.13" + __name__ = "SendspaceCom" + __type__ = "hoster" + __version__ = "0.16" + + __pattern__ = r'https?://(?:www\.)?sendspace\.com/file/\w+' + __description__ = """Sendspace.com hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + + NAME_PATTERN = r'<h2 class="bgray">\s*<(?:b|strong)>(?P<N>[^<]+)</' + SIZE_PATTERN = r'<div class="file_description reverse margin_center">\s*<b>File Size:</b>\s*(?P<S>[\d.,]+)(?P<U>[\w^_]+)\s*</div>' + OFFLINE_PATTERN = r'<div class="msg error" style="cursor: default">Sorry, the file you requested is not available.</div>' + + LINK_PATTERN = r'<a id="download_button" href="([^"]+)"' + + CAPTCHA_PATTERN = r'<td><img src="(/captchas/captcha\.php?captcha=([^"]+))"></td>' + USER_CAPTCHA_PATTERN = r'<td><img src="/captchas/captcha\.php?user=([^"]+))"></td>' - DOWNLOAD_URL_PATTERN = r'<a id="download_button" href="([^"]+)"' - FILE_NAME_PATTERN = r'<h2 class="bgray">\s*<(?:b|strong)>(?P<N>[^<]+)</' - FILE_SIZE_PATTERN = r'<div class="file_description reverse margin_center">\s*<b>File Size:</b>\s*(?P<S>[0-9.]+)(?P<U>[kKMG])i?B\s*</div>' - FILE_OFFLINE_PATTERN = r'<div class="msg error" style="cursor: default">Sorry, the file you requested is not available.</div>' - CAPTCHA_PATTERN = r'<td><img src="(/captchas/captcha.php?captcha=([^"]+))"></td>' - USER_CAPTCHA_PATTERN = r'<td><img src="/captchas/captcha.php?user=([^"]+))"></td>' def handleFree(self): params = {} - for _ in xrange(3): - found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) - if found: + for _i in xrange(3): + m = re.search(self.LINK_PATTERN, self.html) + if m: if 'captcha_hash' in params: self.correctCaptcha() - download_url = found.group(1) + download_url = m.group(1) break - found = re.search(self.CAPTCHA_PATTERN, self.html) - if found: + m = re.search(self.CAPTCHA_PATTERN, self.html) + if m: if 'captcha_hash' in params: self.invalidCaptcha() - captcha_url1 = "http://www.sendspace.com/" + found.group(1) - found = re.search(self.USER_CAPTCHA_PATTERN, self.html) - captcha_url2 = "http://www.sendspace.com/" + found.group(1) - params = {'captcha_hash': found.group(2), + captcha_url1 = "http://www.sendspace.com/" + m.group(1) + m = re.search(self.USER_CAPTCHA_PATTERN, self.html) + captcha_url2 = "http://www.sendspace.com/" + m.group(1) + params = {'captcha_hash': m.group(2), 'captcha_submit': 'Verify', 'captcha_answer': self.decryptCaptcha(captcha_url1) + " " + self.decryptCaptcha(captcha_url2)} else: @@ -63,10 +53,9 @@ class SendspaceCom(SimpleHoster): self.logDebug(params) self.html = self.load(self.pyfile.url, post=params) else: - self.fail("Download link not found") + self.fail(_("Download link not found")) - self.logDebug("Download URL: %s" % download_url) self.download(download_url) -create_getInfo(SendspaceCom) +getInfo = create_getInfo(SendspaceCom) diff --git a/module/plugins/hoster/Share4webCom.py b/module/plugins/hoster/Share4webCom.py index e25216cb8..4634917ad 100644 --- a/module/plugins/hoster/Share4webCom.py +++ b/module/plugins/hoster/Share4webCom.py @@ -5,15 +5,18 @@ from module.plugins.internal.SimpleHoster import create_getInfo class Share4webCom(UnibytesCom): - __name__ = "Share4webCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?share4web\.com/get/\w+' - __version__ = "0.1" + __name__ = "Share4webCom" + __type__ = "hoster" + __version__ = "0.11" + + __pattern__ = r'https?://(?:www\.)?share4web\.com/get/\w+' + __description__ = """Share4web.com hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + - DOMAIN = 'http://www.share4web.com' + HOSTER_DOMAIN = "share4web.com" getInfo = create_getInfo(UnibytesCom) diff --git a/module/plugins/hoster/Share76Com.py b/module/plugins/hoster/Share76Com.py index 558ec2451..1ac8a64e7 100644 --- a/module/plugins/hoster/Share76Com.py +++ b/module/plugins/hoster/Share76Com.py @@ -4,13 +4,15 @@ from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo class Share76Com(DeadHoster): - __name__ = "Share76Com" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?share76.com/\w{12}' + __name__ = "Share76Com" + __type__ = "hoster" __version__ = "0.04" + + __pattern__ = r'http://(?:www\.)?share76\.com/\w{12}' + __description__ = """Share76.com hoster plugin""" - __author_name__ = "me" - __author_mail__ = "" + __license__ = "GPLv3" + __authors__ = [] getInfo = create_getInfo(Share76Com) diff --git a/module/plugins/hoster/ShareFilesCo.py b/module/plugins/hoster/ShareFilesCo.py index 35f21916c..4996014d8 100644 --- a/module/plugins/hoster/ShareFilesCo.py +++ b/module/plugins/hoster/ShareFilesCo.py @@ -4,13 +4,15 @@ from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo class ShareFilesCo(DeadHoster): - __name__ = "ShareFilesCo" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?sharefiles\.co/\w{12}' + __name__ = "ShareFilesCo" + __type__ = "hoster" __version__ = "0.02" + + __pattern__ = r'http://(?:www\.)?sharefiles\.co/\w{12}' + __description__ = """Sharefiles.co hoster plugin""" - __author_name__ = "stickell" - __author_mail__ = "l.stickell@yahoo.it" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it")] getInfo = create_getInfo(ShareFilesCo) diff --git a/module/plugins/hoster/ShareRapidCom.py b/module/plugins/hoster/ShareRapidCom.py deleted file mode 100644 index b82a142ea..000000000 --- a/module/plugins/hoster/ShareRapidCom.py +++ /dev/null @@ -1,70 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from pycurl import HTTPHEADER -from module.network.HTTPRequest import BadHeader -from module.network.RequestFactory import getRequest -from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo, replace_patterns - - -def getInfo(urls): - h = getRequest() - h.c.setopt(HTTPHEADER, - ["Accept: text/html", - "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0"]) - for url in urls: - html = h.load(url, decode=True) - file_info = parseFileInfo(ShareRapidCom, replace_patterns(url, ShareRapidCom.FILE_URL_REPLACEMENTS), html) - yield file_info - - -class ShareRapidCom(SimpleHoster): - __name__ = "ShareRapidCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?((share(-?rapid\.(biz|com|cz|info|eu|net|org|pl|sk)|-(central|credit|free|net)\.cz|-ms\.net)|(s-?rapid|rapids)\.(cz|sk))|(e-stahuj|mediatack|premium-rapidshare|rapidshare-premium|qiuck)\.cz|kadzet\.com|stahuj-zdarma\.eu|strelci\.net|universal-share\.com)/stahuj/(?P<id>\w+)' - __version__ = "0.53" - __description__ = """Share-rapid.com hoster plugin""" - __author_name__ = ("MikyWoW", "zoidberg", "stickell") - __author_mail__ = ("mikywow@seznam.cz", "zoidberg@mujmail.cz", "l.stickell@yahoo.it") - - FILE_NAME_PATTERN = r'<h1[^>]*><span[^>]*>(?:<a[^>]*>)?(?P<N>[^<]+)' - FILE_SIZE_PATTERN = r'<td class="i">Velikost:</td>\s*<td class="h"><strong>\s*(?P<S>[0-9.]+) (?P<U>[kKMG])i?B</strong></td>' - FILE_OFFLINE_PATTERN = ur'Nastala chyba 404|Soubor byl smazán' - - DOWNLOAD_URL_PATTERN = r'<a href="([^"]+)" title="Stahnout">([^<]+)</a>' - ERR_LOGIN_PATTERN = ur'<div class="error_div"><strong>Stahování je přístupné pouze přihlášeným uživatelům' - ERR_CREDIT_PATTERN = ur'<div class="error_div"><strong>Stahování zdarma je možné jen přes náš' - - FILE_URL_REPLACEMENTS = [(__pattern__, r'http://share-rapid.com/stahuj/\g<id>')] - - def setup(self): - self.chunkLimit = 1 - self.resumeDownload = True - - def process(self, pyfile): - if not self.account: - self.fail("User not logged in") - - try: - self.html = self.load(pyfile.url, decode=True) - except BadHeader, e: - self.account.relogin(self.user) - self.retry(max_tries=3, reason=str(e)) - - self.getFileInfo() - - found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) - if found: - link = found.group(1) - self.logDebug("Premium link: %s" % link) - - self.download(link, disposition=True) - else: - if re.search(self.ERR_LOGIN_PATTERN, self.html): - self.relogin(self.user) - self.retry(max_tries=3, reason="User login failed") - elif re.search(self.ERR_CREDIT_PATTERN, self.html): - self.fail("Not enough credit left") - else: - self.fail("Download link not found") diff --git a/module/plugins/hoster/SharebeesCom.py b/module/plugins/hoster/SharebeesCom.py index a4625b6a1..c0fd22c91 100644 --- a/module/plugins/hoster/SharebeesCom.py +++ b/module/plugins/hoster/SharebeesCom.py @@ -4,13 +4,15 @@ from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo class SharebeesCom(DeadHoster): - __name__ = "SharebeesCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?sharebees.com/\w{12}' + __name__ = "SharebeesCom" + __type__ = "hoster" __version__ = "0.02" + + __pattern__ = r'http://(?:www\.)?sharebees\.com/\w{12}' + __description__ = """ShareBees hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] getInfo = create_getInfo(SharebeesCom) diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py index a5bd9c250..dc3d5093c 100644 --- a/module/plugins/hoster/ShareonlineBiz.py +++ b/module/plugins/hoster/ShareonlineBiz.py @@ -1,195 +1,188 @@ # -*- coding: utf-8 -*- import re + from time import time +from urllib import unquote +from urlparse import urlparse -from module.plugins.Hoster import Hoster from module.network.RequestFactory import getURL -from module.plugins.Plugin import chunks from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -def getInfo(urls): - api_url_base = "http://api.share-online.biz/linkcheck.php" +class ShareonlineBiz(SimpleHoster): + __name__ = "ShareonlineBiz" + __type__ = "hoster" + __version__ = "0.45" - urls = [url.replace("https://", "http://") for url in urls] + __pattern__ = r'https?://(?:www\.)?(share-online\.biz|egoshare\.com)/(download\.php\?id=|dl/)(?P<ID>\w+)' - for chunk in chunks(urls, 90): - api_param_file = {"links": "\n".join(x.replace("http://www.share-online.biz/dl/", "").rstrip("/") for x in - chunk)} # api only supports old style links - src = getURL(api_url_base, post=api_param_file, decode=True) - result = [] - for i, res in enumerate(src.split("\n")): - if not res: - continue - fields = res.split(";") + __description__ = """Shareonline.biz hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("spoob", "spoob@pyload.org"), + ("mkaay", "mkaay@mkaay.de"), + ("zoidberg", "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com")] - if fields[1] == "OK": - status = 2 - elif fields[1] in ("DELETED", "NOT FOUND"): - status = 1 - else: - status = 3 - result.append((fields[2], int(fields[3]), status, chunk[i])) - yield result + URL_REPLACEMENTS = [(__pattern__ + ".*", "http://www.share-online.biz/dl/\g<ID>")] - -class ShareonlineBiz(Hoster): - __name__ = "ShareonlineBiz" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?(share-online\.biz|egoshare\.com)/(download.php\?id=|dl/)(?P<ID>\w+)' - __version__ = "0.40" - __description__ = """Shareonline.biz hoster plugin""" - __author_name__ = ("spoob", "mkaay", "zoidberg", "Walter Purcaro") - __author_mail__ = ("spoob@pyload.org", "mkaay@mkaay.de", "zoidberg@mujmail.cz", "vuolter@gmail.com") + RECAPTCHA_KEY = "6LdatrsSAAAAAHZrB70txiV5p-8Iv8BtVxlTtjKX" ERROR_INFO_PATTERN = r'<p class="b">Information:</p>\s*<div>\s*<strong>(.*?)</strong>' - def setup(self): - # range request not working? - # api supports resume, only one chunk - # website isn't supporting resuming in first place - self.file_id = re.match(self.__pattern__, self.pyfile.url).group("ID") - self.pyfile.url = "http://www.share-online.biz/dl/" + self.file_id - self.resumeDownload = self.premium - self.multiDL = False - #self.chunkLimit = 1 + @classmethod + def getInfo(cls, url="", html=""): + info = {'name': urlparse(unquote(url)).path.split('/')[-1] or _("Unknown"), 'size': 0, 'status': 3 if url else 1, 'url': url} - self.check_data = None + if url: + info['pattern'] = re.match(cls.__pattern__, url).groupdict() - def process(self, pyfile): - if self.premium: - self.handlePremium() - #web-download fallback removed - didn't work anyway - else: - self.handleFree() - - # check = self.checkDownload({"failure": re.compile(self.ERROR_INFO_PATTERN)}) - # if check == "failure": - # try: - # self.retry(reason=self.lastCheck.group(1).decode("utf8")) - # except: - # self.retry(reason="Unknown error") - - if self.api_data: - self.check_data = {"size": int(self.api_data['size']), "md5": self.api_data['md5']} - - def loadAPIData(self): - api_url_base = "http://api.share-online.biz/linkcheck.php?md5=1" - api_param_file = {"links": self.file_id} # api only supports old style links - src = self.load(api_url_base, cookies=False, post=api_param_file, decode=True) - - fields = src.split(";") - self.api_data = {"fileid": fields[0], - "status": fields[1]} - if not self.api_data["status"] == "OK": - self.offline() - else: - self.api_data["filename"] = fields[2] - self.api_data["size"] = fields[3] # in bytes - self.api_data["md5"] = fields[4].strip().lower().replace("\n\n", "") # md5 + field = getURL("http://api.share-online.biz/linkcheck.php", + get={'md5': "1"}, + post={'links': info['pattern']['ID']}, + decode=True).split(";") - def handleFree(self): - self.loadAPIData() - self.pyfile.name = self.api_data["filename"] - self.pyfile.size = int(self.api_data["size"]) + if field[1] == "OK": + info['fileid'] = field[0] + info['status'] = 2 + info['name'] = field[2] + info['size'] = field[3] #: in bytes + info['md5'] = field[4].strip().lower().replace("\n\n", "") #: md5 - self.html = self.load(self.pyfile.url, cookies=True) # refer, stuff - self.setWait(3) - self.wait() + elif field[1] in ("DELETED", "NOT FOUND"): + info['status'] = 1 + + return info - self.html = self.load("%s/free/" % self.pyfile.url, post={"dl_free": "1", "choice": "free"}, decode=True) - self.checkErrors() - found = re.search(r'var wait=(\d+);', self.html) + def setup(self): + self.resumeDownload = self.premium + self.multiDL = False + + def handleCaptcha(self): recaptcha = ReCaptcha(self) - for _ in xrange(5): - challenge, response = recaptcha.challenge("6LdatrsSAAAAAHZrB70txiV5p-8Iv8BtVxlTtjKX") - self.setWait(int(found.group(1)) if found else 30) - response = self.load("%s/free/captcha/%d" % (self.pyfile.url, int(time() * 1000)), post={ - 'dl_free': '1', - 'recaptcha_challenge_field': challenge, - 'recaptcha_response_field': response}) - - if not response == '0': + + for _i in xrange(5): + challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY) + + m = re.search(r'var wait=(\d+);', self.html) + self.setWait(int(m.group(1)) if m else 30) + + res = self.load("%s/free/captcha/%d" % (self.pyfile.url, int(time() * 1000)), + post={'dl_free' : "1", + 'recaptcha_challenge_field': challenge, + 'recaptcha_response_field' : response}) + if not res == '0': self.correctCaptcha() - break + return res else: self.invalidCaptcha() else: self.invalidCaptcha() - self.fail("No valid captcha solution received") + self.fail(_("No valid captcha solution received")) + + + def handleFree(self): + self.html = self.load(self.pyfile.url, cookies=True) #: refer, stuff + + self.wait(3) + + self.html = self.load("%s/free/" % self.pyfile.url, post={"dl_free": "1", "choice": "free"}, decode=True) + + self.checkErrors() + + res = self.handleCaptcha() + + download_url = res.decode("base64") - download_url = response.decode("base64") - self.logDebug(download_url) if not download_url.startswith("http://"): - self.parseError("download url") + self.error(_("Wrong download url")) self.wait() + self.download(download_url) - # check download + + + def checkFile(self): + super(ShareonlineBiz, self).checkFile() + check = self.checkDownload({ - "cookie": re.compile(r'<div id="dl_failure"'), - "fail": re.compile(r"<title>Share-Online") + 'cookie': re.compile(r'<div id="dl_failure"'), + 'fail' : re.compile(r"<title>Share-Online") }) + if check == "cookie": self.invalidCaptcha() - self.retry(5, 60, "Cookie failure") + self.retry(5, 60, _("Cookie failure")) + elif check == "fail": self.invalidCaptcha() - self.retry(5, 5 * 60, "Download failed") - else: - self.correctCaptcha() + self.retry(5, 5 * 60, _("Download failed")) + - def handlePremium(self): # should be working better loading (account) api internally + def handlePremium(self): #: should be working better loading (account) api internally self.account.getAccountInfo(self.user, True) - src = self.load("http://api.share-online.biz/account.php", - {"username": self.user, "password": self.account.accounts[self.user]["password"], - "act": "download", "lid": self.file_id}) + + html = self.load("http://api.share-online.biz/account.php", + {"username": self.user, "password": self.account.accounts[self.user]['password'], + "act": "download", "lid": self.info['fileid']}) self.api_data = dlinfo = {} - for line in src.splitlines(): + + for line in html.splitlines(): key, value = line.split(": ") dlinfo[key.lower()] = value self.logDebug(dlinfo) - if not dlinfo["status"] == "online": + + if not dlinfo['status'] == "online": self.offline() else: - self.pyfile.name = dlinfo["name"] - self.pyfile.size = int(dlinfo["size"]) + self.pyfile.name = dlinfo['name'] + self.pyfile.size = int(dlinfo['size']) + + dlLink = dlinfo['url'] - dlLink = dlinfo["url"] if dlLink == "server_under_maintenance": self.tempOffline() else: self.multiDL = True self.download(dlLink) + def checkErrors(self): - found = re.search(r"/failure/(.*?)/1", self.req.lastEffectiveURL) - if not found: + m = re.search(r"/failure/(.*?)/1", self.req.lastEffectiveURL) + if m is None: + self.info.pop('error', None) return - err = found.group(1) - found = re.search(self.ERROR_INFO_PATTERN, self.html) - msg = found.group(1) if found else "" - self.logError(err, msg or "Unknown error occurred") + errmsg = m.group(1).lower() + + try: + self.logError(errmsg, re.search(self.ERROR_INFO_PATTERN, self.html).group(1)) + except: + self.logError("Unknown error occurred", errmsg) + + if errmsg is "invalid": + self.fail(_("File not available")) + + elif errmsg in ("freelimit", "size", "proxy"): + self.fail(_("Premium account needed")) + + elif errmsg in ("expired", "server"): + self.retry(wait_time=600, reason=errmsg) + + elif 'slot' in errmsg: + self.wantReconnect = True + self.retry(24, 3600, errmsg) - if err in ('invalid'): - self.fail(msg or "File not available") - elif err in ('freelimit', 'size', 'proxy'): - self.fail(msg or "Premium account needed") else: - if err in 'server': - self.setWait(600, False) - elif err in 'expired': - self.setWait(30, False) - else: - self.setWait(300, True) + self.wantReconnect = True + self.retry(wait_time=60, reason=errmsg) + - self.wait() - self.retry(max_tries=25, reason=msg) +getInfo = create_getInfo(ShareonlineBiz) diff --git a/module/plugins/hoster/ShareplaceCom.py b/module/plugins/hoster/ShareplaceCom.py index ba1b40fb7..ccf4bcda5 100644 --- a/module/plugins/hoster/ShareplaceCom.py +++ b/module/plugins/hoster/ShareplaceCom.py @@ -1,24 +1,30 @@ # -*- coding: utf-8 -*- import re -import urllib + +from urllib import unquote + from module.plugins.Hoster import Hoster class ShareplaceCom(Hoster): - __name__ = "ShareplaceCom" - __type__ = "hoster" - __pattern__ = r'(http://)?(?:www\.)?shareplace\.(com|org)/\?[a-zA-Z0-9]+' + __name__ = "ShareplaceCom" + __type__ = "hoster" __version__ = "0.11" + + __pattern__ = r'(http://)?(?:www\.)?shareplace\.(com|org)/\?\w+' + __description__ = """Shareplace.com hoster plugin""" - __author_name__ = "ACCakut" - __author_mail__ = "" + __license__ = "GPLv3" + __authors__ = [("ACCakut", None)] + def process(self, pyfile): self.pyfile = pyfile self.prepare() self.download(self.get_file_url()) + def prepare(self): if not self.file_exists(): self.offline() @@ -27,11 +33,11 @@ class ShareplaceCom(Hoster): wait_time = self.get_waiting_time() self.setWait(wait_time) - self.logDebug("%s: Waiting %d seconds." % (self.__name__, wait_time)) self.wait() + def get_waiting_time(self): - if self.html is None: + if not self.html: self.download_html() #var zzipitime = 15; @@ -43,34 +49,38 @@ class ShareplaceCom(Hoster): return sec + def download_html(self): url = re.sub("shareplace.com\/\?", "shareplace.com//index1.php/?a=", self.pyfile.url) self.html = self.load(url, decode=True) + def get_file_url(self): """ returns the absolute downloadable filepath """ url = re.search(r"var beer = '(.*?)';", self.html) if url: url = url.group(1) - url = urllib.unquote( + url = unquote( url.replace("http://http:/", "").replace("vvvvvvvvv", "").replace("lllllllll", "").replace( "teletubbies", "")) self.logDebug("URL: %s" % url) return url else: - self.fail("absolute filepath could not be found. offline? ") + self.error(_("Absolute filepath not found")) + def get_file_name(self): - if self.html is None: + if not self.html: self.download_html() return re.search("<title>\s*(.*?)\s*</title>", self.html).group(1) + def file_exists(self): """ returns True or False """ - if self.html is None: + if not self.html: self.download_html() if re.search(r"HTTP Status 404", self.html) is not None: diff --git a/module/plugins/hoster/SharingmatrixCom.py b/module/plugins/hoster/SharingmatrixCom.py new file mode 100644 index 000000000..fa08a4a8f --- /dev/null +++ b/module/plugins/hoster/SharingmatrixCom.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo + + +class SharingmatrixCom(DeadHoster): + __name__ = "SharingmatrixCom" + __type__ = "hoster" + __version__ = "0.01" + + __pattern__ = r'http://(?:www\.)?sharingmatrix\.com/file/\w+' + + __description__ = """Sharingmatrix.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("jeix", "jeix@hasnomail.de"), + ("paulking", None)] + + +getInfo = create_getInfo(SharingmatrixCom) diff --git a/module/plugins/hoster/ShragleCom.py b/module/plugins/hoster/ShragleCom.py index a86e66972..bec30f6f2 100644 --- a/module/plugins/hoster/ShragleCom.py +++ b/module/plugins/hoster/ShragleCom.py @@ -4,13 +4,16 @@ from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo class ShragleCom(DeadHoster): - __name__ = "ShragleCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?(cloudnator|shragle).com/files/(?P<ID>.*?)/' + __name__ = "ShragleCom" + __type__ = "hoster" __version__ = "0.22" + + __pattern__ = r'http://(?:www\.)?(cloudnator|shragle)\.com/files/(?P<ID>.+?)/' + __description__ = """Cloudnator.com (Shragle.com) hoster plugin""" - __author_name__ = ("RaNaN", "zoidberg") - __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz") + __license__ = "GPLv3" + __authors__ = [("RaNaN", "RaNaN@pyload.org"), + ("zoidberg", "zoidberg@mujmail.cz")] getInfo = create_getInfo(ShragleCom) diff --git a/module/plugins/hoster/SimplyPremiumCom.py b/module/plugins/hoster/SimplyPremiumCom.py index c9fbf2ff1..bf7c43af6 100644 --- a/module/plugins/hoster/SimplyPremiumCom.py +++ b/module/plugins/hoster/SimplyPremiumCom.py @@ -1,103 +1,77 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################ - import re + from datetime import datetime, timedelta -from module.plugins.Hoster import Hoster +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo +from module.plugins.internal.SimpleHoster import secondsToMidnight -def secondsToMidnight(): - # Seconds until 00:10 GMT+2 - now = datetime.utcnow() + timedelta(hours=2) - if now.hour is 0 and now.minute < 10: - midnight = now - else: - midnight = now + timedelta(days=1) - midnight = midnight.replace(hour=0, minute=10, second=0, microsecond=0) - return int((midnight - now).total_seconds()) +class SimplyPremiumCom(MultiHoster): + __name__ = "SimplyPremiumCom" + __type__ = "hoster" + __version__ = "0.07" + __pattern__ = r'https?://.+simply-premium\.com' + + __description__ = """Simply-Premium.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("EvolutionClip", "evolutionclip@live.de")] -class SimplyPremiumCom(Hoster): - __name__ = "SimplyPremiumCom" - __version__ = "0.01" - __type__ = "hoster" - __pattern__ = r"https?://.*(simply-premium)\.com" - __description__ = """Simply-Premium.Com hoster plugin""" - __author_name__ = ("EvolutionClip") - __author_mail__ = ("evolutionclip@live.de") def setup(self): - self.chunkLimit = 16 + self.chunkLimit = 16 self.resumeDownload = False - def process(self, pyfile): - if re.match(self.__pattern__, pyfile.url): - new_url = pyfile.url - elif not self.account: - self.logError(_("Please enter your %s account or deactivate this plugin") % "Simply-Premium.com") - self.fail("No Simply-Premium.com account provided") + + def handlePremium(self): + for i in xrange(5): + page = self.load("http://www.simply-premium.com/premium.php", get={'info': "", 'link': self.pyfile.url}) + self.logDebug("JSON data: " + page) + if page != '': + break else: - self.logDebug("Old URL: %s" % pyfile.url) - for i in xrange(5): - page = self.load('http://www.simply-premium.com/premium.php?info&link=' + pyfile.url) - self.logDebug("JSON data: " + page) - if page != '': - break - else: - self.logInfo("Unable to get API data, waiting 1 minute and retry") - self.retry(5, 60, "Unable to get API data") - - if '<valid>0</valid>' in page or ( - "You are not allowed to download from this host" in page and self.premium): - self.account.relogin(self.user) - self.retry() - elif "NOTFOUND" in page: - self.offline() - elif "downloadlimit" in page: - self.logInfo("Reached maximum connctions") - self.retry(5, 60, "Reached maximum connctions") - elif "trafficlimit" in page: - self.logInfo("Reached daily limit for this host. Waiting until 00:10 GMT+2") - self.retry(5, secondsToMidnight(), "Daily limit for this host reached") - elif "hostererror" in page: - self.logInfo("Hoster temporarily unavailable, waiting 1 minute and retry") - self.retry(5, 60, "Hoster is temporarily unavailable") - #page = json_loads(page) - #new_url = page.keys()[0] - #self.api_data = page[new_url] - - try: - start = page.index('<name>') + len('<name>') - end = page.index('</name>', start) - self.pyfile.name = page[start:end] - except ValueError: - self.pyfile.name = "" - - try: - start = page.index('<size>') + len('<size>') - end = page.index('</size>', start) - self.pyfile.size = int(float(page[start:end])) - except ValueError: - self.pyfile.size = 0 - - new_url = 'http://www.simply-premium.com/premium.php?link=' + pyfile.url - - if new_url != pyfile.url: - self.logDebug("New URL: " + new_url) - - self.download(new_url, disposition=True) + self.logInfo(_("Unable to get API data, waiting 1 minute and retry")) + self.retry(5, 60, "Unable to get API data") + + if '<valid>0</valid>' in page or ( + "You are not allowed to download from this host" in page and self.premium): + self.account.relogin(self.user) + self.retry() + + elif "NOTFOUND" in page: + self.offline() + + elif "downloadlimit" in page: + self.logWarning(_("Reached maximum connctions")) + self.retry(5, 60, "Reached maximum connctions") + + elif "trafficlimit" in page: + self.logWarning(_("Reached daily limit for this host")) + self.retry(wait_time=secondsToMidnight(gmt=2), reason="Daily limit for this host reached") + + elif "hostererror" in page: + self.logWarning(_("Hoster temporarily unavailable, waiting 1 minute and retry")) + self.retry(5, 60, "Hoster is temporarily unavailable") + + try: + self.pyfile.name = re.search(r'<name>([^<]+)</name>', page).group(1) + except AttributeError: + self.pyfile.name = "" + + try: + self.pyfile.size = re.search(r'<size>(\d+)</size>', page).group(1) + except AttributeError: + self.pyfile.size = 0 + + try: + self.link = re.search(r'<download>([^<]+)</download>', page).group(1) + except AttributeError: + self.link = 'http://www.simply-premium.com/premium.php?link=' + self.pyfile.url + + if self.link != self.pyfile.url: + self.logDebug("New URL: " + self.link) + + +getInfo = create_getInfo(SimplyPremiumCom) diff --git a/module/plugins/hoster/SimplydebridCom.py b/module/plugins/hoster/SimplydebridCom.py index 2aab12e04..5e6b47efc 100644 --- a/module/plugins/hoster/SimplydebridCom.py +++ b/module/plugins/hoster/SimplydebridCom.py @@ -2,58 +2,62 @@ import re -from module.plugins.Hoster import Hoster +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -class SimplydebridCom(Hoster): - __name__ = "SimplydebridCom" - __version__ = "0.1" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/sd.php/*' +class SimplydebridCom(MultiHoster): + __name__ = "SimplydebridCom" + __type__ = "hoster" + __version__ = "0.14" + + __pattern__ = r'http://\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/sd\.php' + __description__ = """Simply-debrid.com hoster plugin""" - __author_name__ = "Kagenoshin" - __author_mail__ = "kagenoshin@gmx.ch" + __license__ = "GPLv3" + __authors__ = [("Kagenoshin", "kagenoshin@gmx.ch")] - def setup(self): - self.resumeDownload = self.multiDL = True - self.chunkLimit = 1 - def process(self, pyfile): - if not self.account: - self.logError(_("Please enter your %s account or deactivate this plugin") % "simply-debrid.com") - self.fail("No simply-debrid.com account provided") + def setup(self): + self.resumeDownload = True + self.multiDL = True + self.chunkLimit = 1 - self.logDebug("Old URL: %s" % pyfile.url) + def handlePremium(self): #fix the links for simply-debrid.com! - new_url = pyfile.url - new_url = new_url.replace("clz.to", "cloudzer.net/file") - new_url = new_url.replace("http://share-online", "http://www.share-online") - new_url = new_url.replace("ul.to", "uploaded.net/file") - new_url = new_url.replace("uploaded.com", "uploaded.net") - new_url = new_url.replace("filerio.com", "filerio.in") - new_url = new_url.replace("lumfile.com", "lumfile.se") - if('fileparadox' in new_url): - new_url = new_url.replace("http://", "https://") - - if re.match(self.__pattern__, new_url): - new_url = new_url - - self.logDebug("New URL: %s" % new_url) - - if not re.match(self.__pattern__, new_url): - page = self.load('http://simply-debrid.com/api.php', get={'dl': new_url}) # +'&u='+self.user+'&p='+self.account.getAccountData(self.user)['password']) + self.link = self.pyfile.url + self.link = self.link.replace("clz.to", "cloudzer.net/file") + self.link = self.link.replace("http://share-online", "http://www.share-online") + self.link = self.link.replace("ul.to", "uploaded.net/file") + self.link = self.link.replace("uploaded.com", "uploaded.net") + self.link = self.link.replace("filerio.com", "filerio.in") + self.link = self.link.replace("lumfile.com", "lumfile.se") + + if('fileparadox' in self.link): + self.link = self.link.replace("http://", "https://") + + if re.match(self.__pattern__, self.link): + self.link = self.link + + self.logDebug("New URL: %s" % self.link) + + if not re.match(self.__pattern__, self.link): + page = self.load("http://simply-debrid.com/api.php", get={'dl': self.link}) # +'&u='+self.user+'&p='+self.account.getAccountData(self.user)['password']) if 'tiger Link' in page or 'Invalid Link' in page or ('API' in page and 'ERROR' in page): - self.fail('Unable to unrestrict link') - new_url = page + self.fail(_("Unable to unrestrict link")) + self.link = page self.setWait(5) self.wait() - self.logDebug("Unrestricted URL: " + new_url) - self.download(new_url, disposition=True) + + def checkFile(self): + super(SimplydebridCom, self).checkFile() check = self.checkDownload({"bad1": "No address associated with hostname", "bad2": "<html"}) if check == "bad1" or check == "bad2": self.retry(24, 3 * 60, "Bad file downloaded") + + +getInfo = create_getInfo(SimplydebridCom) diff --git a/module/plugins/hoster/SockshareCom.py b/module/plugins/hoster/SockshareCom.py index 017c8a839..aabb8dcd1 100644 --- a/module/plugins/hoster/SockshareCom.py +++ b/module/plugins/hoster/SockshareCom.py @@ -1,96 +1,20 @@ # -*- coding: utf-8 -*- -############################################################################### -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -# @author: Walter Purcaro -############################################################################### -import re -from os import rename +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +class SockshareCom(DeadHoster): + __name__ = "SockshareCom" + __type__ = "hoster" + __version__ = "0.05" -class SockshareCom(SimpleHoster): - __name__ = "SockshareCom" - __type__ = "hoster" __pattern__ = r'http://(?:www\.)?sockshare\.com/(mobile/)?(file|embed)/(?P<ID>\w+)' - __version__ = "0.02" - __description__ = """Sockshare.com hoster plugin""" - __author_name__ = ("jeix", "stickell", "Walter Purcaro") - __author_mail__ = ("jeix@hasnomail.de", "l.stickell@yahoo.it", "vuolter@gmail.com") - - FILE_INFO_PATTERN = r'site-content">\s*<h1>(?P<N>.+)<strong>\( (?P<S>[^)]+) \)</strong></h1>' - FILE_OFFLINE_PATTERN = r'>This file doesn\'t exist, or has been removed.<' - - FILE_URL_REPLACEMENTS = [(__pattern__, r'http://www.sockshare.com/file/\g<ID>')] - - def setup(self): - self.multiDL = self.resumeDownload = True - self.chunkLimit = -1 - - def handleFree(self): - name = self.pyfile.name - link = self._getLink() - self.logDebug("Direct link: " + link) - self.download(link, disposition=True) - self.processName(name) - def _getLink(self): - hash_data = re.search(r'<input type="hidden" value="([a-z0-9]+)" name="hash">', self.html) - if not hash_data: - self.parseError("Unable to detect hash") - - post_data = {"hash": hash_data.group(1), "confirm": "Continue+as+Free+User"} - self.html = self.load(self.pyfile.url, post=post_data) - if (">You have exceeded the daily stream limit for your country\\. You can wait until tomorrow" in self.html or - "(>This content server has been temporarily disabled for upgrades|Try again soon\\. You can still download it below\\.<)" in self.html): - self.retry(wait_time=60 * 60 * 2, reason="Download limit exceeded or server disabled") # 2 hours wait - - patterns = (r'(/get_file\.php\?id=[A-Z0-9]+&key=[a-zA-Z0-9=]+&original=1)', - r'(/get_file\.php\?download=[A-Z0-9]+&key=[a-z0-9]+)', - r'(/get_file\.php\?download=[A-Z0-9]+&key=[a-z0-9]+&original=1)', - r'<a href="/gopro\.php">Tired of ads and waiting\? Go Pro!</a>[\t\n\rn ]+</div>[\t\n\rn ]+<a href="(/.*?)"') - for pattern in patterns: - link = re.search(pattern, self.html) - if link: - break - else: - link = re.search(r"playlist: '(/get_file\.php\?stream=[a-zA-Z0-9=]+)'", self.html) - if link: - self.html = self.load("http://www.sockshare.com" + link.group(1)) - link = re.search(r'media:content url="(http://.*?)"', self.html) - if not link: - link = re.search(r'\"(http://media\\-b\\d+\\.sockshare\\.com/download/\\d+/.*?)\"', self.html) - else: - self.parseError('Unable to detect a download link') - - link = link.group(1).replace("&", "&") - if link.startswith("http://"): - return link - else: - return "http://www.sockshare.com" + link - - def processName(self, name_old): - name = self.pyfile.name - if name <= name_old: - return - name_new = re.sub(r'\.[^.]+$', "", name_old) + name[len(name_old):] - filename = self.lastDownload - self.pyfile.name = name_new - rename(filename, filename.rsplit(name)[0] + name_new) - self.logInfo("%(name)s renamed to %(newname)s" % {"name": name, "newname": name_new}) + __description__ = """Sockshare.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("jeix", "jeix@hasnomail.de"), + ("stickell", "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com")] getInfo = create_getInfo(SockshareCom) diff --git a/module/plugins/hoster/SoundcloudCom.py b/module/plugins/hoster/SoundcloudCom.py index a1ec1378a..3eb546604 100644 --- a/module/plugins/hoster/SoundcloudCom.py +++ b/module/plugins/hoster/SoundcloudCom.py @@ -1,44 +1,47 @@ # -*- coding: utf-8 -*- -import re import pycurl +import re from module.plugins.Hoster import Hoster class SoundcloudCom(Hoster): - __name__ = "SoundcloudCom" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?soundcloud\.com/(?P<UID>.*?)/(?P<SID>.*)' - __version__ = "0.1" + __name__ = "SoundcloudCom" + __type__ = "hoster" + __version__ = "0.10" + + __pattern__ = r'https?://(?:www\.)?soundcloud\.com/(?P<UID>.+?)/(?P<SID>.+)' + __description__ = """SoundCloud.com hoster plugin""" - __author_name__ = "Peekayy" - __author_mail__ = "peekayy.dev@gmail.com" + __license__ = "GPLv3" + __authors__ = [("Peekayy", "peekayy.dev@gmail.com")] + def process(self, pyfile): # default UserAgent of HTTPRequest fails for this hoster so we use this one self.req.http.c.setopt(pycurl.USERAGENT, 'Mozilla/5.0') page = self.load(pyfile.url) - match = re.search(r'<div class="haudio.*?large.*?" data-sc-track="(?P<ID>[0-9]*)"', page) + m = re.search(r'<div class="haudio.*?large.*?" data-sc-track="(?P<ID>\d*)"', page) songId = clientId = "" - if match: - songId = match.group("ID") + if m: + songId = m.group('ID') if len(songId) <= 0: - self.logError("Could not find song id") + self.logError(_("Could not find song id")) self.offline() else: - match = re.search(r'"clientID":"(?P<CID>.*?)"', page) - if match: - clientId = match.group("CID") + m = re.search(r'"clientID":"(?P<CID>.*?)"', page) + if m: + clientId = m.group('CID') if len(clientId) <= 0: clientId = "b45b1aa10f1ac2941910a7f0d10f8e28" - match = re.search(r'<em itemprop="name">\s(?P<TITLE>.*?)\s</em>', page) - if match: - pyfile.name = match.group("TITLE") + ".mp3" + m = re.search(r'<em itemprop="name">\s(?P<TITLE>.*?)\s</em>', page) + if m: + pyfile.name = m.group('TITLE') + ".mp3" else: - pyfile.name = re.match(self.__pattern__, pyfile.url).group("SID") + ".mp3" + pyfile.name = re.match(self.__pattern__, pyfile.url).group('SID') + ".mp3" # url to retrieve the actual song url page = self.load("https://api.sndcdn.com/i1/tracks/%s/streams" % songId, get={"client_id": clientId}) @@ -46,7 +49,7 @@ class SoundcloudCom(Hoster): # for now we choose the first stream found in all cases # it could be improved if relevant for this hoster streams = [ - (result.group("QUALITY"), result.group("URL")) + (result.group('QUALITY'), result.group('URL')) for result in re.finditer(r'"(?P<QUALITY>.*?)":"(?P<URL>.*?)"', page) ] self.logDebug("Found Streams", streams) diff --git a/module/plugins/hoster/SpeedLoadOrg.py b/module/plugins/hoster/SpeedLoadOrg.py index 76ab52868..a13220eab 100644 --- a/module/plugins/hoster/SpeedLoadOrg.py +++ b/module/plugins/hoster/SpeedLoadOrg.py @@ -4,13 +4,15 @@ from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo class SpeedLoadOrg(DeadHoster): - __name__ = "SpeedLoadOrg" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?speedload\.org/(?P<ID>\w+)' + __name__ = "SpeedLoadOrg" + __type__ = "hoster" __version__ = "1.02" + + __pattern__ = r'http://(?:www\.)?speedload\.org/(?P<ID>\w+)' + __description__ = """Speedload.org hoster plugin""" - __author_name__ = "stickell" - __author_mail__ = "l.stickell@yahoo.it" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it")] getInfo = create_getInfo(SpeedLoadOrg) diff --git a/module/plugins/hoster/SpeedfileCz.py b/module/plugins/hoster/SpeedfileCz.py index 63e126f0a..f23c8d4c7 100644 --- a/module/plugins/hoster/SpeedfileCz.py +++ b/module/plugins/hoster/SpeedfileCz.py @@ -1,33 +1,18 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo class SpeedfileCz(DeadHoster): - __name__ = "SpeedFileCz" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?speedfile.cz/.*' + __name__ = "SpeedFileCz" + __type__ = "hoster" __version__ = "0.32" + + __pattern__ = r'http://(?:www\.)?speedfile\.cz/.+' + __description__ = """Speedfile.cz hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] getInfo = create_getInfo(SpeedfileCz) diff --git a/module/plugins/hoster/SpeedyshareCom.py b/module/plugins/hoster/SpeedyshareCom.py new file mode 100644 index 000000000..fa54d6060 --- /dev/null +++ b/module/plugins/hoster/SpeedyshareCom.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# +# Test links: +# http://speedy.sh/ep2qY/Zapp-Brannigan.jpg + +import re + +from urlparse import urljoin + +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + + +class SpeedyshareCom(SimpleHoster): + __name__ = "SpeedyshareCom" + __type__ = "hoster" + __version__ = "0.03" + + __pattern__ = r'https?://(?:www\.)?(speedyshare\.com|speedy\.sh)/\w+' + + __description__ = """Speedyshare.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zapp-brannigan", "fuerst.reinje@web.de")] + + + NAME_PATTERN = r'class=downloadfilename>(?P<N>.*)</span></td>' + SIZE_PATTERN = r'class=sizetagtext>(?P<S>.*) (?P<U>[kKmM]?[iI]?[bB]?)</div>' + + OFFLINE_PATTERN = r'class=downloadfilenamenotfound>.*</span>' + + LINK_PATTERN = r'<a href=\'(.*)\'><img src=/gf/slowdownload\.png alt=\'Slow Download\' border=0' + + + def setup(self): + self.multiDL = False + self.chunkLimit = 1 + + + def handleFree(self): + m = re.search(self.LINK_PATTERN, self.html) + if m is None: + self.error(_("Download link not found")) + + dl_link = urljoin("http://www.speedyshare.com", m.group(1)) + self.download(dl_link, disposition=True) + + check = self.checkDownload({'html': re.compile("html")}) + if check == "html": + self.error(_("Downloaded file is an html page")) + + +getInfo = create_getInfo(SpeedyshareCom) diff --git a/module/plugins/hoster/StorageTo.py b/module/plugins/hoster/StorageTo.py new file mode 100644 index 000000000..bedc2934f --- /dev/null +++ b/module/plugins/hoster/StorageTo.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo + + +class StorageTo(DeadHoster): + __name__ = "StorageTo" + __type__ = "hoster" + __version__ = "0.01" + + __pattern__ = r'http://(?:www\.)?storage\.to/get/.+' + + __description__ = """Storage.to hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("mkaay", "mkaay@mkaay.de")] + + +getInfo = create_getInfo(StorageTo) diff --git a/module/plugins/hoster/StreamCz.py b/module/plugins/hoster/StreamCz.py index bbef31a67..11d4efcdb 100644 --- a/module/plugins/hoster/StreamCz.py +++ b/module/plugins/hoster/StreamCz.py @@ -1,25 +1,9 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re -from module.plugins.Hoster import Hoster + from module.network.RequestFactory import getURL +from module.plugins.Hoster import Hoster def getInfo(urls): @@ -28,7 +12,7 @@ def getInfo(urls): for url in urls: html = getURL(url) - if re.search(StreamCz.FILE_OFFLINE_PATTERN, html): + if re.search(StreamCz.OFFLINE_PATTERN, html): # File offline result.append((url, 0, 1, url)) else: @@ -37,46 +21,51 @@ def getInfo(urls): class StreamCz(Hoster): - __name__ = "StreamCz" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?stream.cz/[^/]+/\d+.*' - __version__ = "0.1" + __name__ = "StreamCz" + __type__ = "hoster" + __version__ = "0.20" + + __pattern__ = r'https?://(?:www\.)?stream\.cz/[^/]+/\d+' + __description__ = """Stream.cz hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + + NAME_PATTERN = r'<link rel="video_src" href="http://www\.stream\.cz/\w+/(\d+)-([^"]+)" />' + OFFLINE_PATTERN = r'<h1 class="commonTitle">Str.nku nebylo mo.n. nal.zt \(404\)</h1>' - FILE_OFFLINE_PATTERN = r'<h1 class="commonTitle">Str.nku nebylo mo.n. nal.zt \(404\)</h1>' - FILE_NAME_PATTERN = r'<link rel="video_src" href="http://www.stream.cz/\w+/(\d+)-([^"]+)" />' CDN_PATTERN = r'<param name="flashvars" value="[^"]*&id=(?P<ID>\d+)(?:&cdnLQ=(?P<cdnLQ>\d*))?(?:&cdnHQ=(?P<cdnHQ>\d*))?(?:&cdnHD=(?P<cdnHD>\d*))?&' + def setup(self): - self.multiDL = True self.resumeDownload = True + self.multiDL = True - def process(self, pyfile): + def process(self, pyfile): self.html = self.load(pyfile.url, decode=True) - if re.search(self.FILE_OFFLINE_PATTERN, self.html): + if re.search(self.OFFLINE_PATTERN, self.html): self.offline() - found = re.search(self.CDN_PATTERN, self.html) - if found is None: - self.fail("Parse error (CDN)") - cdn = found.groupdict() + m = re.search(self.CDN_PATTERN, self.html) + if m is None: + self.error(_("CDN_PATTERN not found")) + cdn = m.groupdict() self.logDebug(cdn) for cdnkey in ("cdnHD", "cdnHQ", "cdnLQ"): if cdnkey in cdn and cdn[cdnkey] > '': cdnid = cdn[cdnkey] break else: - self.fail("Stream URL not found") + self.fail(_("Stream URL not found")) - found = re.search(self.FILE_NAME_PATTERN, self.html) - if found is None: - self.fail("Parse error (NAME)") - pyfile.name = "%s-%s.%s.mp4" % (found.group(2), found.group(1), cdnkey[-2:]) + m = re.search(self.NAME_PATTERN, self.html) + if m is None: + self.error(_("NAME_PATTERN not found")) + pyfile.name = "%s-%s.%s.mp4" % (m.group(2), m.group(1), cdnkey[-2:]) download_url = "http://cdn-dispatcher.stream.cz/?id=" + cdnid - self.logInfo("STREAM (%s): %s" % (cdnkey[-2:], download_url)) + self.logInfo(_("STREAM: %s") % cdnkey[-2:], download_url) self.download(download_url) diff --git a/module/plugins/hoster/StreamcloudEu.py b/module/plugins/hoster/StreamcloudEu.py index 388eb7876..4f854a99d 100644 --- a/module/plugins/hoster/StreamcloudEu.py +++ b/module/plugins/hoster/StreamcloudEu.py @@ -1,120 +1,31 @@ # -*- coding: utf-8 -*- -from time import sleep import re -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo -from module.network.HTTPRequest import HTTPRequest +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo -class StreamcloudEu(XFileSharingPro): - __name__ = "StreamcloudEu" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?streamcloud\.eu/\S+' - __version__ = "0.04" - __description__ = """Streamcloud.eu hoster plugin""" - __author_name__ = "seoester" - __author_mail__ = "seoester@googlemail.com" - - HOSTER_NAME = "streamcloud.eu" - - DIRECT_LINK_PATTERN = r'file: "(http://(stor|cdn)\d+\.streamcloud.eu:?\d*/.*/video\.(mp4|flv))",' - - def setup(self): - super(StreamcloudEu, self).setup() - self.multiDL = True - - def getDownloadLink(self): - found = re.search(self.DIRECT_LINK_PATTERN, self.html, re.S) - if found: - return found.group(1) - - for i in xrange(5): - self.logDebug("Getting download link: #%d" % i) - data = self.getPostParameters() - httpRequest = HTTPRequest(options=self.req.options) - httpRequest.cj = self.req.cj - sleep(10) - self.html = httpRequest.load(self.pyfile.url, post=data, referer=False, cookies=True, decode=True) - self.header = httpRequest.header - - found = re.search("Location\s*:\s*(.*)", self.header, re.I) - if found: - break - - found = re.search(self.DIRECT_LINK_PATTERN, self.html, re.S) - if found: - break - - else: - if self.errmsg and 'captcha' in self.errmsg: - self.fail("No valid captcha code entered") - else: - self.fail("Download link not found") +class StreamcloudEu(XFSHoster): + __name__ = "StreamcloudEu" + __type__ = "hoster" + __version__ = "0.09" - return found.group(1) + __pattern__ = r'http://(?:www\.)?streamcloud\.eu/\w{12}' - def getPostParameters(self): - for i in xrange(3): - if not self.errmsg: - self.checkErrors() - - if hasattr(self, "FORM_PATTERN"): - action, inputs = self.parseHtmlForm(self.FORM_PATTERN) - else: - action, inputs = self.parseHtmlForm(input_names={"op": re.compile("^download")}) - - if not inputs: - action, inputs = self.parseHtmlForm('F1') - if not inputs: - if self.errmsg: - self.retry() - else: - self.parseError("Form not found") - - self.logDebug(self.HOSTER_NAME, inputs) - - if 'op' in inputs and inputs['op'] in ('download1', 'download2', 'download3'): - if "password" in inputs: - if self.passwords: - inputs['password'] = self.passwords.pop(0) - else: - self.fail("No or invalid passport") - - if not self.premium: - found = re.search(self.WAIT_PATTERN, self.html) - if found: - wait_time = int(found.group(1)) + 1 - self.setWait(wait_time, False) - else: - wait_time = 0 - - self.captcha = self.handleCaptcha(inputs) - - if wait_time: - self.wait() + __description__ = """Streamcloud.eu hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("seoester", "seoester@googlemail.com")] - self.errmsg = None - self.logDebug("getPostParameters {0}".format(i)) - return inputs - else: - inputs['referer'] = self.pyfile.url + HOSTER_DOMAIN = "streamcloud.eu" - if self.premium: - inputs['method_premium'] = "Premium Download" - if 'method_free' in inputs: - del inputs['method_free'] - else: - inputs['method_free'] = "Free Download" - if 'method_premium' in inputs: - del inputs['method_premium'] + LINK_PATTERN = r'file: "(http://(stor|cdn)\d+\.streamcloud\.eu:?\d*/.*/video\.(mp4|flv))",' - self.html = self.load(self.pyfile.url, post=inputs, ref=False) - self.errmsg = None - else: - self.parseError('FORM: %s' % (inputs['op'] if 'op' in inputs else 'UNKNOWN')) + def setup(self): + self.multiDL = True + self.chunkLimit = 1 + self.resumeDownload = self.premium getInfo = create_getInfo(StreamcloudEu) diff --git a/module/plugins/hoster/TurbobitNet.py b/module/plugins/hoster/TurbobitNet.py index f15b8b0c4..258ec7d3e 100644 --- a/module/plugins/hoster/TurbobitNet.py +++ b/module/plugins/hoster/TurbobitNet.py @@ -1,63 +1,49 @@ # -*- coding: utf-8 -*- -""" - Copyright (C) 2012 pyLoad team - Copyright (C) 2012 JD-Team support@jdownloader.org - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - -import re import random -from urllib import quote -from binascii import hexlify, unhexlify +import re import time -from pycurl import HTTPHEADER from Crypto.Cipher import ARC4 +from binascii import hexlify, unhexlify +from pycurl import HTTPHEADER +from urllib import quote + from module.network.RequestFactory import getURL -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, timestamp from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, timestamp class TurbobitNet(SimpleHoster): - __name__ = "TurbobitNet" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?(turbobit.net|unextfiles.com)/(?!download/folder/)(?:download/free/)?(?P<ID>\w+).*' - __version__ = "0.11" - __description__ = """Turbobit.net plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" - - # long filenames are shortened - FILE_INFO_PATTERN = r"<span class='file-icon1[^>]*>(?P<N>[^<]+)</span>\s*\((?P<S>[^\)]+)\)\s*</h1>" - FILE_NAME_PATTERN = r'<meta name="keywords" content="\s+(?P<N>[^,]+)' # full name but missing on page2 - FILE_OFFLINE_PATTERN = r'<h2>File Not Found</h2>|html\(\'File (?:was )?not found' - FILE_URL_REPLACEMENTS = [(r"http://(?:www\.)?(turbobit.net|unextfiles.com)/(?:download/free/)?(?P<ID>\w+).*", - "http://turbobit.net/\g<ID>.html")] - SH_COOKIES = [("turbobit.net", "user_lang", "en")] - - CAPTCHA_KEY_PATTERN = r'src="http://api\.recaptcha\.net/challenge\?k=([^"]+)"' - DOWNLOAD_URL_PATTERN = r'(?P<url>/download/redirect/[^"\']+)' - LIMIT_WAIT_PATTERN = r'<div id="time-limit-text">\s*.*?<span id=\'timeout\'>(\d+)</span>' - CAPTCHA_SRC_PATTERN = r'<img alt="Captcha" src="(.*?)"' + __name__ = "TurbobitNet" + __type__ = "hoster" + __version__ = "0.16" + + __pattern__ = r'http://(?:www\.)?turbobit\.net/(?:download/free/)?(?P<ID>\w+)' + + __description__ = """ Turbobit.net hoster plugin """ + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("prOq", None)] + + + URL_REPLACEMENTS = [(__pattern__ + ".*", "http://turbobit.net/\g<ID>.html")] + + COOKIES = [("turbobit.net", "user_lang", "en")] + + NAME_PATTERN = r'id="file-title">(?P<N>.+?)<' + SIZE_PATTERN = r'class="file-size">(?P<S>[\d.,]+) (?P<U>[\w^_]+)' + OFFLINE_PATTERN = r'<h2>File Not Found</h2>|html\(\'File (?:was )?not found' + + LINK_PATTERN = r'(/download/redirect/[^"\']+)' + LIMIT_WAIT_PATTERN = r'<div id=\'timeout\'>(\d+)<' + + CAPTCHA_PATTERN = r'<img alt="Captcha" src="(.+?)"' + def handleFree(self): - self.url = "http://turbobit.net/download/free/%s" % self.file_info['ID'] - self.html = self.load(self.url) + self.url = "http://turbobit.net/download/free/%s" % self.info['pattern']['ID'] + self.html = self.load(self.url, ref=True, decode=True) rtUpdate = self.getRtUpdate() @@ -70,79 +56,81 @@ class TurbobitNet(SimpleHoster): self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With:"]) self.downloadFile() + def solveCaptcha(self): - for _ in xrange(5): - found = re.search(self.LIMIT_WAIT_PATTERN, self.html) - if found: - wait_time = int(found.group(1)) + for _i in xrange(5): + m = re.search(self.LIMIT_WAIT_PATTERN, self.html) + if m: + wait_time = int(m.group(1)) self.wait(wait_time, wait_time > 60) self.retry() action, inputs = self.parseHtmlForm("action='#'") if not inputs: - self.parseError("captcha form") + self.error(_("Captcha form not found")) self.logDebug(inputs) if inputs['captcha_type'] == 'recaptcha': recaptcha = ReCaptcha(self) - found = re.search(self.CAPTCHA_KEY_PATTERN, self.html) - captcha_key = found.group(1) if found else '6LcTGLoSAAAAAHCWY9TTIrQfjUlxu6kZlTYP50_c' - inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge( - captcha_key) + inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge() else: - found = re.search(self.CAPTCHA_SRC_PATTERN, self.html) - if not found: - self.parseError('captcha') - captcha_url = found.group(1) + m = re.search(self.CAPTCHA_PATTERN, self.html) + if m is None: + self.error(_("captcha")) + captcha_url = m.group(1) inputs['captcha_response'] = self.decryptCaptcha(captcha_url) self.logDebug(inputs) self.html = self.load(self.url, post=inputs) - if not "<div class='download-timer-header'>" in self.html: + if '<div class="captcha-error">Incorrect, try again!<' in self.html: self.invalidCaptcha() else: self.correctCaptcha() break else: - self.fail("Invalid captcha") + self.fail(_("Invalid captcha")) + def getRtUpdate(self): rtUpdate = self.getStorage("rtUpdate") if not rtUpdate: - if self.getStorage("version") != self.__version__ or int( - self.getStorage("timestamp", 0)) + 86400000 < timestamp(): + if self.getStorage("version") != self.__version__ \ + or int(self.getStorage("timestamp", 0)) + 86400000 < timestamp(): # that's right, we are even using jdownloader updates rtUpdate = getURL("http://update0.jdownloader.org/pluginstuff/tbupdate.js") rtUpdate = self.decrypt(rtUpdate.splitlines()[1]) - # but we still need to fix the syntax to work with other engines than rhino + # but we still need to fix the syntax to work with other engines than rhino rtUpdate = re.sub(r'for each\(var (\w+) in(\[[^\]]+\])\)\{', r'zza=\2;for(var zzi=0;zzi<zza.length;zzi++){\1=zza[zzi];', rtUpdate) rtUpdate = re.sub(r"for\((\w+)=", r"for(var \1=", rtUpdate) - self.logDebug("rtUpdate") self.setStorage("rtUpdate", rtUpdate) self.setStorage("timestamp", timestamp()) self.setStorage("version", self.__version__) else: - self.logError("Unable to download, wait for update...") + self.logError(_("Unable to download, wait for update...")) self.tempOffline() return rtUpdate + def getDownloadUrl(self, rtUpdate): self.req.http.lastURL = self.url - found = re.search("(/\w+/timeout\.js\?\w+=)([^\"\'<>]+)", self.html) - url = "http://turbobit.net%s%s" % (found.groups() if found else ( - '/files/timeout.js?ver=', ''.join(random.choice('0123456789ABCDEF') for _ in xrange(32)))) + m = re.search("(/\w+/timeout\.js\?\w+=)([^\"\'<>]+)", self.html) + if m: + url = "http://turbobit.net%s%s" % m.groups() + else: + url = "http://turbobit.net/files/timeout.js?ver=%s" % "".join(random.choice('0123456789ABCDEF') for _i in xrange(32)) + fun = self.load(url) self.setWait(65, False) for b in [1, 3]: self.jscode = "var id = \'%s\';var b = %d;var inn = \'%s\';%sout" % ( - self.file_info['ID'], b, quote(fun), rtUpdate) + self.info['pattern']['ID'], b, quote(fun), rtUpdate) try: out = self.js.eval(self.jscode) @@ -157,26 +145,28 @@ class TurbobitNet(SimpleHoster): self.delStorage("rtUpdate") self.retry() + def decrypt(self, data): cipher = ARC4.new(hexlify('E\x15\xa1\x9e\xa3M\xa0\xc6\xa0\x84\xb6H\x83\xa8o\xa0')) return unhexlify(cipher.encrypt(unhexlify(data))) + def getLocalTimeString(self): lt = time.localtime() tz = time.altzone if lt.tm_isdst else time.timezone return "%s GMT%+03d%02d" % (time.strftime("%a %b %d %Y %H:%M:%S", lt), -tz // 3600, tz % 3600) + def handlePremium(self): self.logDebug("Premium download as user %s" % self.user) - self.html = self.load(self.pyfile.url) # Useless in 0.5 self.downloadFile() + def downloadFile(self): - found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) - if not found: - self.parseError("download link") - self.url = "http://turbobit.net" + found.group('url') - self.logDebug(self.url) + m = re.search(self.LINK_PATTERN, self.html) + if m is None: + self.error(_("Download link not found")) + self.url = "http://turbobit.net" + m.group(1) self.download(self.url) diff --git a/module/plugins/hoster/TurbouploadCom.py b/module/plugins/hoster/TurbouploadCom.py index 3f3deca15..f0893cef6 100644 --- a/module/plugins/hoster/TurbouploadCom.py +++ b/module/plugins/hoster/TurbouploadCom.py @@ -1,33 +1,18 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo class TurbouploadCom(DeadHoster): - __name__ = "TurbouploadCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?turboupload.com/(\w+).*' + __name__ = "TurbouploadCom" + __type__ = "hoster" __version__ = "0.03" + + __pattern__ = r'http://(?:www\.)?turboupload\.com/(\w+)' + __description__ = """Turboupload.com hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] getInfo = create_getInfo(TurbouploadCom) diff --git a/module/plugins/hoster/TusfilesNet.py b/module/plugins/hoster/TusfilesNet.py index c31b88f20..a4e352956 100644 --- a/module/plugins/hoster/TusfilesNet.py +++ b/module/plugins/hoster/TusfilesNet.py @@ -1,42 +1,35 @@ # -*- coding: utf-8 -*- -############################################################################### -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -############################################################################### - -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo - - -class TusfilesNet(XFileSharingPro): - __name__ = "TusfilesNet" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?tusfiles\.net/(?P<ID>\w+)' - __version__ = "0.03" + +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo + + +class TusfilesNet(XFSHoster): + __name__ = "TusfilesNet" + __type__ = "hoster" + __version__ = "0.08" + + __pattern__ = r'https?://(?:www\.)?tusfiles\.net/\w{12}' + __description__ = """Tusfiles.net hoster plugin""" - __author_name__ = "Walter Purcaro" - __author_mail__ = "vuolter@gmail.com" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com"), + ("guidobelix", "guidobelix@hotmail.it")] + - HOSTER_NAME = "tusfiles.net" + HOSTER_DOMAIN = "tusfiles.net" - FILE_INFO_PATTERN = r'\](?P<N>.+) - (?P<S>[\d.]+) (?P<U>\w+)\[' - FILE_OFFLINE_PATTERN = r'>File Not Found|<Title>TusFiles - Fast Sharing Files!' + INFO_PATTERN = r'\](?P<N>.+) - (?P<S>[\d.,]+) (?P<U>[\w^_]+)\[' + OFFLINE_PATTERN = r'>File Not Found|<Title>TusFiles - Fast Sharing Files!|The file you are trying to download is no longer available' - SH_COOKIES = [(".tusfiles.net", "lang", "english")] def setup(self): - self.multiDL = False - self.chunkLimit = -1 + self.multiDL = False + self.chunkLimit = -1 self.resumeDownload = True + def handlePremium(self): + return self.handleFree() + + getInfo = create_getInfo(TusfilesNet) diff --git a/module/plugins/hoster/TwoSharedCom.py b/module/plugins/hoster/TwoSharedCom.py index 7881ca098..1dd67f974 100644 --- a/module/plugins/hoster/TwoSharedCom.py +++ b/module/plugins/hoster/TwoSharedCom.py @@ -6,29 +6,35 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class TwoSharedCom(SimpleHoster): - __name__ = "TwoSharedCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?2shared.com/(account/)?(download|get|file|document|photo|video|audio)/.*' - __version__ = "0.11" + __name__ = "TwoSharedCom" + __type__ = "hoster" + __version__ = "0.12" + + __pattern__ = r'http://(?:www\.)?2shared\.com/(account/)?(download|get|file|document|photo|video|audio)/.+' + __description__ = """2Shared.com hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + + NAME_PATTERN = r'<h1>(?P<N>.*)</h1>' + SIZE_PATTERN = r'<span class="dtitle">File size:</span>\s*(?P<S>[\d.,]+) (?P<U>[\w^_]+)' + OFFLINE_PATTERN = r'The file link that you requested is not valid\.|This file was deleted\.' + + LINK_PATTERN = r'window.location =\'(.+?)\';' - FILE_NAME_PATTERN = r'<h1>(?P<N>.*)</h1>' - FILE_SIZE_PATTERN = r'<span class="dtitle">File size:</span>\s*(?P<S>[0-9,.]+) (?P<U>[kKMG])i?B' - FILE_OFFLINE_PATTERN = r'The file link that you requested is not valid\.|This file was deleted\.' - DOWNLOAD_URL_PATTERN = r"window.location ='([^']+)';" def setup(self): - self.resumeDownload = self.multiDL = True + self.resumeDownload = True + self.multiDL = True + def handleFree(self): - found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) - if not found: - self.parseError('Download link') - link = found.group(1) - self.logDebug("Download URL %s" % link) + m = re.search(self.LINK_PATTERN, self.html) + if m is None: + self.error(_("Download link")) + link = m.group(1) self.download(link) diff --git a/module/plugins/hoster/UlozTo.py b/module/plugins/hoster/UlozTo.py index 282d4605b..6b84a5e1b 100644 --- a/module/plugins/hoster/UlozTo.py +++ b/module/plugins/hoster/UlozTo.py @@ -1,26 +1,11 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re import time -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + from module.common.json_layer import json_loads +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + def convertDecimalPrefix(m): # decimal prefixes used in filesize and traffic @@ -28,61 +13,71 @@ def convertDecimalPrefix(m): class UlozTo(SimpleHoster): - __name__ = "UlozTo" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?(uloz\.to|ulozto\.(cz|sk|net)|bagruj.cz|zachowajto.pl)/(?:live/)?(?P<id>\w+/[^/?]*)' - __version__ = "0.98" + __name__ = "UlozTo" + __type__ = "hoster" + __version__ = "1.01" + + __pattern__ = r'http://(?:www\.)?(uloz\.to|ulozto\.(cz|sk|net)|bagruj\.cz|zachowajto\.pl)/(?:live/)?(?P<ID>\w+/[^/?]*)' + __description__ = """Uloz.to hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" - - FILE_NAME_PATTERN = r'<title>(?P<N>[^<]+) \| Uloz.to</title>' - FILE_SIZE_PATTERN = r'<span id="fileSize">.*?(?P<S>[0-9.]+\s[kMG]?B)</span>' - FILE_INFO_PATTERN = r'<p>File <strong>(?P<N>[^<]+)</strong> is password protected</p>' - FILE_OFFLINE_PATTERN = r'<title>404 - Page not found</title>|<h1 class="h1">File (has been deleted|was banned)</h1>' - FILE_SIZE_REPLACEMENTS = [('([0-9.]+)\s([kMG])B', convertDecimalPrefix)] - FILE_URL_REPLACEMENTS = [(r"(?<=http://)([^/]+)", "www.ulozto.net")] - - ADULT_PATTERN = r'<form action="(?P<link>[^\"]*)" method="post" id="frm-askAgeForm">' - PASSWD_PATTERN = r'<div class="passwordProtectedFile">' + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + + INFO_PATTERN = r'<p>File <strong>(?P<N>[^<]+)</strong> is password protected</p>' + NAME_PATTERN = r'<title>(?P<N>[^<]+) \| Uloz\.to</title>' + SIZE_PATTERN = r'<span id="fileSize">.*?(?P<S>[\d.,]+\s[kMG]?B)</span>' + OFFLINE_PATTERN = r'<title>404 - Page not found</title>|<h1 class="h1">File (has been deleted|was banned)</h1>' + + URL_REPLACEMENTS = [(r"(?<=http://)([^/]+)", "www.ulozto.net")] + SIZE_REPLACEMENTS = [('([\d.]+)\s([kMG])B', convertDecimalPrefix)] + + ADULT_PATTERN = r'<form action="([^\"]*)" method="post" id="frm-askAgeForm">' + PASSWD_PATTERN = r'<div class="passwordProtectedFile">' VIPLINK_PATTERN = r'<a href="[^"]*\?disclaimer=1" class="linkVip">' - FREE_URL_PATTERN = r'<div class="freeDownloadForm"><form action="([^"]+)"' + TOKEN_PATTERN = r'<input type="hidden" name="_token_" .*?value="(.+?)"' + + FREE_URL_PATTERN = r'<div class="freeDownloadForm"><form action="([^"]+)"' PREMIUM_URL_PATTERN = r'<div class="downloadForm"><form action="([^"]+)"' - TOKEN_PATTERN = r'<input type="hidden" name="_token_" id="[^\"]*" value="(?P<token>[^\"]*)" />' + def setup(self): - self.multiDL = self.premium + self.multiDL = self.premium self.resumeDownload = True + def process(self, pyfile): pyfile.url = re.sub(r"(?<=http://)([^/]+)", "www.ulozto.net", pyfile.url) self.html = self.load(pyfile.url, decode=True, cookies=True) if re.search(self.ADULT_PATTERN, self.html): - self.logInfo("Adult content confirmation needed. Proceeding..") + self.logInfo(_("Adult content confirmation needed")) - found = re.search(self.TOKEN_PATTERN, self.html) - if not found: - self.parseError('TOKEN') - token = found.group(1) + m = re.search(self.TOKEN_PATTERN, self.html) + if m is None: + self.error(_("TOKEN_PATTERN not found")) + token = m.group(1) self.html = self.load(pyfile.url, get={"do": "askAgeForm-submit"}, post={"agree": "Confirm", "_token_": token}, cookies=True) - passwords = self.getPassword().splitlines() - while self.PASSWD_PATTERN in self.html: - if passwords: - password = passwords.pop(0) - self.logInfo("Password protected link, trying " + password) + if self.PASSWD_PATTERN in self.html: + password = self.getPassword() + + if password: + self.logInfo(_("Password protected link, trying ") + password) self.html = self.load(pyfile.url, get={"do": "passwordProtectedForm-submit"}, post={"password": password, "password_send": 'Send'}, cookies=True) + + if self.PASSWD_PATTERN in self.html: + self.fail(_("Incorrect password")) else: - self.fail("No or incorrect password") + self.fail(_("No password found")) if re.search(self.VIPLINK_PATTERN, self.html): self.html = self.load(pyfile.url, get={"disclaimer": "1"}) - self.file_info = self.getFileInfo() + self.getFileInfo() if self.premium and self.checkTrafficLeft(): self.handlePremium() @@ -91,58 +86,62 @@ class UlozTo(SimpleHoster): self.doCheckDownload() + def handleFree(self): action, inputs = self.parseHtmlForm('id="frm-downloadDialog-freeDownloadForm"') if not action or not inputs: - self.parseError("free download form") + self.error(_("Free download form not found")) - self.logDebug('inputs.keys() = ' + str(inputs.keys())) + self.logDebug("inputs.keys = " + str(inputs.keys())) # get and decrypt captcha - if all(key in inputs for key in ('captcha_value', 'captcha_id', 'captcha_key')): + if all(key in inputs for key in ("captcha_value", "captcha_id", "captcha_key")): # Old version - last seen 9.12.2013 self.logDebug('Using "old" version') captcha_value = self.decryptCaptcha("http://img.uloz.to/captcha/%s.png" % inputs['captcha_id']) - self.logDebug('CAPTCHA ID: ' + inputs['captcha_id'] + ', CAPTCHA VALUE: ' + captcha_value) + self.logDebug("CAPTCHA ID: " + inputs['captcha_id'] + ", CAPTCHA VALUE: " + captcha_value) inputs.update({'captcha_id': inputs['captcha_id'], 'captcha_key': inputs['captcha_key'], 'captcha_value': captcha_value}) - elif all(key in inputs for key in ('captcha_value', 'timestamp', 'salt', 'hash')): + elif all(key in inputs for key in ("captcha_value", "timestamp", "salt", "hash")): # New version - better to get new parameters (like captcha reload) because of image url - since 6.12.2013 self.logDebug('Using "new" version') xapca = self.load("http://www.ulozto.net/reloadXapca.php", get={"rnd": str(int(time.time()))}) - self.logDebug('xapca = ' + str(xapca)) + self.logDebug("xapca = " + str(xapca)) data = json_loads(xapca) captcha_value = self.decryptCaptcha(str(data['image'])) - self.logDebug('CAPTCHA HASH: ' + data['hash'] + ', CAPTCHA SALT: ' + str(data['salt']) + ', CAPTCHA VALUE: ' + captcha_value) + self.logDebug("CAPTCHA HASH: " + data['hash'], "CAPTCHA SALT: " + str(data['salt']), "CAPTCHA VALUE: " + captcha_value) inputs.update({'timestamp': data['timestamp'], 'salt': data['salt'], 'hash': data['hash'], 'captcha_value': captcha_value}) else: - self.parseError("CAPTCHA form changed") + self.error(_("CAPTCHA form changed")) self.multiDL = True self.download("http://www.ulozto.net" + action, post=inputs, cookies=True, disposition=True) + def handlePremium(self): self.download(self.pyfile.url + "?do=directDownload", disposition=True) #parsed_url = self.findDownloadURL(premium=True) #self.download(parsed_url, post={"download": "Download"}) + def findDownloadURL(self, premium=False): - msg = "%s link" % ("Premium" if premium else "Free") - found = re.search(self.PREMIUM_URL_PATTERN if premium else self.FREE_URL_PATTERN, self.html) - if not found: - self.parseError(msg) - parsed_url = "http://www.ulozto.net" + found.group(1) + msg = _("%s link" % ("Premium" if premium else "Free")) + m = re.search(self.PREMIUM_URL_PATTERN if premium else self.FREE_URL_PATTERN, self.html) + if m is None: + self.error(msg) + parsed_url = "http://www.ulozto.net" + m.group(1) self.logDebug("%s: %s" % (msg, parsed_url)) return parsed_url + def doCheckDownload(self): check = self.checkDownload({ "wrong_captcha": re.compile(r'<ul class="error">\s*<li>Error rewriting the text.</li>'), - "offline": re.compile(self.FILE_OFFLINE_PATTERN), + "offline": re.compile(self.OFFLINE_PATTERN), "passwd": self.PASSWD_PATTERN, "server_error": 'src="http://img.ulozto.cz/error403/vykricnik.jpg"', # paralell dl, server overload etc. "not_found": "<title>Ulož.to</title>" @@ -152,18 +151,18 @@ class UlozTo(SimpleHoster): #self.delStorage("captcha_id") #self.delStorage("captcha_text") self.invalidCaptcha() - self.retry(reason="Wrong captcha code") + self.retry(reason=_("Wrong captcha code")) elif check == "offline": self.offline() elif check == "passwd": - self.fail("Wrong password") + self.fail(_("Wrong password")) elif check == "server_error": - self.logError("Server error, try downloading later") + self.logError(_("Server error, try downloading later")) self.multiDL = False self.wait(1 * 60 * 60, True) self.retry() elif check == "not_found": - self.fail("Server error - file not downloadable") + self.fail(_("Server error - file not downloadable")) getInfo = create_getInfo(UlozTo) diff --git a/module/plugins/hoster/UloziskoSk.py b/module/plugins/hoster/UloziskoSk.py index d24e21779..0afa4e5a5 100644 --- a/module/plugins/hoster/UloziskoSk.py +++ b/module/plugins/hoster/UloziskoSk.py @@ -1,75 +1,65 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. +import re - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo - @author: zoidberg -""" -import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, PluginParseError +class UloziskoSk(SimpleHoster): + __name__ = "UloziskoSk" + __type__ = "hoster" + __version__ = "0.24" + __pattern__ = r'http://(?:www\.)?ulozisko\.sk/.+' -class UloziskoSk(SimpleHoster): - __name__ = "UloziskoSk" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?ulozisko.sk/.*' - __version__ = "0.23" __description__ = """Ulozisko.sk hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - URL_PATTERN = r'<form name = "formular" action = "([^"]+)" method = "post">' + + NAME_PATTERN = r'<div class="down1">(?P<N>[^<]+)</div>' + SIZE_PATTERN = ur'Veľkosť súboru: <strong>(?P<S>[\d.,]+) (?P<U>[\w^_]+)</strong><br />' + OFFLINE_PATTERN = ur'<span class = "red">Zadaný súbor neexistuje z jedného z nasledujúcich dôvodov:</span>' + + LINK_PATTERN = r'<form name = "formular" action = "([^"]+)" method = "post">' ID_PATTERN = r'<input type = "hidden" name = "id" value = "([^"]+)" />' - FILE_NAME_PATTERN = r'<div class="down1">(?P<N>[^<]+)</div>' - FILE_SIZE_PATTERN = ur'Veľkosť súboru: <strong>(?P<S>[0-9.]+) (?P<U>[kKMG])i?B</strong><br />' - CAPTCHA_PATTERN = r'<img src="(/obrazky/obrazky.php\?fid=[^"]+)" alt="" />' - FILE_OFFLINE_PATTERN = ur'<span class = "red">Zadaný súbor neexistuje z jedného z nasledujúcich dôvodov:</span>' + CAPTCHA_PATTERN = r'<img src="(/obrazky/obrazky\.php\?fid=[^"]+)" alt="" />' IMG_PATTERN = ur'<strong>PRE ZVÄČŠENIE KLIKNITE NA OBRÁZOK</strong><br /><a href = "([^"]+)">' + def process(self, pyfile): self.html = self.load(pyfile.url, decode=True) self.getFileInfo() - found = re.search(self.IMG_PATTERN, self.html) - if found: - url = "http://ulozisko.sk" + found.group(1) + m = re.search(self.IMG_PATTERN, self.html) + if m: + url = "http://ulozisko.sk" + m.group(1) self.download(url) else: self.handleFree() + def handleFree(self): - found = re.search(self.URL_PATTERN, self.html) - if found is None: - raise PluginParseError('URL') - parsed_url = 'http://www.ulozisko.sk' + found.group(1) + m = re.search(self.LINK_PATTERN, self.html) + if m is None: + self.error(_("LINK_PATTERN not found")) + parsed_url = 'http://www.ulozisko.sk' + m.group(1) - found = re.search(self.ID_PATTERN, self.html) - if found is None: - raise PluginParseError('ID') - id = found.group(1) + m = re.search(self.ID_PATTERN, self.html) + if m is None: + self.error(_("ID_PATTERN not found")) + id = m.group(1) - self.logDebug('URL:' + parsed_url + ' ID:' + id) + self.logDebug("URL:" + parsed_url + ' ID:' + id) - found = re.search(self.CAPTCHA_PATTERN, self.html) - if found is None: - raise PluginParseError('CAPTCHA') - captcha_url = 'http://www.ulozisko.sk' + found.group(1) + m = re.search(self.CAPTCHA_PATTERN, self.html) + if m is None: + self.error(_("CAPTCHA_PATTERN not found")) + captcha_url = 'http://www.ulozisko.sk' + m.group(1) captcha = self.decryptCaptcha(captcha_url, cookies=True) - self.logDebug('CAPTCHA_URL:' + captcha_url + ' CAPTCHA:' + captcha) + self.logDebug("CAPTCHA_URL:" + captcha_url + ' CAPTCHA:' + captcha) self.download(parsed_url, post={ "antispam": captcha, diff --git a/module/plugins/hoster/UnibytesCom.py b/module/plugins/hoster/UnibytesCom.py index 1a64146c4..8c39cce82 100644 --- a/module/plugins/hoster/UnibytesCom.py +++ b/module/plugins/hoster/UnibytesCom.py @@ -1,53 +1,46 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. +import re - @author: zoidberg -""" +from urlparse import urljoin -import re from pycurl import FOLLOWLOCATION + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class UnibytesCom(SimpleHoster): - __name__ = "UnibytesCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?unibytes\.com/[a-zA-Z0-9-._ ]{11}B' - __version__ = "0.1" + __name__ = "UnibytesCom" + __type__ = "hoster" + __version__ = "0.11" + + __pattern__ = r'https?://(?:www\.)?unibytes\.com/[\w .-]{11}B' + __description__ = """UniBytes.com hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + - FILE_INFO_PATTERN = r'<span[^>]*?id="fileName"[^>]*>(?P<N>[^>]+)</span>\s*\((?P<S>\d.*?)\)' - DOMAIN = 'http://www.unibytes.com' + HOSTER_DOMAIN = "unibytes.com" + + INFO_PATTERN = r'<span[^>]*?id="fileName"[^>]*>(?P<N>[^>]+)</span>\s*\((?P<S>\d.*?)\)' WAIT_PATTERN = r'Wait for <span id="slowRest">(\d+)</span> sec' - DOWNLOAD_LINK_PATTERN = r'<a href="([^"]+)">Download</a>' + LINK_PATTERN = r'<a href="([^"]+)">Download</a>' + def handleFree(self): + domain = "http://www.%s/" % self.HOSTER_DOMAIN action, post_data = self.parseHtmlForm('id="startForm"') self.req.http.c.setopt(FOLLOWLOCATION, 0) - for _ in xrange(8): + for _i in xrange(8): self.logDebug(action, post_data) - self.html = self.load(self.DOMAIN + action, post=post_data) + self.html = self.load(urljoin(domain, action), post=post_data) - found = re.search(r'location:\s*(\S+)', self.req.http.header, re.I) - if found: - url = found.group(1) + m = re.search(r'location:\s*(\S+)', self.req.http.header, re.I) + if m: + url = m.group(1) break if '>Somebody else is already downloading using your IP-address<' in self.html: @@ -55,9 +48,9 @@ class UnibytesCom(SimpleHoster): self.retry() if post_data['step'] == 'last': - found = re.search(self.DOWNLOAD_LINK_PATTERN, self.html) - if found: - url = found.group(1) + m = re.search(self.LINK_PATTERN, self.html) + if m: + url = m.group(1) self.correctCaptcha() break else: @@ -67,14 +60,13 @@ class UnibytesCom(SimpleHoster): action, post_data = self.parseHtmlForm('id="stepForm"') if last_step == 'timer': - found = re.search(self.WAIT_PATTERN, self.html) - self.wait(int(found.group(1)) if found else 60, False) - elif last_step in ('captcha', 'last'): - post_data['captcha'] = self.decryptCaptcha(self.DOMAIN + '/captcha.jpg') + m = re.search(self.WAIT_PATTERN, self.html) + self.wait(int(m.group(1)) if m else 60, False) + elif last_step in ("captcha", "last"): + post_data['captcha'] = self.decryptCaptcha(urljoin(domain, "/captcha.jpg")) else: - self.fail("No valid captcha code entered") + self.fail(_("No valid captcha code entered")) - self.logDebug('Download link: ' + url) self.req.http.c.setopt(FOLLOWLOCATION, 1) self.download(url) diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py index a0447d873..c84f1daa7 100644 --- a/module/plugins/hoster/UnrestrictLi.py +++ b/module/plugins/hoster/UnrestrictLi.py @@ -1,100 +1,88 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################ import re + from datetime import datetime, timedelta -from module.plugins.Hoster import Hoster from module.common.json_layer import json_loads +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo +from module.plugins.internal.SimpleHoster import secondsToMidnight -def secondsToMidnight(): - # Seconds until 00:10 GMT+2 - now = datetime.utcnow() + timedelta(hours=2) - if now.hour is 0 and now.minute < 10: - midnight = now - else: - midnight = now + timedelta(days=1) - midnight = midnight.replace(hour=0, minute=10, second=0, microsecond=0) - return int((midnight - now).total_seconds()) +class UnrestrictLi(MultiHoster): + __name__ = "UnrestrictLi" + __type__ = "hoster" + __version__ = "0.20" + __pattern__ = r'https?://(?:www\.)?(unrestrict|unr)\.li/dl/[\w^_]+' -class UnrestrictLi(Hoster): - __name__ = "UnrestrictLi" - __version__ = "0.11" - __type__ = "hoster" - __pattern__ = r'https?://(?:[^/]*\.)?(unrestrict|unr)\.li' __description__ = """Unrestrict.li hoster plugin""" - __author_name__ = "stickell" - __author_mail__ = "l.stickell@yahoo.it" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it")] + + + LOGIN_ACCOUNT = False + def setup(self): - self.chunkLimit = 16 + self.chunkLimit = 16 self.resumeDownload = True - def process(self, pyfile): - if re.match(self.__pattern__, pyfile.url): - new_url = pyfile.url - elif not self.account: - self.logError(_("Please enter your %s account or deactivate this plugin") % "Unrestrict.li") - self.fail("No Unrestrict.li account provided") + + def handleFree(self): + for _i in xrange(5): + page = self.load('https://unrestrict.li/unrestrict.php', + post={'link': self.pyfile.url, 'domain': 'long'}) + self.logDebug("JSON data: " + page) + if page != '': + break else: - self.logDebug("Old URL: %s" % pyfile.url) - for _ in xrange(5): - page = self.req.load('https://unrestrict.li/unrestrict.php', - post={'link': pyfile.url, 'domain': 'long'}) - self.logDebug("JSON data: " + page) - if page != '': - break - else: - self.logInfo("Unable to get API data, waiting 1 minute and retry") - self.retry(5, 60, "Unable to get API data") - - if 'Expired session' in page or ("You are not allowed to " - "download from this host" in page and self.premium): - self.account.relogin(self.user) - self.retry() - elif "File offline" in page: - self.offline() - elif "You are not allowed to download from this host" in page: - self.fail("You are not allowed to download from this host") - elif "You have reached your daily limit for this host" in page: - self.logInfo("Reached daily limit for this host. Waiting until 00:10 GMT+2") - self.retry(5, secondsToMidnight(), "Daily limit for this host reached") - elif "ERROR_HOSTER_TEMPORARILY_UNAVAILABLE" in page: - self.logInfo("Hoster temporarily unavailable, waiting 1 minute and retry") - self.retry(5, 60, "Hoster is temporarily unavailable") - page = json_loads(page) - new_url = page.keys()[0] - self.api_data = page[new_url] - - if new_url != pyfile.url: - self.logDebug("New URL: " + new_url) + self.logInfo(_("Unable to get API data, waiting 1 minute and retry")) + self.retry(5, 60, "Unable to get API data") + + if 'Expired session' in page or ("You are not allowed to " + "download from this host" in page and self.premium): + self.account.relogin(self.user) + self.retry() + + elif "File offline" in page: + self.offline() + + elif "You are not allowed to download from this host" in page: + self.fail(_("You are not allowed to download from this host")) + + elif "You have reached your daily limit for this host" in page: + self.logWarning(_("Reached daily limit for this host")) + self.retry(5, secondsToMidnight(gmt=2), "Daily limit for this host reached") + + elif "ERROR_HOSTER_TEMPORARILY_UNAVAILABLE" in page: + self.logInfo(_("Hoster temporarily unavailable, waiting 1 minute and retry")) + self.retry(5, 60, "Hoster is temporarily unavailable") + + page = json_loads(page) + self.link = page.keys()[0] + self.api_data = page[self.link] + + if self.link != self.pyfile.url: + self.logDebug("New URL: " + self.link) if hasattr(self, 'api_data'): self.setNameSize() - self.download(new_url, disposition=True) + + def checkFile(self): + super(UnrestrictLi, self).checkFile() if self.getConfig("history"): - self.load("https://unrestrict.li/history/&delete=all") - self.logInfo("Download history deleted") + self.load("https://unrestrict.li/history/", get={'delete': "all"}) + self.logInfo(_("Download history deleted")) + def setNameSize(self): if 'name' in self.api_data: self.pyfile.name = self.api_data['name'] if 'size' in self.api_data: self.pyfile.size = self.api_data['size'] + + +getInfo = create_getInfo(UnrestrictLi) diff --git a/module/plugins/hoster/UpleaCom.py b/module/plugins/hoster/UpleaCom.py new file mode 100644 index 000000000..7ae46ef38 --- /dev/null +++ b/module/plugins/hoster/UpleaCom.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- + +import re + +from urlparse import urljoin + +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo + + +class UpleaCom(XFSHoster): + __name__ = "UpleaCom" + __type__ = "hoster" + __version__ = "0.05" + + __pattern__ = r'https?://(?:www\.)?uplea\.com/dl/\w{15}' + + __description__ = """Uplea.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("Redleon", None)] + + + HOSTER_DOMAIN = "uplea.com" + + NAME_PATTERN = r'class="agmd size18">(?P<N>.+?)<' + SIZE_PATTERN = r'size14">(?P<S>[\d.,]+) (?P<U>[\w^_])</span>' + + OFFLINE_PATTERN = r'>You followed an invalid or expired link' + + LINK_PATTERN = r'"(http?://\w+\.uplea\.com/anonym/.*?)"' + + WAIT_PATTERN = r'timeText:([\d.]+),' + STEP_PATTERN = r'<a href="(/step/.+)">' + + + def setup(self): + self.multiDL = False + self.chunkLimit = 1 + self.resumeDownload = True + + + def handleFree(self): + m = re.search(self.STEP_PATTERN, self.html) + if m is None: + self.error("STEP_PATTERN not found") + + self.html = self.load(urljoin("http://uplea.com/", m.group(1))) + + m = re.search(self.WAIT_PATTERN, self.html) + if m: + self.wait(int(m.group(1)), True) + self.retry() + + m = re.search(self.LINK_PATTERN, self.html) + if m is None: + self.error("LINK_PATTERN not found") + + self.wait(15) + self.download(m.group(1), disposition=True) + + +getInfo = create_getInfo(UpleaCom) diff --git a/module/plugins/hoster/UploadStationCom.py b/module/plugins/hoster/UploadStationCom.py index b0229aba4..d987770fe 100644 --- a/module/plugins/hoster/UploadStationCom.py +++ b/module/plugins/hoster/UploadStationCom.py @@ -4,13 +4,16 @@ from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo class UploadStationCom(DeadHoster): - __name__ = "UploadStationCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?uploadstation\.com/file/(?P<id>[A-Za-z0-9]+)' + __name__ = "UploadStationCom" + __type__ = "hoster" __version__ = "0.52" + + __pattern__ = r'http://(?:www\.)?uploadstation\.com/file/(?P<ID>\w+)' + __description__ = """UploadStation.com hoster plugin""" - __author_name__ = ("fragonib", "zoidberg") - __author_mail__ = ("fragonib[AT]yahoo[DOT]es", "zoidberg@mujmail.cz") + __license__ = "GPLv3" + __authors__ = [("fragonib", "fragonib[AT]yahoo[DOT]es"), + ("zoidberg", "zoidberg@mujmail.cz")] getInfo = create_getInfo(UploadStationCom) diff --git a/module/plugins/hoster/UploadableCh.py b/module/plugins/hoster/UploadableCh.py new file mode 100644 index 000000000..b09e3ded4 --- /dev/null +++ b/module/plugins/hoster/UploadableCh.py @@ -0,0 +1,85 @@ +# -*- coding: utf-8 -*- + +import re + +from time import sleep + +from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + + +class UploadableCh(SimpleHoster): + __name__ = "UploadableCh" + __type__ = "hoster" + __version__ = "0.05" + + __pattern__ = r'http://(?:www\.)?uploadable\.ch/file/(?P<ID>\w+)' + + __description__ = """Uploadable.ch hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zapp-brannigan", "fuerst.reinje@web.de"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + FILE_URL_REPLACEMENTS = [(__pattern__ + ".*", r'http://www.uploadable.ch/file/\g<ID>')] + + FILE_INFO_PATTERN = r'div id=\"file_name\" title=.*>(?P<N>.+)<span class=\"filename_normal\">\((?P<S>[\d.]+) (?P<U>\w+)\)</span><' + + OFFLINE_PATTERN = r'>(File not available|This file is no longer available)' + TEMP_OFFLINE_PATTERN = r'<div class="icon_err">' + + WAIT_PATTERN = r'>Please wait.+?<' + + RECAPTCHA_KEY = "6LdlJuwSAAAAAPJbPIoUhyqOJd7-yrah5Nhim5S3" + + + def handleFree(self): + # Click the "free user" button and wait + a = self.load(self.pyfile.url, cookies=True, post={'downloadLink': "wait"}, decode=True) + self.logDebug(a) + + self.wait(30) + + # Make the recaptcha appear and show it the pyload interface + b = self.load(self.pyfile.url, cookies=True, post={'checkDownload': "check"}, decode=True) + self.logDebug(b) #: Expected output: {"success":"showCaptcha"} + + recaptcha = ReCaptcha(self) + + challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY) + + # Submit the captcha solution + self.load("http://www.uploadable.ch/checkReCaptcha.php", + cookies=True, + post={'recaptcha_challenge_field' : challenge, + 'recaptcha_response_field' : response, + 'recaptcha_shortencode_field': self.info['pattern']['ID']}, + decode=True) + + self.wait(3) + + # Get ready for downloading + self.load(self.pyfile.url, cookies=True, post={'downloadLink': "show"}, decode=True) + + self.wait(3) + + # Download the file + self.download(self.pyfile.url, cookies=True, post={'download': "normal"}, disposition=True) + + + def checkFile(self): + super(UploadableCh, self).checkFile() + + check = self.checkDownload({'wait_or_reconnect': re.compile("Please wait for"), + 'is_html' : re.compile("<head>")}) + + if check == "wait_or_reconnect": + self.logInfo("Downloadlimit reached, please wait or reconnect") + self.wait(60 * 60, True) + self.retry() + + elif check == "is_html": + self.error("Downloaded file is an html file") + + +getInfo = create_getInfo(UploadableCh) diff --git a/module/plugins/hoster/UploadboxCom.py b/module/plugins/hoster/UploadboxCom.py new file mode 100644 index 000000000..031c5f761 --- /dev/null +++ b/module/plugins/hoster/UploadboxCom.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo + + +class UploadboxCom(DeadHoster): + __name__ = "Uploadbox" + __type__ = "hoster" + __version__ = "0.05" + + __pattern__ = r'http://(?:www\.)?uploadbox\.com/files/.+' + + __description__ = """UploadBox.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + +getInfo = create_getInfo(UploadboxCom) diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index 6d17bcbd9..833468a80 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -1,18 +1,19 @@ # -*- coding: utf-8 -*- - -# Test links (random.bin): +# +# Test links: # http://ul.to/044yug9o # http://ul.to/gzfhd0xs import re -from time import sleep -from module.utils import html_unescape, parseFileSize +from time import sleep -from module.plugins.Hoster import Hoster from module.network.RequestFactory import getURL +from module.plugins.Hoster import Hoster from module.plugins.Plugin import chunks from module.plugins.internal.CaptchaService import ReCaptcha +from module.utils import html_unescape, parseFileSize + key = "bGhGMkllZXByd2VEZnU5Y2NXbHhYVlZ5cEE1bkEzRUw=".decode('base64') @@ -30,10 +31,10 @@ def getAPIData(urls): for i, url in enumerate(urls): id = getID(url) - post["id_%s" % i] = id + post['id_%s' % i] = id idMap[id] = url - for _ in xrange(5): + for _i in xrange(5): api = unicode(getURL("http://uploaded.net/api/filemultiple", post=post, decode=False), 'iso-8859-1') if api != "can't find request": break @@ -54,17 +55,22 @@ def getAPIData(urls): def parseFileInfo(self, url='', html=''): if not html and hasattr(self, "html"): html = self.html - name, size, status, found, fileid = url, 0, 3, None, None - if re.search(self.FILE_OFFLINE_PATTERN, html): + name = url + size = 0 + fileid = None + + if re.search(self.OFFLINE_PATTERN, html): # File offline status = 1 else: - found = re.search(self.FILE_INFO_PATTERN, html) - if found: - name, fileid = html_unescape(found.group('N')), found.group('ID') - size = parseFileSize(found.group('S')) + m = re.search(self.INFO_PATTERN, html) + if m: + name, fileid = html_unescape(m.group('N')), m.group('ID') + size = parseFileSize(m.group('S')) status = 2 + else: + status = 3 return name, size, status, fileid @@ -86,26 +92,34 @@ def getInfo(urls): class UploadedTo(Hoster): - __name__ = "UploadedTo" - __type__ = "hoster" + __name__ = "UploadedTo" + __type__ = "hoster" + __version__ = "0.75" + __pattern__ = r'https?://(?:www\.)?(uploaded\.(to|net)|ul\.to)(/file/|/?\?id=|.*?&id=|/)(?P<ID>\w+)' - __version__ = "0.72" + __description__ = """Uploaded.net hoster plugin""" - __author_name__ = ("spoob", "mkaay", "zoidberg", "netpok", "stickell") - __author_mail__ = ("spoob@pyload.org", "mkaay@mkaay.de", "zoidberg@mujmail.cz", - "netpok@gmail.com", "l.stickell@yahoo.it") + __license__ = "GPLv3" + __authors__ = [("spoob", "spoob@pyload.org"), + ("mkaay", "mkaay@mkaay.de"), + ("zoidberg", "zoidberg@mujmail.cz"), + ("netpok", "netpok@gmail.com"), + ("stickell", "l.stickell@yahoo.it")] + + + INFO_PATTERN = r'<a href="file/(?P<ID>\w+)" id="filename">(?P<N>[^<]+)</a> \s*<small[^>]*>(?P<S>[^<]+)</small>' + OFFLINE_PATTERN = r'<small class="cL">Error: 404</small>' + DL_LIMIT_PATTERN = r'You have reached the max. number of possible free downloads for this hour' - FILE_INFO_PATTERN = r'<a href="file/(?P<ID>\w+)" id="filename">(?P<N>[^<]+)</a> \s*<small[^>]*>(?P<S>[^<]+)</small>' - FILE_OFFLINE_PATTERN = r'<small class="cL">Error: 404</small>' - DL_LIMIT_PATTERN = "You have reached the max. number of possible free downloads for this hour" def setup(self): - self.multiDL = self.resumeDownload = self.premium + self.multiDL = self.resumeDownload = self.premium self.chunkLimit = 1 # critical problems with more chunks self.fileID = getID(self.pyfile.url) self.pyfile.url = "http://uploaded.net/file/%s" % self.fileID + def process(self, pyfile): self.load("http://uploaded.net/language/en", just_header=True) @@ -114,7 +128,7 @@ class UploadedTo(Hoster): # TODO: fallback to parse from site, because api sometimes delivers wrong status codes if not api: - self.logWarning("No response for API call") + self.logWarning(_("No response for API call")) self.html = unicode(self.load(pyfile.url, decode=False), 'iso-8859-1') name, size, status, self.fileID = parseFileInfo(self) @@ -124,7 +138,8 @@ class UploadedTo(Hoster): elif status == 2: pyfile.name, pyfile.size = name, size else: - self.fail('Parse error - file info') + self.error(_("file info")) + elif api == 'Access denied': self.fail(_("API key invalid")) @@ -145,83 +160,82 @@ class UploadedTo(Hoster): else: self.handleFree() + def handlePremium(self): info = self.account.getAccountInfo(self.user, True) self.logDebug("%(name)s: Use Premium Account (%(left)sGB left)" % {"name": self.__name__, - "left": info["trafficleft"] / 1024 / 1024}) - if int(self.data[1]) / 1024 > info["trafficleft"]: - self.logInfo(_("%s: Not enough traffic left" % self.__name__)) + "left": info['trafficleft'] / 1024 / 1024}) + if int(self.data[1]) / 1024 > info['trafficleft']: + self.logInfo(_("Not enough traffic left")) self.account.empty(self.user) self.resetAccount() self.fail(_("Traffic exceeded")) header = self.load("http://uploaded.net/file/%s" % self.fileID, just_header=True) - if "location" in header: + if 'location' in header: #Direct download - print "Direct Download: " + header['location'] + self.logDebug("Direct download link detected") self.download(header['location']) else: #Indirect download self.html = self.load("http://uploaded.net/file/%s" % self.fileID) - found = re.search(r'<div class="tfree".*\s*<form method="post" action="(.*?)"', self.html) - if not found: - self.fail("Download URL not found. Try to enable direct downloads.") - url = found.group(1) - print "Premium URL: " + url + m = re.search(r'<div class="tfree".*\s*<form method="post" action="(.*?)"', self.html) + if m is None: + self.fail(_("Download URL not m. Try to enable direct downloads")) + url = m.group(1) self.download(url, post={}) + def handleFree(self): self.html = self.load(self.pyfile.url, decode=True) if 'var free_enabled = false;' in self.html: - self.logError("Free-download capacities exhausted.") - self.retry(max_tries=24, wait_time=5 * 60) + self.logError(_("Free-download capacities exhausted")) + self.retry(24, 5 * 60) - found = re.search(r"Current waiting period: <span>(\d+)</span> seconds", self.html) - if not found: - self.fail("File not downloadable for free users") - self.setWait(int(found.group(1))) + m = re.search(r"Current waiting period: <span>(\d+)</span> seconds", self.html) + if m is None: + self.fail(_("File not downloadable for free users")) + self.setWait(int(m.group(1))) - js = self.load("http://uploaded.net/js/download.js", decode=True) - - challengeId = re.search(r'Recaptcha\.create\("([^"]+)', js) + self.html = self.load("http://uploaded.net/js/download.js", decode=True) url = "http://uploaded.net/io/ticket/captcha/%s" % self.fileID downloadURL = "" - for _ in xrange(5): - re_captcha = ReCaptcha(self) - challenge, result = re_captcha.challenge(challengeId.group(1)) - options = {"recaptcha_challenge_field": challenge, "recaptcha_response_field": result} + recaptcha = ReCaptcha(self) + + for _i in xrange(5): + challenge, response = recaptcha.challenge() + options = {"recaptcha_challenge_field": challenge, "recaptcha_response_field": response} self.wait() result = self.load(url, post=options) - self.logDebug("result: %s" % result) + self.logDebug("Result: %s" % result) if "limit-size" in result: - self.fail("File too big for free download") + self.fail(_("File too big for free download")) elif "limit-slot" in result: # Temporary restriction so just wait a bit self.setWait(30 * 60, True) self.wait() self.retry() elif "limit-parallel" in result: - self.fail("Cannot download in parallel") - elif self.DL_LIMIT_PATTERN in result: # limit-dl + self.fail(_("Cannot download in parallel")) + elif "limit-dl" in result or self.DL_LIMIT_PATTERN in result: # limit-dl self.setWait(3 * 60 * 60, True) self.wait() self.retry() - elif 'err:"captcha"' in result: - self.logError("ul.net captcha is disabled") + elif '"err":"captcha"' in result: self.invalidCaptcha() elif "type:'download'" in result: self.correctCaptcha() downloadURL = re.search("url:'([^']+)", result).group(1) break else: - self.fail("Unknown error '%s'") + self.error(_("Unknown error: %s") % result) if not downloadURL: - self.fail("No Download url retrieved/all captcha attempts failed") + self.fail(_("No Download url retrieved/all captcha attempts failed")) self.download(downloadURL, disposition=True) check = self.checkDownload({"limit-dl": self.DL_LIMIT_PATTERN}) diff --git a/module/plugins/hoster/UploadhereCom.py b/module/plugins/hoster/UploadhereCom.py new file mode 100644 index 000000000..8da30be46 --- /dev/null +++ b/module/plugins/hoster/UploadhereCom.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo + + +class UploadhereCom(DeadHoster): + __name__ = "UploadhereCom" + __type__ = "hoster" + __version__ = "0.12" + + __pattern__ = r'http://(?:www\.)?uploadhere\.com/\w{10}' + + __description__ = """Uploadhere.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + +getInfo = create_getInfo(UploadhereCom) diff --git a/module/plugins/hoster/UploadheroCom.py b/module/plugins/hoster/UploadheroCom.py index 6ee3dbeba..189079017 100644 --- a/module/plugins/hoster/UploadheroCom.py +++ b/module/plugins/hoster/UploadheroCom.py @@ -1,90 +1,81 @@ # -*- coding: utf-8 -*- - -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - -# Test link (random.bin): +# +# Test links: # http://uploadhero.co/dl/wQBRAVSM import re + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class UploadheroCom(SimpleHoster): - __name__ = "UploadheroCom" - __type__ = "hoster" + __name__ = "UploadheroCom" + __type__ = "hoster" + __version__ = "0.16" + __pattern__ = r'http://(?:www\.)?uploadhero\.com?/dl/\w+' - __version__ = "0.15" + __description__ = """UploadHero.co plugin""" - __author_name__ = ("mcmyst", "zoidberg") - __author_mail__ = ("mcmyst@hotmail.fr", "zoidberg@mujmail.cz") + __license__ = "GPLv3" + __authors__ = [("mcmyst", "mcmyst@hotmail.fr"), + ("zoidberg", "zoidberg@mujmail.cz")] + - SH_COOKIES = [("http://uploadhero.co", "lang", "en")] - FILE_NAME_PATTERN = r'<div class="nom_de_fichier">(?P<N>.*?)</div>' - FILE_SIZE_PATTERN = r'Taille du fichier : </span><strong>(?P<S>.*?)</strong>' - FILE_OFFLINE_PATTERN = r'<p class="titre_dl_2">|<div class="raison"><strong>Le lien du fichier ci-dessus n\'existe plus.' + NAME_PATTERN = r'<div class="nom_de_fichier">(?P<N>.*?)</div>' + SIZE_PATTERN = r'Taille du fichier : </span><strong>(?P<S>.*?)</strong>' + OFFLINE_PATTERN = r'<p class="titre_dl_2">|<div class="raison"><strong>Le lien du fichier ci-dessus n\'existe plus.' - DOWNLOAD_URL_PATTERN = r'<a href="([^"]+)" id="downloadnow"' + COOKIES = [("uploadhero.co", "lang", "en")] - IP_BLOCKED_PATTERN = r'href="(/lightbox_block_download.php\?min=.*?)"' + IP_BLOCKED_PATTERN = r'href="(/lightbox_block_download\.php\?min=.*?)"' IP_WAIT_PATTERN = r'<span id="minutes">(\d+)</span>.*\s*<span id="seconds">(\d+)</span>' - CAPTCHA_PATTERN = r'"(/captchadl\.php\?[a-z0-9]+)"' - FREE_URL_PATTERN = r'var magicomfg = \'<a href="(http://[^<>"]*?)"|"(http://storage\d+\.uploadhero\.co/\?d=[A-Za-z0-9]+/[^<>"/]+)"' + CAPTCHA_PATTERN = r'"(/captchadl\.php\?\w+)"' + FREE_URL_PATTERN = r'var magicomfg = \'<a href="(http://[^<>"]*?)"|"(http://storage\d+\.uploadhero\.co/\?d=\w+/[^<>"/]+)"' + PREMIUM_URL_PATTERN = r'<a href="([^"]+)" id="downloadnow"' + def handleFree(self): self.checkErrors() - found = re.search(self.CAPTCHA_PATTERN, self.html) - if not found: - self.parseError("Captcha URL") - captcha_url = "http://uploadhero.co" + found.group(1) + m = re.search(self.CAPTCHA_PATTERN, self.html) + if m is None: + self.error(_("CAPTCHA_PATTERN not found")) + captcha_url = "http://uploadhero.co" + m.group(1) - for _ in xrange(5): + for _i in xrange(5): captcha = self.decryptCaptcha(captcha_url) self.html = self.load(self.pyfile.url, get={"code": captcha}) - found = re.search(self.FREE_URL_PATTERN, self.html) - if found: + m = re.search(self.FREE_URL_PATTERN, self.html) + if m: self.correctCaptcha() - download_url = found.group(1) or found.group(2) + download_url = m.group(1) or m.group(2) break else: self.invalidCaptcha() else: - self.fail("No valid captcha code entered") + self.fail(_("No valid captcha code entered")) self.download(download_url) + def handlePremium(self): self.logDebug("%s: Use Premium Account" % self.__name__) - self.html = self.load(self.pyfile.url) - link = re.search(self.DOWNLOAD_URL_PATTERN, self.html).group(1) - self.logDebug("Downloading link : '%s'" % link) + link = re.search(self.PREMIUM_URL_PATTERN, self.html).group(1) self.download(link) + def checkErrors(self): - found = re.search(self.IP_BLOCKED_PATTERN, self.html) - if found: - self.html = self.load("http://uploadhero.co%s" % found.group(1)) + m = re.search(self.IP_BLOCKED_PATTERN, self.html) + if m: + self.html = self.load("http://uploadhero.co%s" % m.group(1)) - found = re.search(self.IP_WAIT_PATTERN, self.html) - wait_time = (int(found.group(1)) * 60 + int(found.group(2))) if found else 5 * 60 + m = re.search(self.IP_WAIT_PATTERN, self.html) + wait_time = (int(m.group(1)) * 60 + int(m.group(2))) if m else 5 * 60 self.wait(wait_time, True) self.retry() + self.info.pop('error', None) + getInfo = create_getInfo(UploadheroCom) diff --git a/module/plugins/hoster/UploadingCom.py b/module/plugins/hoster/UploadingCom.py index f3cc7a1c6..b163f2252 100644 --- a/module/plugins/hoster/UploadingCom.py +++ b/module/plugins/hoster/UploadingCom.py @@ -1,63 +1,53 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: jeix -""" - import re + from pycurl import HTTPHEADER -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, timestamp from module.common.json_layer import json_loads +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, timestamp class UploadingCom(SimpleHoster): - __name__ = "UploadingCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?uploading\.com/files/(?:get/)?(?P<ID>[\w\d]+)' - __version__ = "0.34" + __name__ = "UploadingCom" + __type__ = "hoster" + __version__ = "0.39" + + __pattern__ = r'http://(?:www\.)?uploading\.com/files/(?:get/)?(?P<ID>\w+)' + __description__ = """Uploading.com hoster plugin""" - __author_name__ = ("jeix", "mkaay", "zoidberg") - __author_mail__ = ("jeix@hasnomail.de", "mkaay@mkaay.de", "zoidberg@mujmail.cz") + __license__ = "GPLv3" + __authors__ = [("jeix", "jeix@hasnomail.de"), + ("mkaay", "mkaay@mkaay.de"), + ("zoidberg", "zoidberg@mujmail.cz")] - FILE_NAME_PATTERN = r'id="file_title">(?P<N>.+)</' - FILE_SIZE_PATTERN = r'size tip_container">(?P<S>[\d.]+) (?P<U>\w+)<' - FILE_OFFLINE_PATTERN = r'Page not found!' - def process(self, pyfile): - # set lang to english - self.req.cj.setCookie("uploading.com", "lang", "1") - self.req.cj.setCookie("uploading.com", "language", "1") - self.req.cj.setCookie("uploading.com", "setlang", "en") - self.req.cj.setCookie("uploading.com", "_lang", "en") + NAME_PATTERN = r'id="file_title">(?P<N>.+)</' + SIZE_PATTERN = r'size tip_container">(?P<S>[\d.,]+) (?P<U>[\w^_]+)<' + OFFLINE_PATTERN = r'(Page|file) not found' + + COOKIES = [("uploading.com", "lang", "1"), + (".uploading.com", "language", "1"), + (".uploading.com", "setlang", "en"), + (".uploading.com", "_lang", "en")] + + def process(self, pyfile): if not "/get/" in pyfile.url: pyfile.url = pyfile.url.replace("/files", "/files/get") self.html = self.load(pyfile.url, decode=True) - self.file_info = self.getFileInfo() + self.getFileInfo() if self.premium: self.handlePremium() else: self.handleFree() + def handlePremium(self): postData = {'action': 'get_link', - 'code': self.file_info['ID'], + 'code': self.info['pattern']['ID'], 'pass': 'undefined'} self.html = self.load('http://uploading.com/files/get/?JsHttpRequest=%d-xml' % timestamp(), post=postData) @@ -66,46 +56,48 @@ class UploadingCom(SimpleHoster): url = url.group(1).replace("\\/", "/") self.download(url) - raise Exception("Plugin defect.") + raise Exception("Plugin defect") + def handleFree(self): - found = re.search('<h2>((Daily )?Download Limit)</h2>', self.html) - if found: - self.pyfile.error = found.group(1) + m = re.search('<h2>((Daily )?Download Limit)</h2>', self.html) + if m: + self.pyfile.error = m.group(1) self.logWarning(self.pyfile.error) - self.retry(max_tries=6, wait_time=6 * 60 * 60 if found.group(2) else 15 * 60, reason=self.pyfile.error) + self.retry(6, (6 * 60 if m.group(2) else 15) * 60, self.pyfile.error) ajax_url = "http://uploading.com/files/get/?ajax" self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) self.req.http.lastURL = self.pyfile.url - response = json_loads(self.load(ajax_url, post={'action': 'second_page', 'code': self.file_info['ID']})) - if 'answer' in response and 'wait_time' in response['answer']: - wait_time = int(response['answer']['wait_time']) - self.logInfo("%s: Waiting %d seconds." % (self.__name__, wait_time)) + res = json_loads(self.load(ajax_url, post={'action': 'second_page', 'code': self.info['pattern']['ID']})) + + if 'answer' in res and 'wait_time' in res['answer']: + wait_time = int(res['answer']['wait_time']) + self.logInfo(_("Waiting %d seconds") % wait_time) self.wait(wait_time) else: - self.pluginParseError("AJAX/WAIT") + self.error(_("No AJAX/WAIT")) + + res = json_loads(self.load(ajax_url, post={'action': 'get_link', 'code': self.info['pattern']['ID'], 'pass': 'false'})) - response = json_loads( - self.load(ajax_url, post={'action': 'get_link', 'code': self.file_info['ID'], 'pass': 'false'})) - if 'answer' in response and 'link' in response['answer']: - url = response['answer']['link'] + if 'answer' in res and 'link' in res['answer']: + url = res['answer']['link'] else: - self.pluginParseError("AJAX/URL") + self.error(_("No AJAX/URL")) self.html = self.load(url) - found = re.search(r'<form id="file_form" action="(.*?)"', self.html) - if found: - url = found.group(1) + m = re.search(r'<form id="file_form" action="(.*?)"', self.html) + if m: + url = m.group(1) else: - self.pluginParseError("URL") + self.error(_("No URL")) self.download(url) check = self.checkDownload({"html": re.compile("\A<!DOCTYPE html PUBLIC")}) if check == "html": - self.logWarning("Redirected to a HTML page, wait 10 minutes and retry") + self.logWarning(_("Redirected to a HTML page, wait 10 minutes and retry")) self.wait(10 * 60, True) diff --git a/module/plugins/hoster/UploadkingCom.py b/module/plugins/hoster/UploadkingCom.py new file mode 100644 index 000000000..743e700eb --- /dev/null +++ b/module/plugins/hoster/UploadkingCom.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo + + +class UploadkingCom(DeadHoster): + __name__ = "UploadkingCom" + __type__ = "hoster" + __version__ = "0.14" + + __pattern__ = r'http://(?:www\.)?uploadking\.com/\w{10}' + + __description__ = """UploadKing.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + +getInfo = create_getInfo(UploadkingCom) diff --git a/module/plugins/hoster/UpstoreNet.py b/module/plugins/hoster/UpstoreNet.py index 9d1c4b3dd..25c424f1f 100644 --- a/module/plugins/hoster/UpstoreNet.py +++ b/module/plugins/hoster/UpstoreNet.py @@ -1,32 +1,38 @@ # -*- coding: utf-8 -*- + import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class UpstoreNet(SimpleHoster): - __name__ = "UpstoreNet" - __type__ = "hoster" - __pattern__ = r"https?://(?:www\.)?upstore\.net/" - __version__ = "0.02" + __name__ = "UpstoreNet" + __type__ = "hoster" + __version__ = "0.03" + + __pattern__ = r'https?://(?:www\.)?upstore\.net/' + __description__ = """Upstore.Net File Download Hoster""" - __author_name__ = ("igel") + __license__ = "GPLv3" + __authors__ = [("igel", "igelkun@myopera.com")] + - FILE_INFO_PATTERN = r'<div class="comment">.*?</div>\s*\n<h2 style="margin:0">(?P<N>.*?)</h2>\s*\n<div class="comment">\s*\n\s*(?P<S>[\d.]+) (?P<U>\w+)' - FILE_OFFLINE_PATTERN = r'<span class="error">File not found</span>' + INFO_PATTERN = r'<div class="comment">.*?</div>\s*\n<h2 style="margin:0">(?P<N>.*?)</h2>\s*\n<div class="comment">\s*\n\s*(?P<S>[\d.,]+) (?P<U>[\w^_]+)' + OFFLINE_PATTERN = r'<span class="error">File not found</span>' - WAIT_PATTERN = r"var sec = (\d+)" + WAIT_PATTERN = r'var sec = (\d+)' CHASH_PATTERN = r'<input type="hidden" name="hash" value="([^"]*)">' - DIRECT_LINK_PATTERN = r'<a href="(https?://.*?)" target="_blank"><b>' + LINK_PATTERN = r'<a href="(https?://.*?)" target="_blank"><b>' + def handleFree(self): # STAGE 1: get link to continue m = re.search(self.CHASH_PATTERN, self.html) - if not m: - self.parseError("could not detect hash") + if m is None: + self.error(_("CHASH_PATTERN not found")) chash = m.group(1) - self.logDebug("read hash " + chash) + self.logDebug("Read hash " + chash) # continue to stage2 post_data = {'hash': chash, 'free': 'Slow download'} self.html = self.load(self.pyfile.url, post=post_data, decode=True) @@ -34,36 +40,33 @@ class UpstoreNet(SimpleHoster): # STAGE 2: solv captcha and wait # first get the infos we need: recaptcha key and wait time recaptcha = ReCaptcha(self) - if not recaptcha.detect_key(self.html): - self.parseError("could not find recaptcha pattern") - self.logDebug("using captcha key " + recaptcha.recaptcha_key) + # try the captcha 5 times for i in xrange(5): m = re.search(self.WAIT_PATTERN, self.html) - if not m: - self.parseError("could not find wait pattern") - wait_time = m.group(1) + if m is None: + self.error(_("Wait pattern not found")) + wait_time = int(m.group(1)) # then, do the waiting self.wait(wait_time) # then, handle the captcha - challenge, code = recaptcha.challenge() - post_data['recaptcha_challenge_field'] = challenge - post_data['recaptcha_response_field'] = code + challenge, response = recaptcha.challenge() + post_data.update({'recaptcha_challenge_field': challenge, + 'recaptcha_response_field' : response}) self.html = self.load(self.pyfile.url, post=post_data, decode=True) # STAGE 3: get direct link - m = re.search(self.DIRECT_LINK_PATTERN, self.html, re.DOTALL) + m = re.search(self.LINK_PATTERN, self.html, re.S) if m: break - if not m: - self.parseError("could not detect direct link") + if m is None: + self.error(_("Download link not found")) direct = m.group(1) - self.logDebug('found direct link: ' + direct) self.download(direct, disposition=True) diff --git a/module/plugins/hoster/UptoboxCom.py b/module/plugins/hoster/UptoboxCom.py index e403425c1..21d781f55 100644 --- a/module/plugins/hoster/UptoboxCom.py +++ b/module/plugins/hoster/UptoboxCom.py @@ -1,81 +1,34 @@ # -*- coding: utf-8 -*- -############################################################################### -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -# @author: Walter Purcaro -############################################################################### -import re -from urllib import unquote +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo -from module.plugins.internal.CaptchaService import ReCaptcha, SolveMedia -from module.utils import html_unescape +class UptoboxCom(XFSHoster): + __name__ = "UptoboxCom" + __type__ = "hoster" + __version__ = "0.16" + + __pattern__ = r'https?://(?:www\.)?uptobox\.com/\w{12}' -class UptoboxCom(XFileSharingPro): - __name__ = "UptoboxCom" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?uptobox\.com/\w+' - __version__ = "0.09" __description__ = """Uptobox.com hoster plugin""" - __author_name__ = "Walter Purcaro" - __author_mail__ = "vuolter@gmail.com" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = "uptobox.com" - HOSTER_NAME = "uptobox.com" + INFO_PATTERN = r'"para_title">(?P<N>.+) \((?P<S>[\d.,]+) (?P<U>[\w^_]+)\)' + OFFLINE_PATTERN = r'>(File not found|Access Denied|404 Not Found)' - FILE_INFO_PATTERN = r'"para_title">(?P<N>.+) \((?P<S>[\d\.]+) (?P<U>\w+)\)' - FILE_OFFLINE_PATTERN = r'>(File not found|Access Denied|404 Not Found)' - TEMP_OFFLINE_PATTERN = r'>This server is in maintenance mode' + LINK_PATTERN = r'"(https?://\w+\.uptobox\.com/d/.*?)"' - WAIT_PATTERN = r'>(\d+)</span> seconds<' + ERROR_PATTERN = r'>(You have to wait.+till next download.)<' #@TODO: Check XFSHoster ERROR_PATTERN - DIRECT_LINK_PATTERN = r'"(https?://\w+\.uptobox\.com/d/.*?)"' - def handleCaptcha(self, inputs): - found = re.search(self.SOLVEMEDIA_PATTERN, self.html) - if found: - captcha_key = found.group(1) - captcha = SolveMedia(self) - inputs['adcopy_challenge'], inputs['adcopy_response'] = captcha.challenge(captcha_key) - return 4 - else: - found = re.search(self.CAPTCHA_URL_PATTERN, self.html) - if found: - captcha_url = found.group(1) - inputs['code'] = self.decryptCaptcha(captcha_url) - return 2 - else: - found = re.search(self.CAPTCHA_DIV_PATTERN, self.html, re.DOTALL) - if found: - captcha_div = found.group(1) - self.logDebug(captcha_div) - numerals = re.findall(r'<span.*?padding-left\s*:\s*(\d+).*?>(\d)</span>', - html_unescape(captcha_div)) - inputs['code'] = "".join([a[1] for a in sorted(numerals, key=lambda num: int(num[0]))]) - self.logDebug("CAPTCHA", inputs['code'], numerals) - return 3 - else: - found = re.search(self.RECAPTCHA_URL_PATTERN, self.html) - if found: - recaptcha_key = unquote(found.group(1)) - self.logDebug("RECAPTCHA KEY: %s" % recaptcha_key) - recaptcha = ReCaptcha(self) - inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge( - recaptcha_key) - return 1 - return 0 + def setup(self): + self.multiDL = True + self.chunkLimit = 1 + self.resumeDownload = True getInfo = create_getInfo(UptoboxCom) diff --git a/module/plugins/hoster/VeehdCom.py b/module/plugins/hoster/VeehdCom.py index 22fc4b207..d894dab24 100644 --- a/module/plugins/hoster/VeehdCom.py +++ b/module/plugins/hoster/VeehdCom.py @@ -1,27 +1,29 @@ # -*- coding: utf-8 -*- import re + from module.plugins.Hoster import Hoster class VeehdCom(Hoster): - __name__ = 'VeehdCom' - __type__ = 'hoster' + __name__ = "VeehdCom" + __type__ = "hoster" + __version__ = "0.23" + __pattern__ = r'http://veehd\.com/video/\d+_\S+' __config__ = [("filename_spaces", "bool", "Allow spaces in filename", False), ("replacement_char", "str", "Filename replacement character", "_")] - __version__ = '0.23' + __description__ = """Veehd.com hoster plugin""" - __author_name__ = "cat" - __author_mail__ = "cat@pyload" + __license__ = "GPLv3" + __authors__ = [("cat", "cat@pyload")] - def _debug(self, msg): - self.logDebug('[%s] %s' % (self.__name__, msg)) def setup(self): self.multiDL = True self.req.canContinue = True + def process(self, pyfile): self.download_html() if not self.file_exists(): @@ -30,48 +32,50 @@ class VeehdCom(Hoster): pyfile.name = self.get_file_name() self.download(self.get_file_url()) + def download_html(self): url = self.pyfile.url - self._debug("Requesting page: %s" % (repr(url),)) + self.logDebug("Requesting page: %s" % url) self.html = self.load(url) + def file_exists(self): - if self.html is None: + if not self.html: self.download_html() if '<title>Veehd</title>' in self.html: return False return True + def get_file_name(self): - if self.html is None: + if not self.html: self.download_html() - match = re.search(r'<title[^>]*>([^<]+) on Veehd</title>', self.html) - if not match: - self.fail("video title not found") - name = match.group(1) + m = re.search(r'<title[^>]*>([^<]+) on Veehd</title>', self.html) + if m is None: + self.error(_("Video title not found")) + + name = m.group(1) # replace unwanted characters in filename if self.getConfig('filename_spaces'): - pattern = '[^0-9A-Za-z\.\ ]+' + pattern = '[^\w ]+' else: - pattern = '[^0-9A-Za-z\.]+' + pattern = '[^\w.]+' + + return re.sub(pattern, self.getConfig('replacement_char'), name) + '.avi' - name = re.sub(pattern, self.getConfig('replacement_char'), - name) - return name + '.avi' def get_file_url(self): """ returns the absolute downloadable filepath """ - if self.html is None: + if not self.html: self.download_html() - match = re.search(r'<embed type="video/divx" src="(http://([^/]*\.)?veehd\.com/dl/[^"]+)"', + m = re.search(r'<embed type="video/divx" src="(http://([^/]*\.)?veehd\.com/dl/[^"]+)"', self.html) - if not match: - self.fail("embedded video url not found") - file_url = match.group(1) + if m is None: + self.error(_("Embedded video url not found")) - return file_url + return m.group(1) diff --git a/module/plugins/hoster/VeohCom.py b/module/plugins/hoster/VeohCom.py index c1ebffb81..6dbac397b 100644 --- a/module/plugins/hoster/VeohCom.py +++ b/module/plugins/hoster/VeohCom.py @@ -1,18 +1,4 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -############################################################################ import re @@ -20,37 +6,48 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class VeohCom(SimpleHoster): - __name__ = "VeohCom" - __type__ = "hoster" + __name__ = "VeohCom" + __type__ = "hoster" + __version__ = "0.21" + __pattern__ = r'http://(?:www\.)?veoh\.com/(tv/)?(watch|videos)/(?P<ID>v\w+)' - __version__ = "0.1" - __config__ = [("quality", "Low;High", "Quality", "High")] + __config__ = [("quality", "Low;High;Auto", "Quality", "Auto")] + __description__ = """Veoh.com hoster plugin""" - __author_name__ = "Walter Purcaro" - __author_mail__ = "vuolter@gmail.com" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + - FILE_NAME_PATTERN = r'<meta name="title" content="(?P<N>.*?)"' - FILE_OFFLINE_PATTERN = r'>Sorry, we couldn\'t find the video you were looking for' + NAME_PATTERN = r'<meta name="title" content="(?P<N>.*?)"' + OFFLINE_PATTERN = r'>Sorry, we couldn\'t find the video you were looking for' - FILE_URL_REPLACEMENTS = [(__pattern__, r'http://www.veoh.com/watch/\g<ID>')] + URL_REPLACEMENTS = [(__pattern__ + ".*", r'http://www.veoh.com/watch/\g<ID>')] + + COOKIES = [("veoh.com", "lassieLocale", "en")] - SH_COOKIES = [(".veoh.com", "lassieLocale", "en")] def setup(self): - self.resumeDownload = self.multiDL = True - self.chunkLimit = -1 + self.resumeDownload = True + self.multiDL = True + self.chunkLimit = -1 + def handleFree(self): - q = self.getConfig("quality") - pattern = r'"fullPreviewHash%sPath":"(.+?)"' % q - found = re.search(pattern, self.html) - if found: - self.pyfile.name += ".mp4" - link = found.group(1).replace("\\", "") - self.logDebug("Download link: " + link) - self.download(link) + quality = self.getConfig("quality") + if quality == "Auto": + quality = ("High", "Low") + for q in quality: + pattern = r'"fullPreviewHash%sPath":"(.+?)"' % q + m = re.search(pattern, self.html) + if m: + self.pyfile.name += ".mp4" + link = m.group(1).replace("\\", "") + self.download(link) + return + else: + self.logInfo(_("No %s quality video found") % q.upper()) else: - self.fail("No %s quality video found" % q.lower()) + self.fail(_("No video found!")) getInfo = create_getInfo(VeohCom) diff --git a/module/plugins/hoster/VidPlayNet.py b/module/plugins/hoster/VidPlayNet.py index ade416750..76af05edd 100644 --- a/module/plugins/hoster/VidPlayNet.py +++ b/module/plugins/hoster/VidPlayNet.py @@ -1,25 +1,26 @@ # -*- coding: utf-8 -*- - +# # Test links: # BigBuckBunny_320x180.mp4 - 61.7 Mb - http://vidplay.net/38lkev0h3jv0 -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo + +class VidPlayNet(XFSHoster): + __name__ = "VidPlayNet" + __type__ = "hoster" + __version__ = "0.04" -class VidPlayNet(XFileSharingPro): - __name__ = "VidPlayNet" - __type__ = "hoster" __pattern__ = r'https?://(?:www\.)?vidplay\.net/\w{12}' - __version__ = "0.01" + __description__ = """VidPlay.net hoster plugin""" - __author_name__ = "t4skforce" - __author_mail__ = "t4skforce1337[AT]gmail[DOT]com" + __license__ = "GPLv3" + __authors__ = [("t4skforce", "t4skforce1337[AT]gmail[DOT]com")] + - HOSTER_NAME = "vidplay.net" + HOSTER_DOMAIN = "vidplay.net" - FILE_OFFLINE_PATTERN = r'<b>File Not Found</b><br>\s*<br>' - FILE_NAME_PATTERN = r'<b>Password:</b></div>\s*<h[1-6]>(?P<N>[^<]+)</h[1-6]>' - DIRECT_LINK_PATTERN = r'(http://([^/]*?%s|\d+\.\d+\.\d+\.\d+)(:\d+)?(/d/|(?:/files)?/\d+/\w+/)[^"\'<&]+)' % HOSTER_NAME + NAME_PATTERN = r'<b>Password:</b></div>\s*<h[1-6]>(?P<N>[^<]+)</h[1-6]>' getInfo = create_getInfo(VidPlayNet) diff --git a/module/plugins/hoster/VimeoCom.py b/module/plugins/hoster/VimeoCom.py new file mode 100644 index 000000000..0e42c1674 --- /dev/null +++ b/module/plugins/hoster/VimeoCom.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + + +class VimeoCom(SimpleHoster): + __name__ = "VimeoCom" + __type__ = "hoster" + __version__ = "0.03" + + __pattern__ = r'https?://(?:www\.)?(player\.)?vimeo\.com/(video/)?(?P<ID>\d+)' + __config__ = [("quality", "Lowest;Mobile;SD;HD;Highest", "Quality", "Highest"), + ("original", "bool", "Try to download the original file first", True)] + + __description__ = """Vimeo.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + NAME_PATTERN = r'<title>(?P<N>.+) on Vimeo<' + OFFLINE_PATTERN = r'class="exception_header"' + TEMP_OFFLINE_PATTERN = r'Please try again in a few minutes.<' + + URL_REPLACEMENTS = [(__pattern__ + ".*", r'https://www.vimeo.com/\g<ID>')] + + COOKIES = [("vimeo.com", "language", "en")] + + + def setup(self): + self.resumeDownload = True + self.multiDL = True + self.chunkLimit = -1 + + + def handleFree(self): + password = self.getPassword() + + if self.js and 'class="btn iconify_down_b"' in self.html: + html = self.js.eval(self.load(self.pyfile.url, get={'action': "download", 'password': password}, decode=True)) + pattern = r'href="(?P<URL>http://vimeo\.com.+?)".*?\>(?P<QL>.+?) ' + else: + id = re.match(self.__pattern__, self.pyfile.url).group('ID') + html = self.load("https://player.vimeo.com/video/" + id, get={'password': password}) + pattern = r'"(?P<QL>\w+)":{"profile".*?"(?P<URL>http://pdl\.vimeocdn\.com.+?)"' + + link = dict([(l.group('QL').lower(), l.group('URL')) for l in re.finditer(pattern, html)]) + + if self.getConfig("original"): + if "original" in link: + self.download(link[q]) + return + else: + self.logInfo(_("Original file not downloadable")) + + quality = self.getConfig("quality") + if quality == "Highest": + qlevel = ("hd", "sd", "mobile") + elif quality == "Lowest": + qlevel = ("mobile", "sd", "hd") + else: + qlevel = quality.lower() + + for q in qlevel: + if q in link: + self.download(link[q]) + return + else: + self.logInfo(_("No %s quality video found") % q.upper()) + else: + self.fail(_("No video found!")) + + +getInfo = create_getInfo(VimeoCom) diff --git a/module/plugins/hoster/Vipleech4uCom.py b/module/plugins/hoster/Vipleech4uCom.py index 53768a430..340a3feaa 100644 --- a/module/plugins/hoster/Vipleech4uCom.py +++ b/module/plugins/hoster/Vipleech4uCom.py @@ -1,84 +1,18 @@ # -*- coding: utf-8 -*- -import re +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo -from module.plugins.Hoster import Hoster +class Vipleech4uCom(DeadHoster): + __name__ = "Vipleech4uCom" + __type__ = "hoster" + __version__ = "0.20" -class Vipleech4uCom(Hoster): - __name__ = "Vipleech4uCom" - __version__ = "0.1" - __type__ = "hoster" - __pattern__ = r"http://vipleech4u.com/manager.php" - __description__ = """Vipleech4u.com hoster plugin""" - __author_name__ = ("Kagenoshin") - __author_mail__ = ("kagenoshin@gmx.ch") - - FILENAME_PATTERN = re.compile(r'name\s*?=\s*?["\']filename["\'][^>]*?value\s*?=\s*?["\'](.*?)["\']', re.I) - HOST_PATTERN = re.compile(r'name\s*?=\s*?["\']host["\'][^>]*?value\s*?=\s*?["\'](.*?)["\']', re.I) - PATH_PATTERN = re.compile(r'name\s*?=\s*?["\']path["\'][^>]*?value\s*?=\s*?["\'](.*?)["\']', re.I) - REFERER_PATTERN = re.compile(r'name\s*?=\s*?["\']referer["\'][^>]*?value\s*?=\s*?["\'](.*?)["\']', re.I) - LINK_PATTERN = re.compile(r'name\s*?=\s*?["\']link["\'][^>]*?value\s*?=\s*?["\'](.*?)["\']', re.I) - COOKIE_PATTERN = re.compile(r'name\s*?=\s*?["\']cookie["\'][^>]*?value\s*?=\s*?["\'](.*?)["\']', re.I) - - def setup(self): - self.resumeDownload = self.multiDL = True - self.chunkLimit = 1 - - def process(self, pyfile): - if not self.account: - self.logError(_("Please enter your %s account or deactivate this plugin") % "vipleech4u.com") - self.fail("No vipleech4u.com account provided") - - self.logDebug("Old URL: %s" % pyfile.url) - - new_url = pyfile.url - - if re.match(self.__pattern__, new_url): - self.fail("Can't handle vipleech4u links.") - - #upload the link which has to be loaded - page = self.load('http://vipleech4u.com/generator.php', post={'links': new_url, 'ddl': 'no'}) + __pattern__ = r'http://(?:www\.)?vipleech4u\.com/manager\.php' - #switch to the manager and see what's happening - page = self.load('http://vipleech4u.com/unrestrict.php', get={'link': new_url, 'premium_acc': 'on'}) - - if re.search(r'You have generated maximum links available to you today', page, re.I): - self.fail('Daily limit reached.') - - filename = self.FILENAME_PATTERN.search(page) - host = self.HOST_PATTERN.search(page) - path = self.PATH_PATTERN.search(page) - referer = self.REFERER_PATTERN.search(page) - link = self.LINK_PATTERN.search(page) - cookie = self.COOKIE_PATTERN.search(page) - - #build the post-dictionary - post_dict = {} - - if filename: - post_dict.update({'filename': filename.group(1)}) - if host: - post_dict.update({'host': host.group(1)}) - if path: - post_dict.update({'path': path.group(1)}) - if referer: - post_dict.update({'referer': referer.group(1)}) - if link: - post_dict.update({'link': link.group(1)}) - if cookie: - post_dict.update({'cookie': cookie.group(1)}) - - if not post_dict: - self.logDebug('Get an empty post_dict. Strange.') - - self.setWait(5) - self.wait() - self.logDebug("Unrestricted URL: " + str(post_dict)) - - self.download('http://vipleech4u.com/unrestrict.php', post=post_dict, disposition=True) + __description__ = """Vipleech4u.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("Kagenoshin", "kagenoshin@gmx.ch")] - check = self.checkDownload({"bad": "<html"}) - if check == "bad": - self.retry(24, 150, 'Bad file downloaded') +getInfo = create_getInfo(Vipleech4uCom) diff --git a/module/plugins/hoster/WarserverCz.py b/module/plugins/hoster/WarserverCz.py index a80349b45..c83d5c03e 100644 --- a/module/plugins/hoster/WarserverCz.py +++ b/module/plugins/hoster/WarserverCz.py @@ -1,77 +1,18 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. +class WarserverCz(DeadHoster): + __name__ = "WarserverCz" + __type__ = "hoster" + __version__ = "0.13" - @author: zoidberg -""" + __pattern__ = r'http://(?:www\.)?warserver\.cz/stahnout/\d+' -#similar to coolshare.cz (down) - -import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.network.HTTPRequest import BadHeader -from module.utils import html_unescape - - -class WarserverCz(SimpleHoster): - __name__ = "WarserverCz" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?warserver.cz/stahnout/(?P<ID>\d+)/.+' - __version__ = "0.12" __description__ = """Warserver.cz hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" - - FILE_NAME_PATTERN = r'<h1.*?>(?P<N>[^<]+)</h1>' - FILE_SIZE_PATTERN = r'<li>Velikost: <strong>(?P<S>[^<]+)</strong>' - FILE_OFFLINE_PATTERN = r'<h1>Soubor nenalezen</h1>' - - PREMIUM_URL_PATTERN = r'href="(http://[^/]+/dwn-premium.php.*?)"' - DOMAIN = "http://csd01.coolshare.cz" - - DOMAIN = "http://s01.warserver.cz" - - def handleFree(self): - try: - self.download("%s/dwn-free.php?fid=%s" % (self.DOMAIN, self.file_info['ID'])) - except BadHeader, e: - self.logError(e) - if e.code == 403: - self.longWait(60, 60) - else: - raise - self.checkDownloadedFile() - - def handlePremium(self): - found = re.search(self.PREMIUM_URL_PATTERN, self.html) - if not found: - self.parseError("Premium URL") - url = html_unescape(found.group(1)) - self.logDebug("Premium URL: " + url) - if not url.startswith("http://"): - self.resetAccount() - self.download(url) - self.checkDownloadedFile() - - def checkDownloadedFile(self): - check = self.checkDownload({ - "offline": ">404 Not Found<" - }) - - if check == "offline": - self.offline() + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] getInfo = create_getInfo(WarserverCz) diff --git a/module/plugins/hoster/WebshareCz.py b/module/plugins/hoster/WebshareCz.py index 53dc3b95c..a08341ff3 100644 --- a/module/plugins/hoster/WebshareCz.py +++ b/module/plugins/hoster/WebshareCz.py @@ -1,71 +1,64 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################ import re -from module.plugins.internal.SimpleHoster import SimpleHoster -from module.network.RequestFactory import getRequest +from module.network.RequestFactory import getURL +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -def getInfo(urls): - h = getRequest() - for url in urls: - h.load(url) - fid = re.search(WebshareCz.__pattern__, url).group('ID') - api_data = h.load('https://webshare.cz/api/file_info/', post={'ident': fid}) - if 'File not found' in api_data: - file_info = (url, 0, 1, url) - else: - name = re.search('<name>(.+)</name>', api_data).group(1) - size = re.search('<size>(.+)</size>', api_data).group(1) - file_info = (name, size, 2, url) - yield file_info +class WebshareCz(SimpleHoster): + __name__ = "WebshareCz" + __type__ = "hoster" + __version__ = "0.14" + __pattern__ = r'https?://(?:www\.)?webshare\.cz/(?:#/)?file/(?P<ID>\w+)' -class WebshareCz(SimpleHoster): - __name__ = "WebshareCz" - __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?webshare.cz/(?:#/)?file/(?P<ID>\w+)' - __version__ = "0.13" __description__ = """WebShare.cz hoster plugin""" - __author_name__ = "stickell" - __author_mail__ = "l.stickell@yahoo.it" + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it"), + ("rush", "radek.senfeld@gmail.com")] + + + @classmethod + def getInfo(cls, url="", html=""): + info = super(WebshareCz, self).getInfo(url, html) + + if url: + info['pattern'] = re.match(cls.__pattern__, url).groupdict() + + api_data = getURL("https://webshare.cz/api/file_info/", + post={'ident': info['pattern']['ID']}, + decode=True) + + if 'File not found' in api_data: + info['status'] = 1 + else: + info["status"] = 2 + info['name'] = re.search('<name>(.+)</name>', api_data).group(1) or info['name'] + info['size'] = re.search('<size>(.+)</size>', api_data).group(1) or info['size'] + + return info + def handleFree(self): - api_data = self.load('https://webshare.cz/api/file_link/', post={'ident': self.fid}) + fid = re.match(self.__pattern__, self.pyfile.url).group('ID') + wst = self.account.infos['wst'] if self.account and 'wst' in self.account.infos else "" + + api_data = getURL('https://webshare.cz/api/file_link/', + post={'ident': fid, 'wst': wst}, + decode=True) + self.logDebug("API data: " + api_data) + m = re.search('<link>(.+)</link>', api_data) - if not m: - self.parseError('Unable to detect direct link') - direct = m.group(1) - self.logDebug("Direct link: " + direct) - self.download(direct, disposition=True) + if m is None: + self.error(_("Unable to detect direct link")) - def getFileInfo(self): - self.logDebug("URL: %s" % self.pyfile.url) + self.link = m.group(1) - self.fid = re.match(self.__pattern__, self.pyfile.url).group('ID') - self.load(self.pyfile.url) - api_data = self.load('https://webshare.cz/api/file_info/', post={'ident': self.fid}) + def handlePremium(self): + return self.handleFree() - if 'File not found' in api_data: - self.offline() - else: - self.pyfile.name = re.search('<name>(.+)</name>', api_data).group(1) - self.pyfile.size = re.search('<size>(.+)</size>', api_data).group(1) - self.logDebug("FILE NAME: %s FILE SIZE: %s" % (self.pyfile.name, self.pyfile.size)) +getInfo = create_getInfo(WebshareCz) diff --git a/module/plugins/hoster/WrzucTo.py b/module/plugins/hoster/WrzucTo.py index 7966b980a..8e9653307 100644 --- a/module/plugins/hoster/WrzucTo.py +++ b/module/plugins/hoster/WrzucTo.py @@ -1,48 +1,38 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re + from pycurl import HTTPHEADER from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class WrzucTo(SimpleHoster): - __name__ = "WrzucTo" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?wrzuc\.to/([a-zA-Z0-9]+(\.wt|\.html)|(\w+/?linki/[a-zA-Z0-9]+))' - __version__ = "0.01" + __name__ = "WrzucTo" + __type__ = "hoster" + __version__ = "0.02" + + __pattern__ = r'http://(?:www\.)?wrzuc\.to/(\w+(\.wt|\.html)|(\w+/?linki/\w+))' + __description__ = """Wrzuc.to hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + + NAME_PATTERN = r'id="file_info">\s*<strong>(?P<N>.*?)</strong>' + SIZE_PATTERN = r'class="info">\s*<tr>\s*<td>(?P<S>.*?)</td>' + + COOKIES = [("wrzuc.to", "language", "en")] - SH_COOKIES = [("http://www.wrzuc.to", "language", "en")] - FILE_SIZE_PATTERN = r'class="info">\s*<tr>\s*<td>(?P<S>.*?)</td>' - FILE_NAME_PATTERN = r'id="file_info">\s*<strong>(?P<N>.*?)</strong>' def setup(self): self.multiDL = True + def handleFree(self): data = dict(re.findall(r'(md5|file): "(.*?)"', self.html)) if len(data) != 2: - self.parseError('File ID') + self.error(_("No file ID")) self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) self.req.http.lastURL = self.pyfile.url @@ -53,10 +43,9 @@ class WrzucTo(SimpleHoster): data.update(re.findall(r'"(download_link|server_id)":"(.*?)"', self.html)) if len(data) != 4: - self.parseError('Download URL') + self.error(_("No download URL")) download_url = "http://%s.wrzuc.to/pobierz/%s" % (data['server_id'], data['download_link']) - self.logDebug("Download URL: %s" % download_url) self.download(download_url) diff --git a/module/plugins/hoster/WuploadCom.py b/module/plugins/hoster/WuploadCom.py index a0228081c..75ce59353 100644 --- a/module/plugins/hoster/WuploadCom.py +++ b/module/plugins/hoster/WuploadCom.py @@ -4,13 +4,16 @@ from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo class WuploadCom(DeadHoster): - __name__ = "WuploadCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?wupload\..*?/file/(([a-z][0-9]+/)?[0-9]+)(/.*)?' + __name__ = "WuploadCom" + __type__ = "hoster" __version__ = "0.23" + + __pattern__ = r'http://(?:www\.)?wupload\..+?/file/((\w+/)?\d+)(/.*)?' + __description__ = """Wupload.com hoster plugin""" - __author_name__ = ("jeix", "Paul King") - __author_mail__ = ("jeix@hasnomail.de", "") + __license__ = "GPLv3" + __authors__ = [("jeix", "jeix@hasnomail.de"), + ("Paul King", None)] getInfo = create_getInfo(WuploadCom) diff --git a/module/plugins/hoster/X7To.py b/module/plugins/hoster/X7To.py index 810ede911..a4e4b04bd 100644 --- a/module/plugins/hoster/X7To.py +++ b/module/plugins/hoster/X7To.py @@ -4,13 +4,15 @@ from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo class X7To(DeadHoster): - __name__ = "X7To" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?x7.to/' + __name__ = "X7To" + __type__ = "hoster" __version__ = "0.41" + + __pattern__ = r'http://(?:www\.)?x7\.to/' + __description__ = """X7.to hoster plugin""" - __author_name__ = "ernieb" - __author_mail__ = "ernieb" + __license__ = "GPLv3" + __authors__ = [("ernieb", "ernieb")] getInfo = create_getInfo(X7To) diff --git a/module/plugins/hoster/XFileSharingPro.py b/module/plugins/hoster/XFileSharingPro.py index f69283c47..0acad3dba 100644 --- a/module/plugins/hoster/XFileSharingPro.py +++ b/module/plugins/hoster/XFileSharingPro.py @@ -1,335 +1,57 @@ # -*- coding: utf-8 -*- -############################################################################### -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, -# or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see <http://www.gnu.org/licenses/>. -# -# @author: zoidberg -############################################################################### - import re -from random import random -from urllib import unquote -from urlparse import urlparse -from pycurl import FOLLOWLOCATION, LOW_SPEED_TIME -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, PluginParseError, replace_patterns -from module.plugins.internal.CaptchaService import ReCaptcha, SolveMedia -from module.utils import html_unescape -from module.network.RequestFactory import getURL - - -class XFileSharingPro(SimpleHoster): - """ - Common base for XFileSharingPro hosters like EasybytezCom, CramitIn, FiledinoCom... - Some hosters may work straight away when added to __pattern__ - However, most of them will NOT work because they are either down or running a customized version - """ - __name__ = "XFileSharingPro" - __type__ = "hoster" - __pattern__ = r'^unmatchable$' - __version__ = "0.31" - __description__ = """XFileSharingPro base hoster plugin""" - __author_name__ = ("zoidberg", "stickell") - __author_mail__ = ("zoidberg@mujmail.cz", "l.stickell@yahoo.it") - - FILE_NAME_PATTERN = r'<input type="hidden" name="fname" value="(?P<N>[^"]+)"' - FILE_SIZE_PATTERN = r'You have requested .*\((?P<S>[\d\.\,]+) ?(?P<U>\w+)?\)</font>' - FILE_INFO_PATTERN = r'<tr><td align=right><b>Filename:</b></td><td nowrap>(?P<N>[^<]+)</td></tr>\s*.*?<small>\((?P<S>[^<]+)\)</small>' - FILE_OFFLINE_PATTERN = r'>\w+ (Not Found|file (was|has been) removed)' - - WAIT_PATTERN = r'<span id="countdown_str">.*?>(\d+)</span>' - #LONG_WAIT_PATTERN = r'(?P<H>\d+(?=\s*hour))?.*?(?P<M>\d+(?=\s*minute))?.*?(?P<S>\d+(?=\s*second))?' - OVR_DOWNLOAD_LINK_PATTERN = r'<h2>Download Link</h2>\s*<textarea[^>]*>([^<]+)' - OVR_KILL_LINK_PATTERN = r'<h2>Delete Link</h2>\s*<textarea[^>]*>([^<]+)' - CAPTCHA_URL_PATTERN = r'(http://[^"\']+?/captchas?/[^"\']+)' - RECAPTCHA_URL_PATTERN = r'http://[^"\']+?recaptcha[^"\']+?\?k=([^"\']+)"' - CAPTCHA_DIV_PATTERN = r'>Enter code.*?<div.*?>(.*?)</div>' - SOLVEMEDIA_PATTERN = r'http:\/\/api\.solvemedia\.com\/papi\/challenge\.script\?k=(.*?)"' - ERROR_PATTERN = r'class=["\']err["\'][^>]*>(.*?)</' - - def setup(self): - if self.__name__ == "XFileSharingPro": - self.__pattern__ = self.core.pluginManager.hosterPlugins[self.__name__]['pattern'] - self.multiDL = True - else: - self.resumeDownload = self.multiDL = self.premium - - self.chunkLimit = 1 - - def process(self, pyfile): - self.prepare() - - pyfile.url = replace_patterns(pyfile.url, self.FILE_URL_REPLACEMENTS) - - if not re.match(self.__pattern__, pyfile.url): - if self.premium: - self.handleOverriden() - else: - self.fail("Only premium users can download from other hosters with %s" % self.HOSTER_NAME) - else: - try: - # Due to a 0.4.9 core bug self.load would use cookies even if - # cookies=False. Workaround using getURL to avoid cookies. - # Can be reverted in 0.5 as the cookies bug has been fixed. - self.html = getURL(pyfile.url, decode=True) - self.file_info = self.getFileInfo() - except PluginParseError: - self.file_info = None - - self.location = self.getDirectDownloadLink() - - if not self.file_info: - pyfile.name = html_unescape(unquote(urlparse( - self.location if self.location else pyfile.url).path.split("/")[-1])) - - if self.location: - self.startDownload(self.location) - elif self.premium: - self.handlePremium() - else: - self.handleFree() - - def prepare(self): - """ Initialize important variables """ - if not hasattr(self, "HOSTER_NAME"): - self.HOSTER_NAME = re.match(self.__pattern__, self.pyfile.url).group(1) - if not hasattr(self, "DIRECT_LINK_PATTERN"): - self.DIRECT_LINK_PATTERN = r'(http://([^/]*?%s|\d+\.\d+\.\d+\.\d+)(:\d+)?(/d/|(?:/files)?/\d+/\w+/)[^"\'<]+)' % self.HOSTER_NAME - - self.captcha = self.errmsg = None - self.passwords = self.getPassword().splitlines() - - def getDirectDownloadLink(self): - """ Get download link for premium users with direct download enabled """ - self.req.http.lastURL = self.pyfile.url - - self.req.http.c.setopt(FOLLOWLOCATION, 0) - self.html = self.load(self.pyfile.url, cookies=True, decode=True) - self.header = self.req.http.header - self.req.http.c.setopt(FOLLOWLOCATION, 1) - - location = None - found = re.search(r"Location\s*:\s*(.*)", self.header, re.I) - if found and re.match(self.DIRECT_LINK_PATTERN, found.group(1)): - location = found.group(1).strip() - return location +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo - def handleFree(self): - url = self.getDownloadLink() - self.logDebug("Download URL: %s" % url) - self.startDownload(url) - def getDownloadLink(self): - for i in xrange(5): - self.logDebug("Getting download link: #%d" % i) - data = self.getPostParameters() +class XFileSharingPro(XFSHoster): + __name__ = "XFileSharingPro" + __type__ = "hoster" + __version__ = "0.43" - self.req.http.c.setopt(FOLLOWLOCATION, 0) - self.html = self.load(self.pyfile.url, post=data, ref=True, decode=True) - self.header = self.req.http.header - self.req.http.c.setopt(FOLLOWLOCATION, 1) - - found = re.search(r"Location\s*:\s*(.*)", self.header, re.I) - if found: - break - - found = re.search(self.DIRECT_LINK_PATTERN, self.html, re.S) - if found: - break + __pattern__ = r'^unmatchable$' - else: - if self.errmsg and 'captcha' in self.errmsg: - self.fail("No valid captcha code entered") - else: - self.fail("Download link not found") + __description__ = """XFileSharingPro dummy hoster plugin for hook""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - return found.group(1) - def handlePremium(self): - self.html = self.load(self.pyfile.url, post=self.getPostParameters()) - found = re.search(self.DIRECT_LINK_PATTERN, self.html) - if not found: - self.parseError('DIRECT LINK') - self.startDownload(found.group(1)) + URL_REPLACEMENTS = [("/embed-", "/")] - def handleOverriden(self): - #only tested with easybytez.com - self.html = self.load("http://www.%s/" % self.HOSTER_NAME) - action, inputs = self.parseHtmlForm('') - upload_id = "%012d" % int(random() * 10 ** 12) - action += upload_id + "&js_on=1&utype=prem&upload_type=url" - inputs['tos'] = '1' - inputs['url_mass'] = self.pyfile.url - inputs['up1oad_type'] = 'url' - self.logDebug(self.HOSTER_NAME, action, inputs) - #wait for file to upload to easybytez.com - self.req.http.c.setopt(LOW_SPEED_TIME, 600) - self.html = self.load(action, post=inputs) + def _log(self, type, args): + msg = " | ".join([str(a).strip() for a in args if a]) + logger = getattr(self.log, type) + logger("%s: %s: %s" % (self.__name__, self.HOSTER_NAME, msg or _("%s MARK" % type.upper()))) - action, inputs = self.parseHtmlForm('F1') - if not inputs: - self.parseError('TEXTAREA') - self.logDebug(self.HOSTER_NAME, inputs) - if inputs['st'] == 'OK': - self.html = self.load(action, post=inputs) - elif inputs['st'] == 'Can not leech file': - self.retry(max_tries=20, wait_time=3 * 60, reason=inputs['st']) - else: - self.fail(inputs['st']) - #get easybytez.com link for uploaded file - found = re.search(self.OVR_DOWNLOAD_LINK_PATTERN, self.html) - if not found: - self.parseError('DIRECT LINK (OVR)') - self.pyfile.url = found.group(1) - header = self.load(self.pyfile.url, just_header=True) - if 'location' in header: # Direct link - self.startDownload(self.pyfile.url) - else: - self.retry() + def init(self): + super(XFileSharingPro, self).init() - def startDownload(self, link): - link = link.strip() - if self.captcha: - self.correctCaptcha() - self.logDebug('DIRECT LINK: %s' % link) - self.download(link, disposition=True) + self.__pattern__ = self.core.pluginManager.hosterPlugins[self.__name__]['pattern'] - def checkErrors(self): - found = re.search(self.ERROR_PATTERN, self.html) - if found: - self.errmsg = found.group(1) - self.logWarning(re.sub(r"<.*?>", " ", self.errmsg)) + self.HOSTER_DOMAIN = re.match(self.__pattern__, self.pyfile.url).group(1).lower() + self.HOSTER_NAME = "".join([str.capitalize() for str in self.HOSTER_DOMAIN.split('.')]) - if 'wait' in self.errmsg: - wait_time = sum([int(v) * {"hour": 3600, "minute": 60, "second": 1}[u] for v, u in - re.findall(r'(\d+)\s*(hour|minute|second)?', self.errmsg)]) - self.wait(wait_time, True) - elif 'captcha' in self.errmsg: - self.invalidCaptcha() - elif 'premium' in self.errmsg and 'require' in self.errmsg: - self.fail("File can be downloaded by premium users only") - elif 'limit' in self.errmsg: - self.wait(1 * 60 * 60, True) - self.retry(25) - elif 'countdown' in self.errmsg or 'Expired' in self.errmsg: - self.retry() - elif 'maintenance' in self.errmsg: - self.tempOffline() - elif 'download files up to' in self.errmsg: - self.fail("File too large for free download") - else: - self.fail(self.errmsg) + account = self.core.accountManager.getAccountPlugin(self.HOSTER_NAME) + if account and account.canUse(): + self.account = account + elif self.account: + self.account.HOSTER_DOMAIN = self.HOSTER_DOMAIN else: - self.errmsg = None - - return self.errmsg - - def getPostParameters(self): - for _ in xrange(3): - if not self.errmsg: - self.checkErrors() - - if hasattr(self, "FORM_PATTERN"): - action, inputs = self.parseHtmlForm(self.FORM_PATTERN) - else: - action, inputs = self.parseHtmlForm(input_names={"op": re.compile("^download")}) - - if not inputs: - action, inputs = self.parseHtmlForm('F1') - if not inputs: - if self.errmsg: - self.retry() - else: - self.parseError("Form not found") - - self.logDebug(self.HOSTER_NAME, inputs) + return - if 'op' in inputs and inputs['op'] in ('download2', 'download3'): - if "password" in inputs: - if self.passwords: - inputs['password'] = self.passwords.pop(0) - else: - self.fail("No or invalid passport") + self.user, data = self.account.selectAccount() + self.req = self.account.getAccountRequest(self.user) + self.premium = self.account.isPremium(self.user) - if not self.premium: - found = re.search(self.WAIT_PATTERN, self.html) - if found: - wait_time = int(found.group(1)) + 1 - self.setWait(wait_time, False) - else: - wait_time = 0 - self.captcha = self.handleCaptcha(inputs) - - if wait_time: - self.wait() - - self.errmsg = None - return inputs - - else: - inputs['referer'] = self.pyfile.url - - if self.premium: - inputs['method_premium'] = "Premium Download" - if 'method_free' in inputs: - del inputs['method_free'] - else: - inputs['method_free'] = "Free Download" - if 'method_premium' in inputs: - del inputs['method_premium'] - - self.html = self.load(self.pyfile.url, post=inputs, ref=True) - self.errmsg = None - - else: - self.parseError('FORM: %s' % (inputs['op'] if 'op' in inputs else 'UNKNOWN')) - - def handleCaptcha(self, inputs): - found = re.search(self.RECAPTCHA_URL_PATTERN, self.html) - if found: - recaptcha_key = unquote(found.group(1)) - self.logDebug("RECAPTCHA KEY: %s" % recaptcha_key) - recaptcha = ReCaptcha(self) - inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge(recaptcha_key) - return 1 - else: - found = re.search(self.CAPTCHA_URL_PATTERN, self.html) - if found: - captcha_url = found.group(1) - inputs['code'] = self.decryptCaptcha(captcha_url) - return 2 - else: - found = re.search(self.CAPTCHA_DIV_PATTERN, self.html, re.DOTALL) - if found: - captcha_div = found.group(1) - self.logDebug(captcha_div) - numerals = re.findall(r'<span.*?padding-left\s*:\s*(\d+).*?>(\d)</span>', html_unescape(captcha_div)) - inputs['code'] = "".join([a[1] for a in sorted(numerals, key=lambda num: int(num[0]))]) - self.logDebug("CAPTCHA", inputs['code'], numerals) - return 3 - else: - found = re.search(self.SOLVEMEDIA_PATTERN, self.html) - if found: - captcha_key = found.group(1) - captcha = SolveMedia(self) - inputs['adcopy_challenge'], inputs['adcopy_response'] = captcha.challenge(captcha_key) - return 4 - return 0 + def setup(self): + self.chunkLimit = 1 + self.resumeDownload = self.premium + self.multiDL = True getInfo = create_getInfo(XFileSharingPro) diff --git a/module/plugins/hoster/XHamsterCom.py b/module/plugins/hoster/XHamsterCom.py index 0f0371f21..c6e789fa8 100644 --- a/module/plugins/hoster/XHamsterCom.py +++ b/module/plugins/hoster/XHamsterCom.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- import re + from urllib import unquote -from module.plugins.Hoster import Hoster from module.common.json_layer import json_loads +from module.plugins.Hoster import Hoster def clean_json(json_expr): @@ -16,12 +17,17 @@ def clean_json(json_expr): class XHamsterCom(Hoster): - __name__ = "XHamsterCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?xhamster\.com/movies/.+' + __name__ = "XHamsterCom" + __type__ = "hoster" __version__ = "0.12" + + __pattern__ = r'http://(?:www\.)?xhamster\.com/movies/.+' __config__ = [("type", ".mp4;.flv", "Preferred type", ".mp4")] + __description__ = """XHamster.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [] + def process(self, pyfile): self.pyfile = pyfile @@ -35,81 +41,87 @@ class XHamsterCom(Hoster): pyfile.name = self.get_file_name() + self.desired_fmt self.download(self.get_file_url()) + def download_html(self): url = self.pyfile.url self.html = self.load(url) + def get_file_url(self): """ returns the absolute downloadable filepath """ - if self.html is None: + if not self.html: self.download_html() - flashvar_pattern = re.compile('flashvars = ({.*?});', re.DOTALL) + flashvar_pattern = re.compile('flashvars = ({.*?});', re.S) json_flashvar = flashvar_pattern.search(self.html) - if json_flashvar is None: - self.fail("Parse error (flashvars)") + if not json_flashvar: + self.error(_("flashvar not found")) j = clean_json(json_flashvar.group(1)) flashvars = json_loads(j) - if flashvars["srv"]: - srv_url = flashvars["srv"] + '/' + if flashvars['srv']: + srv_url = flashvars['srv'] + '/' else: - self.fail("Parse error (srv_url)") + self.error(_("srv_url not found")) + + if flashvars['url_mode']: + url_mode = flashvars['url_mode'] + - if flashvars["url_mode"]: - url_mode = flashvars["url_mode"] else: - self.fail("Parse error (url_mode)") + self.error(_("url_mode not found")) if self.desired_fmt == ".mp4": file_url = re.search(r"<a href=\"" + srv_url + "(.+?)\"", self.html) if file_url is None: - self.fail("Parse error (file_url)") + self.error(_("file_url not found")) file_url = file_url.group(1) long_url = srv_url + file_url - self.logDebug("long_url: %s" % long_url) + self.logDebug("long_url = " + long_url) else: - if flashvars["file"]: - file_url = unquote(flashvars["file"]) + if flashvars['file']: + file_url = unquote(flashvars['file']) else: - self.fail("Parse error (file_url)") + self.error(_("file_url not found")) if url_mode == '3': long_url = file_url - self.logDebug("long_url: %s" % long_url) + self.logDebug("long_url = " + long_url) else: long_url = srv_url + "key=" + file_url - self.logDebug("long_url: %s" % long_url) + self.logDebug("long_url = " + long_url) return long_url + def get_file_name(self): - if self.html is None: + if not self.html: self.download_html() - file_name_pattern = r"<title>(.*?) - xHamster\.com</title>" - file_name = re.search(file_name_pattern, self.html) - if file_name is None: - file_name_pattern = r"<h1 >(.*)</h1>" - file_name = re.search(file_name_pattern, self.html) - if file_name is None: - file_name_pattern = r"http://[www.]+xhamster\.com/movies/.*/(.*?)\.html?" - file_name = re.match(file_name_pattern, self.pyfile.url) - if file_name is None: - file_name_pattern = r"<div id=\"element_str_id\" style=\"display:none;\">(.*)</div>" - file_name = re.search(file_name_pattern, self.html) - if file_name is None: + pattern = r'<title>(.*?) - xHamster\.com</title>' + name = re.search(pattern, self.html) + if name is None: + pattern = r'<h1 >(.*)</h1>' + name = re.search(pattern, self.html) + if name is None: + pattern = r'http://[www.]+xhamster\.com/movies/.*/(.*?)\.html?' + name = re.match(file_name_pattern, self.pyfile.url) + if name is None: + pattern = r'<div id="element_str_id" style="display:none;">(.*)</div>' + name = re.search(pattern, self.html) + if name is None: return "Unknown" - return file_name.group(1) + return name.group(1) + def file_exists(self): """ returns True or False """ - if self.html is None: + if not self.html: self.download_html() if re.search(r"(.*Video not found.*)", self.html) is not None: return False diff --git a/module/plugins/hoster/XVideosCom.py b/module/plugins/hoster/XVideosCom.py index b2fa5243f..9bb2da424 100644 --- a/module/plugins/hoster/XVideosCom.py +++ b/module/plugins/hoster/XVideosCom.py @@ -1,18 +1,23 @@ # -*- coding: utf-8 -*- import re -import urllib + +from urllib import unquote from module.plugins.Hoster import Hoster class XVideosCom(Hoster): - __name__ = "XVideos.com" - __version__ = "0.1" - __pattern__ = r'http://(?:www\.)?xvideos\.com/video([0-9]+)/.*' + __name__ = "XVideos.com" + __type__ = "hoster" + __version__ = "0.10" + + __pattern__ = r'http://(?:www\.)?xvideos\.com/video(\d+)' + __description__ = """XVideos.com hoster plugin""" - __author_name__ = "" - __author_mail__ = "" + __license__ = "GPLv3" + __authors__ = [] + def process(self, pyfile): site = self.load(pyfile.url) @@ -20,4 +25,4 @@ class XVideosCom(Hoster): re.search(r"<h2>([^<]+)<span", site).group(1), re.match(self.__pattern__, pyfile.url).group(1), ) - self.download(urllib.unquote(re.search(r"flv_url=([^&]+)&", site).group(1))) + self.download(unquote(re.search(r"flv_url=([^&]+)&", site).group(1))) diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py index 53f61836b..ef6da4a71 100644 --- a/module/plugins/hoster/Xdcc.py +++ b/module/plugins/hoster/Xdcc.py @@ -1,62 +1,48 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: jeix -""" - -from os.path import join -from os.path import exists -from os import makedirs import re -import sys -import time import socket import struct +import sys +import time + +from os import makedirs +from os.path import exists, join from select import select -from module.utils import save_join from module.plugins.Hoster import Hoster +from module.utils import save_join class Xdcc(Hoster): - __name__ = "Xdcc" + __name__ = "Xdcc" + __type__ = "hoster" __version__ = "0.32" - __pattern__ = r'xdcc://([^/]*?)(/#?.*?)?/.*?/#?\d+/?' # xdcc://irc.Abjects.net/#channel/[XDCC]|Shit/#0004/ - __type__ = "hoster" + __config__ = [("nick", "str", "Nickname", "pyload"), ("ident", "str", "Ident", "pyloadident"), ("realname", "str", "Realname", "pyloadreal")] + __description__ = """Download from IRC XDCC bot""" - __author_name__ = "jeix" - __author_mail__ = "jeix@hasnomail.com" + __license__ = "GPLv3" + __authors__ = [("jeix", "jeix@hasnomail.com")] + def setup(self): self.debug = 0 # 0,1,2 self.timeout = 30 self.multiDL = False + def process(self, pyfile): # change request type self.req = pyfile.m.core.requestFactory.getRequest(self.__name__, type="XDCC") self.pyfile = pyfile - for _ in xrange(0, 3): + for _i in xrange(0, 3): try: nmn = self.doDownload(pyfile.url) - self.logDebug("%s: Download of %s finished." % (self.__name__, nmn)) + self.logDebug("Download of %s finished." % nmn) return except socket.error, e: if hasattr(e, "errno"): @@ -64,24 +50,20 @@ class Xdcc(Hoster): else: errno = e.args[0] - if errno in (10054,): - self.logDebug("XDCC: Server blocked our ip, retry in 5 min") + if errno == 10054: + self.logDebug("Server blocked our ip, retry in 5 min") self.setWait(300) self.wait() continue - self.fail("Failed due to socket errors. Code: %d" % errno) + self.fail(_("Failed due to socket errors. Code: %d") % errno) + + self.fail(_("Server blocked our ip, retry again later manually")) - self.fail("Server blocked our ip, retry again later manually") def doDownload(self, url): self.pyfile.setStatus("waiting") # real link - download_folder = self.config['general']['download_folder'] - location = join(download_folder, self.pyfile.package().folder.decode(sys.getfilesystemencoding())) - if not exists(location): - makedirs(location) - m = re.match(r'xdcc://(.*?)/#?(.*?)/(.*?)/#?(\d+)/?', url) server = m.group(1) chan = m.group(2) @@ -98,7 +80,7 @@ class Xdcc(Hoster): elif ln == 1: host, port = temp[0], 6667 else: - self.fail("Invalid hostname for IRC Server (%s)" % server) + self.fail(_("Invalid hostname for IRC Server: %s") % server) ####################### # CONNECT TO IRC AND IDLE FOR REAL LINK @@ -135,7 +117,7 @@ class Xdcc(Hoster): if (dl_time + self.timeout) < time.time(): # todo: add in config sock.send("QUIT :byebye\r\n") sock.close() - self.fail("XDCC Bot did not answer") + self.fail(_("XDCC Bot did not answer")) fdset = select([sock], [], [], 0) if sock not in fdset[0]: @@ -155,7 +137,7 @@ class Xdcc(Hoster): sock.send("PONG %s\r\n" % first[1]) if first[0] == "ERROR": - self.fail("IRC-Error: %s" % line) + self.fail(_("IRC-Error: %s") % line) msg = line.split(None, 3) if len(msg) != 4: @@ -168,31 +150,31 @@ class Xdcc(Hoster): "text": msg[3][1:] } - if nick == msg["target"][0:len(nick)] and "PRIVMSG" == msg["action"]: - if msg["text"] == "\x01VERSION\x01": - self.logDebug("XDCC: Sending CTCP VERSION.") + if nick == msg['target'][0:len(nick)] and "PRIVMSG" == msg['action']: + if msg['text'] == "\x01VERSION\x01": + self.logDebug("Sending CTCP VERSION") sock.send("NOTICE %s :%s\r\n" % (msg['origin'], "pyLoad! IRC Interface")) - elif msg["text"] == "\x01TIME\x01": - self.logDebug("Sending CTCP TIME.") + elif msg['text'] == "\x01TIME\x01": + self.logDebug("Sending CTCP TIME") sock.send("NOTICE %s :%d\r\n" % (msg['origin'], time.time())) - elif msg["text"] == "\x01LAG\x01": + elif msg['text'] == "\x01LAG\x01": pass # don't know how to answer - if not (bot == msg["origin"][0:len(bot)] - and nick == msg["target"][0:len(nick)] - and msg["action"] in ("PRIVMSG", "NOTICE")): + if not (bot == msg['origin'][0:len(bot)] + and nick == msg['target'][0:len(nick)] + and msg['action'] in ("PRIVMSG", "NOTICE")): continue if self.debug is 1: - print "%s: %s" % (msg["origin"], msg["text"]) + print "%s: %s" % (msg['origin'], msg['text']) - if "You already requested that pack" in msg["text"]: + if "You already requested that pack" in msg['text']: retry = time.time() + 300 - if "you must be on a known channel to request a pack" in msg["text"]: - self.fail("Wrong channel") + if "you must be on a known channel to request a pack" in msg['text']: + self.fail(_("Wrong channel")) - m = re.match('\x01DCC SEND (.*?) (\d+) (\d+)(?: (\d+))?\x01', msg["text"]) + m = re.match('\x01DCC SEND (.*?) (\d+) (\d+)(?: (\d+))?\x01', msg['text']) if m: done = True @@ -205,13 +187,16 @@ class Xdcc(Hoster): self.req.filesize = int(m.group(4)) self.pyfile.name = packname - filename = save_join(location, packname) - self.logInfo("XDCC: Downloading %s from %s:%d" % (packname, ip, port)) + + download_folder = self.config['general']['download_folder'] + filename = save_join(download_folder, packname) + + self.logInfo(_("Downloading %s from %s:%d") % (packname, ip, port)) self.pyfile.setStatus("downloading") newname = self.req.download(ip, port, filename, sock, self.pyfile.setProgress) if newname and newname != filename: - self.logInfo("%(name)s saved as %(newname)s" % {"name": self.pyfile.name, "newname": newname}) + self.logInfo(_("%(name)s saved as %(newname)s") % {"name": self.pyfile.name, "newname": newname}) filename = newname # kill IRC socket diff --git a/module/plugins/hoster/YibaishiwuCom.py b/module/plugins/hoster/YibaishiwuCom.py index e51937924..3b4692933 100644 --- a/module/plugins/hoster/YibaishiwuCom.py +++ b/module/plugins/hoster/YibaishiwuCom.py @@ -1,60 +1,55 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + from module.common.json_layer import json_loads +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class YibaishiwuCom(SimpleHoster): - __name__ = "YibaishiwuCom" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?(?:u\.)?115.com/file/(?P<ID>\w+)' - __version__ = "0.12" + __name__ = "YibaishiwuCom" + __type__ = "hoster" + __version__ = "0.13" + + __pattern__ = r'http://(?:www\.)?(?:u\.)?115\.com/file/(?P<ID>\w+)' + __description__ = """115.com hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + - FILE_NAME_PATTERN = r"file_name: '(?P<N>[^']+)'" - FILE_SIZE_PATTERN = r"file_size: '(?P<S>[^']+)'" - FILE_OFFLINE_PATTERN = ur'<h3><i style="color:red;">哎呀!提取码不存在!不妨搜搜看吧!</i></h3>' + NAME_PATTERN = r'file_name: \'(?P<N>.+?)\'' + SIZE_PATTERN = r'file_size: \'(?P<S>.+?)\'' + OFFLINE_PATTERN = ur'<h3><i style="color:red;">哎呀!提取码不存在!不妨搜搜看吧!</i></h3>' + + LINK_PATTERN = r'(/\?ct=(pickcode|download)[^"\']+)' - AJAX_URL_PATTERN = r'(/\?ct=(pickcode|download)[^"\']+)' def handleFree(self): - found = re.search(self.AJAX_URL_PATTERN, self.html) - if not found: - self.parseError("AJAX URL") - url = found.group(1) - self.logDebug(('FREEUSER' if found.group(2) == 'download' else 'GUEST') + ' URL', url) - - response = json_loads(self.load("http://115.com" + url, decode=False)) - for mirror in (response['urls'] if 'urls' in response else response['data'] if 'data' in response else []): + m = re.search(self.LINK_PATTERN, self.html) + if m is None: + self.error(_("LINK_PATTERN not found")) + url = m.group(1) + self.logDebug(('FREEUSER' if m.group(2) == 'download' else 'GUEST') + ' URL', url) + + res = json_loads(self.load("http://115.com" + url, decode=False)) + if "urls" in res: + mirrors = res['urls'] + elif "data" in res: + mirrors = res['data'] + else: + mirrors = None + + for mr in mirrors: try: - url = mirror['url'].replace('\\', '') + url = mr['url'].replace("\\", "") self.logDebug("Trying URL: " + url) self.download(url) break except: continue else: - self.fail('No working link found') + self.fail(_("No working link found")) getInfo = create_getInfo(YibaishiwuCom) diff --git a/module/plugins/hoster/YoupornCom.py b/module/plugins/hoster/YoupornCom.py index 9dc1dc6e9..4bb2520e6 100644 --- a/module/plugins/hoster/YoupornCom.py +++ b/module/plugins/hoster/YoupornCom.py @@ -1,17 +1,21 @@ # -*- coding: utf-8 -*- import re + from module.plugins.Hoster import Hoster class YoupornCom(Hoster): - __name__ = "YoupornCom" - __type__ = "hoster" + __name__ = "YoupornCom" + __type__ = "hoster" + __version__ = "0.20" + __pattern__ = r'http://(?:www\.)?youporn\.com/watch/.+' - __version__ = "0.2" + __description__ = """Youporn.com hoster plugin""" - __author_name__ = "willnix" - __author_mail__ = "willnix@pyload.org" + __license__ = "GPLv3" + __authors__ = [("willnix", "willnix@pyload.org")] + def process(self, pyfile): self.pyfile = pyfile @@ -22,30 +26,33 @@ class YoupornCom(Hoster): pyfile.name = self.get_file_name() self.download(self.get_file_url()) + def download_html(self): url = self.pyfile.url self.html = self.load(url, post={"user_choice": "Enter"}, cookies=False) + def get_file_url(self): """ returns the absolute downloadable filepath """ - if self.html is None: + if not self.html: self.download_html() - file_url = re.search(r'(http://download\.youporn\.com/download/\d+\?save=1)">', self.html).group(1) - return file_url + return re.search(r'(http://download\.youporn\.com/download/\d+\?save=1)">', self.html).group(1) + def get_file_name(self): - if self.html is None: + if not self.html: self.download_html() - file_name_pattern = r"<title>(.*) - Free Porn Videos - YouPorn</title>" + file_name_pattern = r'<title>(.+) - ' return re.search(file_name_pattern, self.html).group(1).replace("&", "&").replace("/", "") + '.flv' + def file_exists(self): """ returns True or False """ - if self.html is None: + if not self.html: self.download_html() if re.search(r"(.*invalid video_id.*)", self.html) is not None: return False diff --git a/module/plugins/hoster/YourfilesTo.py b/module/plugins/hoster/YourfilesTo.py index c8c5c523c..83ab89110 100644 --- a/module/plugins/hoster/YourfilesTo.py +++ b/module/plugins/hoster/YourfilesTo.py @@ -1,24 +1,31 @@ # -*- coding: utf-8 -*- import re -import urllib + +from urllib import unquote + from module.plugins.Hoster import Hoster class YourfilesTo(Hoster): - __name__ = "YourfilesTo" - __type__ = "hoster" - __pattern__ = r'(http://)?(?:www\.)?yourfiles\.(to|biz)/\?d=[a-zA-Z0-9]+' + __name__ = "YourfilesTo" + __type__ = "hoster" __version__ = "0.21" + + __pattern__ = r'(http://)?(?:www\.)?yourfiles\.(to|biz)/\?d=\w+' + __description__ = """Youfiles.to hoster plugin""" - __author_name__ = ("jeix", "skydancer") - __author_mail__ = ("jeix@hasnomail.de", "skydancer@hasnomail.de") + __license__ = "GPLv3" + __authors__ = [("jeix", "jeix@hasnomail.de"), + ("skydancer", "skydancer@hasnomail.de")] + def process(self, pyfile): self.pyfile = pyfile self.prepare() self.download(self.get_file_url()) + def prepare(self): if not self.file_exists(): self.offline() @@ -27,11 +34,11 @@ class YourfilesTo(Hoster): wait_time = self.get_waiting_time() self.setWait(wait_time) - self.logDebug("%s: Waiting %d seconds." % (self.__name__, wait_time)) self.wait() + def get_waiting_time(self): - if self.html is None: + if not self.html: self.download_html() #var zzipitime = 15; @@ -43,31 +50,35 @@ class YourfilesTo(Hoster): return sec + def download_html(self): url = self.pyfile.url self.html = self.load(url) + def get_file_url(self): """ returns the absolute downloadable filepath """ url = re.search(r"var bla = '(.*?)';", self.html) if url: url = url.group(1) - url = urllib.unquote(url.replace("http://http:/http://", "http://").replace("dumdidum", "")) + url = unquote(url.replace("http://http:/http://", "http://").replace("dumdidum", "")) return url else: - self.fail("absolute filepath could not be found. offline? ") + self.error(_("Absolute filepath not found")) + def get_file_name(self): - if self.html is None: + if not self.html: self.download_html() return re.search("<title>(.*)</title>", self.html).group(1) + def file_exists(self): """ returns True or False """ - if self.html is None: + if not self.html: self.download_html() if re.search(r"HTTP Status 404", self.html) is not None: diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 330aae190..90c6df3c2 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -1,12 +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): @@ -18,11 +20,12 @@ def which(program): 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 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): @@ -32,10 +35,11 @@ def which(program): class YoutubeCom(Hoster): - __name__ = "YoutubeCom" - __type__ = "hoster" - __pattern__ = r'https?://(?:[^/]*\.)?youtube\.com/watch.*?[?&]v=.*' - __version__ = "0.39" + __name__ = "YoutubeCom" + __type__ = "hoster" + __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), @@ -43,37 +47,49 @@ 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") + __license__ = "GPLv3" + __authors__ = [("spoob", "spoob@pyload.org"), + ("zoidberg", "zoidberg@mujmail.cz")] + + + 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), - 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): - self.resumeDownload = self.multiDL = True + self.resumeDownload = True + self.multiDL = True + def process(self, pyfile): + pyfile.url = replace_patterns(pyfile.url, self.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): @@ -92,7 +108,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) @@ -109,7 +125,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" % @@ -138,6 +154,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) @@ -145,7 +163,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) diff --git a/module/plugins/hoster/ZDF.py b/module/plugins/hoster/ZDF.py index e718f283e..8d3de5b26 100644 --- a/module/plugins/hoster/ZDF.py +++ b/module/plugins/hoster/ZDF.py @@ -1,22 +1,26 @@ # -*- coding: utf-8 -*- import re + from xml.etree.ElementTree import fromstring from module.plugins.Hoster import Hoster -XML_API = "http://www.zdf.de/ZDFmediathek/xmlservice/web/beitragsDetails?id=%i" - +# Based on zdfm by Roland Beermann (http://github.com/enkore/zdfm/) class ZDF(Hoster): - # Based on zdfm by Roland Beermann - # http://github.com/enkore/zdfm/ - __name__ = "ZDF Mediathek" - __version__ = "0.8" - __pattern__ = r'http://(?:www\.)?zdf\.de/ZDFmediathek/[^0-9]*([0-9]+)[^0-9]*' + __name__ = "ZDF Mediathek" + __type__ = "hoster" + __version__ = "0.80" + + __pattern__ = r'http://(?:www\.)?zdf\.de/ZDFmediathek/\D*(\d+)\D*' + __description__ = """ZDF.de hoster plugin""" - __author_name__ = "" - __author_mail__ = "" + __license__ = "GPLv3" + __authors__ = [] + + XML_API = "http://www.zdf.de/ZDFmediathek/xmlservice/web/beitragsDetails?id=%i" + @staticmethod def video_key(video): @@ -25,21 +29,24 @@ class ZDF(Hoster): any(f.text == "progressive" for f in video.iter("facet")), ) + @staticmethod def video_valid(video): return video.findtext("url").startswith("http") and video.findtext("url").endswith(".mp4") and \ video.findtext("facets/facet").startswith("progressive") + @staticmethod def get_id(url): - return int(re.search(r"[^0-9]*([0-9]{4,})[^0-9]*", url).group(1)) + return int(re.search(r"\D*(\d{4,})\D*", url).group(1)) + def process(self, pyfile): - xml = fromstring(self.load(XML_API % self.get_id(pyfile.url))) + xml = fromstring(self.load(self.XML_API % self.get_id(pyfile.url))) status = xml.findtext("./status/statuscode") if status != "ok": - self.fail("Error retrieving manifest.") + self.fail(_("Error retrieving manifest")) video = xml.find("video") title = video.findtext("information/title") diff --git a/module/plugins/hoster/ZShareNet.py b/module/plugins/hoster/ZShareNet.py new file mode 100644 index 000000000..dc96facbe --- /dev/null +++ b/module/plugins/hoster/ZShareNet.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.DeadHoster import DeadHoster, create_getInfo + + +class ZShareNet(DeadHoster): + __name__ = "ZShareNet" + __type__ = "hoster" + __version__ = "0.21" + + __pattern__ = r'https?://(?:ww[2w]\.)?zshares?\.net/.+' + + __description__ = """ZShare.net hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("espes", None), + ("Cptn Sandwich", None)] + + +getInfo = create_getInfo(ZShareNet) diff --git a/module/plugins/hoster/ZeveraCom.py b/module/plugins/hoster/ZeveraCom.py index d3d67bedc..40ef5de0f 100644 --- a/module/plugins/hoster/ZeveraCom.py +++ b/module/plugins/hoster/ZeveraCom.py @@ -1,105 +1,42 @@ # -*- coding: utf-8 -*- -from module.plugins.Hoster import Hoster +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -class ZeveraCom(Hoster): - __name__ = "ZeveraCom" - __version__ = "0.21" - __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?zevera.com/.*' +class ZeveraCom(MultiHoster): + __name__ = "ZeveraCom" + __type__ = "hoster" + __version__ = "0.25" + + __pattern__ = r'http://(?:www\.)?zevera\.com/.+' + __description__ = """Zevera.com hoster plugin""" - __author_name__ = "zoidberg" - __author_mail__ = "zoidberg@mujmail.cz" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - def setup(self): - self.resumeDownload = self.multiDL = True - self.chunkLimit = 1 - def process(self, pyfile): - if not self.account: - self.logError(_("Please enter your %s account or deactivate this plugin") % "zevera.com") - self.fail("No zevera.com account provided") + def setup(self): + self.resumeDownload = True + self.multiDL = True + self.chunkLimit = 1 - self.logDebug("zevera.com: Old URL: %s" % pyfile.url) - if self.account.getAPIData(self.req, cmd="checklink", olink=pyfile.url) != "Alive": - self.fail("Offline or not downloadable - contact Zevera support") + def handlePremium(self): + if self.account.getAPIData(self.req, cmd="checklink", olink=self.pyfile.url) != "Alive": + self.fail(_("Offline or not downloadable")) - header = self.account.getAPIData(self.req, just_header=True, cmd="generatedownloaddirect", olink=pyfile.url) + header = self.account.getAPIData(self.req, just_header=True, cmd="generatedownloaddirect", olink=self.pyfile.url) if not "location" in header: - self.fail("Unable to initialize download - contact Zevera support") - - self.download(header['location'], disposition=True) - - check = self.checkDownload({"error": 'action="ErrorDownload.aspx'}) - if check == "error": - self.fail("Error response received - contact Zevera support") - - # BitAPI not used - defunct, probably abandoned by Zevera - # - # api_url = "http://zevera.com/API.ashx" - # - # def process(self, pyfile): - # if not self.account: - # self.logError(_("Please enter your zevera.com account or deactivate this plugin")) - # self.fail("No zevera.com account provided") - # - # self.logDebug("zevera.com: Old URL: %s" % pyfile.url) - # - # last_size = retries = 0 - # olink = pyfile.url #quote(pyfile.url.encode('utf_8')) - # - # for _ in xrange(100): - # self.retData = self.account.loadAPIRequest(self.req, cmd = 'download_request', olink = olink) - # self.checkAPIErrors(self.retData) - # - # if self.retData['FileInfo']['StatusID'] == 100: - # break - # elif self.retData['FileInfo']['StatusID'] == 99: - # self.fail('Failed to initialize download (99)') - # else: - # if self.retData['FileInfo']['Progress']['BytesReceived'] <= last_size: - # if retries >= 6: - # self.fail('Failed to initialize download (%d)' % self.retData['FileInfo']['StatusID'] ) - # retries += 1 - # else: - # retries = 0 - # - # last_size = self.retData['FileInfo']['Progress']['BytesReceived'] - # - # self.setWait(self.retData['Update_Wait']) - # self.wait() - # - # pyfile.name = self.retData['FileInfo']['RealFileName'] - # pyfile.size = self.retData['FileInfo']['FileSizeInBytes'] - # - # self.retData = self.account.loadAPIRequest(self.req, cmd = 'download_start', - # FileID = self.retData['FileInfo']['FileID']) - # self.checkAPIErrors(self.retData) - # - # self.download(self.api_url, get = { - # 'cmd': "open_stream", - # 'login': self.account.loginname, - # 'pass': self.account.password, - # 'FileID': self.retData['FileInfo']['FileID'], - # 'startBytes': 0 - # } - # ) - # - # def checkAPIErrors(self, retData): - # if not retData: - # self.fail('Unknown API response') - # - # if retData['ErrorCode']: - # self.logError(retData['ErrorCode'], retData['ErrorMessage']) - # #self.fail('ERROR: ' + retData['ErrorMessage']) - # - # if pyfile.size / 1024000 > retData['AccountInfo']['AvailableTODAYTrafficForUseInMBytes']: - # self.logWarning("Not enough data left to download the file") - # - # def crazyDecode(self, ustring): - # # accepts decoded ie. unicode string - API response is double-quoted, double-utf8-encoded - # # no idea what the proper order of calling these functions would be :-/ - # return html_unescape(unquote(unquote(ustring.replace( - # '@DELIMITER@','#'))).encode('raw_unicode_escape').decode('utf-8')) + self.fail(_("Unable to initialize download")) + + self.link = header['location'] + + + def checkFile(self): + super(ZeveraCom, self).checkFile() + + if self.checkDownload({"error": 'action="ErrorDownload.aspx'}) is "error": + self.fail(_("Error response received - contact Zevera support")) + + +getInfo = create_getInfo(ZeveraCom) diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index b4fa4f8ac..73dd1f22d 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -1,71 +1,66 @@ # -*- coding: utf-8 -*- -# Test links (random.bin): -# http://www13.zippyshare.com/v/18665333/file.html - import re +from urlparse import urljoin + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ZippyshareCom(SimpleHoster): - __name__ = "ZippyshareCom" - __type__ = "hoster" - __pattern__ = r'(?P<HOST>http://www\d{0,2}\.zippyshare.com)/v(?:/|iew.jsp.*key=)(?P<KEY>\d+)' - __version__ = "0.49" + __name__ = "ZippyshareCom" + __type__ = "hoster" + __version__ = "0.65" + + __pattern__ = r'(?P<HOST>http://www\d{0,2}\.zippyshare\.com)/v(?:/|iew\.jsp.*key=)(?P<KEY>\d+)' + __description__ = """Zippyshare.com hoster plugin""" - __author_name__ = ("spoob", "zoidberg", "stickell", "skylab") - __author_mail__ = ("spoob@pyload.org", "zoidberg@mujmail.cz", "l.stickell@yahoo.it", "development@sky-lab.de") + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + NAME_PATTERN = r'("\d{6,}/"[ ]*\+.+?"/|<title>Zippyshare.com - )(?P<N>.+?)("|</title>)' + SIZE_PATTERN = r'>Size:.+?">(?P<S>[\d.,]+) (?P<U>[\w^_]+)' - FILE_NAME_PATTERN = r'<title>Zippyshare\.com - (?P<N>[^<]+)</title>' - FILE_SIZE_PATTERN = r'>Size:</font>\s*<font [^>]*>(?P<S>[0-9.,]+) (?P<U>[kKMG]+)i?B</font><br />' - FILE_INFO_PATTERN = r'document\.getElementById\(\'dlbutton\'\)\.href = "[^;]*/(?P<N>[^"]+)";' - FILE_OFFLINE_PATTERN = r'>File does not exist on this server</div>' + OFFLINE_PATTERN = r'>File does not exist on this server<' + + COOKIES = [("zippyshare.com", "ziplocale", "en")] - SH_COOKIES = [('zippyshare.com', 'ziplocale', 'en')] def setup(self): - self.multiDL = True + self.multiDL = True + self.chunkLimit = -1 + self.resumeDownload = True + def handleFree(self): - url = self.get_file_url() - if not url: - self.fail("Download URL not found.") - self.logDebug("Download URL: %s" % url) + url = self.get_link() self.download(url) - def get_file_url(self): - """returns the absolute downloadable filepath""" - url_parts = re.search(r'(addthis:url="(http://www(\d+).zippyshare.com/v/(\d*)/file.html))', self.html) - number = url_parts.group(4) - check = re.search(r'<script type="text/javascript">([^<]*?)(var a = (\d*);)', self.html) - if check: - a = int(re.search(r'<script type="text/javascript">([^<]*?)(var a = (\d*);)', self.html).group(3)) - k = int(re.search(r'<script type="text/javascript">([^<]*?)(\d*%(\d*))', self.html).group(3)) - checksum = ((a + 3) % k) * ((a + 3) % 3) + 18 - else: - # This might work but is insecure - # checksum = eval(re.search("((\d*)\s\%\s(\d*)\s\+\s(\d*)\s\%\s(\d*))", self.html).group(0)) - - m = re.search(r"((?P<a>\d*)\s%\s(?P<b>\d*)\s\+\s(?P<c>\d*)\s%\s(?P<k>\d*))", self.html) - if not m: - self.parseError("Unable to detect values to calculate direct link") - a = int(m.group("a")) - b = int(m.group("b")) - c = int(m.group("c")) - k = int(m.group("k")) - if a == c: - checksum = ((a % b) + (a % k)) + + def get_checksum(self): + try: + m = re.search(r'\+[ ]*\((\d+)[ ]*\%[ ]*(\d+)[ ]*\+[ ]*(\d+)[ ]*\%[ ]*(\d+)\)[ ]*\+', self.html) + if m: + a1, a2, c1, c2 = map(int, m.groups()) + b = (a1 % a2) + (c1 % c2) else: - checksum = ((a % b) + (c % k)) + a1, a2 = map(int, re.search(r'\(\'downloadB\'\).omg = (\d+)%(\d+)' , self.html).groups()) + c1, c2 = map(int, re.search(r'\(\'downloadB\'\).omg\) \* \((\d+)%(\d+)', self.html).groups()) + b = (a1 % a2) * (c1 % c2) + 18 + + except Exception, e: + self.error(_("Unable to calculate checksum"), e) - self.logInfo('Checksum: %s' % checksum) + else: + return b - filename = re.search(r'>Name:</font>\s*<font [^>]*>(?P<N>[^<]+)</font><br />', self.html).group('N') - url = "/d/%s/%s/%s" % (number, checksum, filename) - self.logInfo(self.file_info['HOST'] + url) - return self.file_info['HOST'] + url + def get_link(self): + checksum = self.get_checksum() + p_url = '/'.join(("d", self.info['pattern']['KEY'], str(checksum), self.pyfile.name)) + dl_link = urljoin(self.info['pattern']['HOST'], p_url) + return dl_link getInfo = create_getInfo(ZippyshareCom) |