# -*- coding: utf-8 -*- import re from urlparse import urljoin from time import time 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" 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(1) + ";" 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.48" __pattern__ = r'https?://(?:[^/]*\.)?netload\.in/(?:datei(.*?)(?:\.htm|/)|index\.php?id=10&file_id=)' __description__ = """Netload.in hoster plugin""" __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.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 '