#!/usr/bin/env python # -*- coding: utf-8 -*- import re import string from module.plugins.Hoster import Hoster from module.plugins.ReCaptcha import ReCaptcha from module.plugins.Plugin import chunks from module.network.RequestFactory import getURL from module.utils import decode try: from json import loads as json_loads except ImportError: # pragma: no cover from module.lib.simplejson import loads as json_loads def getInfo(urls): for chunk in chunks(urls, 20): result=[] ids=dict() for url in chunk: id = getId(url) if id: ids[id]=url else: result.append((none,0,1,url)) if len(ids) > 0: check_url="http://api.filesonic.com/link?method=getInfo&format=json&ids=" + ",".join(ids.keys()) response = json_loads(getURL(check_url).decode("utf8","ignore")) for item in response["FSApi_Link"]["getInfo"]["response"]["links"]: if item["status"] != "AVAILABLE": result.append((None,0,1,ids[item["id"]])) else: result.append((item["filename"],item["size"],2,ids[str(item["id"])])) yield result def getId(url): match = re.search(FilesonicCom.FILE_ID_PATTERN,url) if match: return string.replace(match.group("id"),"/","-") else: return None class FilesonicCom(Hoster): __name__ = "FilesonicCom" __type__ = "hoster" __pattern__ = r"http://[\w\.]*?(sharingmatrix|filesonic)\..*?/file/(([a-z][0-9]+/)?[0-9]+)(/.*)?" __version__ = "0.3" __description__ = """FilesonicCom und Sharingmatrix Download Hoster""" __author_name__ = ("jeix","paulking") __author_mail__ = ("jeix@hasnomail.de","") URL_DOMAIN_PATTERN = r'(?P.*?)(?P.(filesonic|sharingmatrix)\..+?)(?P/.*)' FILE_ID_PATTERN = r'/file/(?P([a-z][0-9]+/)?[0-9]+)(/.*)?' FILE_LINK_PATTERN = r'

Start download' WAIT_TIME_PATTERN = r'countDownDelay = (?P\d+)' WAIT_TM_PATTERN = r"name='tm' value='(.*?)' />" WAIT_TM_HASH_PATTERN = r"name='tm_hash' value='(.*?)' />" CAPTCHA_TYPE1_PATTERN = r'Recaptcha.create\("(.*?)",' CAPTCHA_TYPE2_PATTERN = r'id="recaptcha_image"> 300: self.wantReconnect = True self.setWait(wait) self.log.debug("%s: Waiting %d seconds." % (self.__name__, wait)) self.wait() tm = re.search(self.WAIT_TM_PATTERN, self.html) tm_hash = re.search(self.WAIT_TM_HASH_PATTERN, self.html) if tm and tm_hash: tm = tm.group(1) tm_hash = tm_hash.group(1) self.html = self.load(url, post={"tm":tm,"tm_hash":tm_hash}) self.handleErrors() else: self.html = self.load(url) self.handleErrors() def handleErrors(self): if "This file is available for premium users only." in self.html: self.fail("need premium account for file") if "The file that you're trying to download is larger than" in self.html: self.fail("need premium account for file") if "Free users may only download 1 file at a time" in self.html: self.fail("only 1 file at a time for free users") if "Free user can not download files" in self.html: self.fail("need premium account for file") if "Download session in progress" in self.html: self.fail("already downloading") if "This file is password protected" in self.html: self.fail("This file is password protected") if "An Error Occurred" in self.html: self.fail("A server error occured.") if "This file was deleted" in self.html: self.offline()