# -*- coding: utf-8 -*- import re from time import sleep, time from module.network.RequestFactory import getURL from module.plugins.Hoster import Hoster from module.plugins.Plugin import chunks 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=" 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 + ids, decode=True) if api is None or len(api) < 10: self.logDebug("Prefetch failed") return if api.find("unknown_auth") >= 0: print self.logDebug("Outdated auth code") return result = [] for i, r in enumerate(api.splitlines()): try: tmp = r.split(";") try: size = int(tmp[2]) except: size = 0 result.append((tmp[1], size, 2 if tmp[3] == "online" else 1, chunk[i])) except: self.logDebug("Error while processing response: %s" % r) yield result class NetloadIn(Hoster): __name__ = "NetloadIn" __type__ = "hoster" __version__ = "0.45" __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.download_api_data() 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?id=2&lang=en") if '