# -*- coding: utf-8 -*- import re from time import sleep, time from pyload.network.RequestFactory import getURL from pyload.plugins.Hoster import Hoster from pyload.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: print "Netload prefetch: failed " return if api.find("unknown_auth") >= 0: print "Netload prefetch: 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: print "Netload prefetch: Error while processing response: " print 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""" __author_name__ = ("spoob", "RaNaN", "Gregy") __author_mail__ = ("spoob@pyload.org", "ranan@pyload.org", "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("Netload: Use Premium Account") settings = self.load("http://www.netload.in/index.php?id=2&lang=en") if '