From 8e7d14bae4d3c836f029a1235eb227380acc3f75 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 16 Feb 2015 21:59:10 +0100 Subject: Fix plugins to work on 0.4.10 --- pyload/plugin/hoster/NetloadIn.py | 298 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 298 insertions(+) create mode 100644 pyload/plugin/hoster/NetloadIn.py (limited to 'pyload/plugin/hoster/NetloadIn.py') diff --git a/pyload/plugin/hoster/NetloadIn.py b/pyload/plugin/hoster/NetloadIn.py new file mode 100644 index 000000000..2ed298ffa --- /dev/null +++ b/pyload/plugin/hoster/NetloadIn.py @@ -0,0 +1,298 @@ +# -*- coding: utf-8 -*- + +import re + +from urlparse import urljoin +from time import time + +from pyload.network.RequestFactory import getURL +from pyload.plugin.Hoster import Hoster +from pyload.plugin.Plugin import chunks +from pyload.plugin.captcha import ReCaptcha + + +def getInfo(urls): + ## returns list of tupels (name, size (in bytes), status (see database.File), url) + + apiurl = "http://api.netload.in/info.php" + id_regex = re.compile(NetloadIn.__pattern__) + urls_per_query = 80 + + for chunk in chunks(urls, urls_per_query): + ids = "" + for url in chunk: + match = id_regex.search(url) + if match: + ids = ids + match.group('ID') + ";" + + api = getURL(apiurl, + get={'auth' : "Zf9SnQh9WiReEsb18akjvQGqT0I830e8", + 'bz' : 1, + 'md5' : 1, + 'file_id': ids}, + decode=True) + + if api is None or len(api) < 10: + self.logDebug("Prefetch failed") + return + + if api.find("unknown_auth") >= 0: + self.logDebug("Outdated auth code") + return + + result = [] + + for i, r in enumerate(api.splitlines()): + try: + tmp = r.split(";") + + try: + size = int(tmp[2]) + except Exception: + size = 0 + + 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" + __version__ = "0.49" + + __pattern__ = r'https?://(?:www\.)?netload\.in/(?Pdatei|index\.php\?id=10&file_id=)(?P\w+)' + + __description__ = """Netload.in hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("spoob", "spoob@pyload.org"), + ("RaNaN", "ranan@pyload.org"), + ("Gregy", "gregy@gregy.cz")] + + + RECAPTCHA_KEY = "6LcLJMQSAAAAAJzquPUPKNovIhbK6LpSqCjYrsR1" + + + 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.api_load() + + if self.api_data and self.api_data['filename']: + self.pyfile.name = self.api_data['filename'] + + if self.premium: + self.logDebug("Use Premium Account") + + settings = self.load("http://www.netload.in/index.php", get={'id': 2, 'lang': "en"}) + + if '