# -*- coding: utf-8 -*- import re import time import urlparse from pyload.network.RequestFactory import getURL from pyload.plugin.Hoster import Hoster from pyload.plugin.Plugin import chunks from pyload.plugin.captcha.ReCaptcha 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 '