# -*- coding: utf-8 -*- import re from pycurl import FOLLOWLOCATION, LOW_SPEED_TIME from random import random from urllib import unquote from urlparse import urlparse from module.network.RequestFactory import getURL from module.plugins.internal.CaptchaService import ReCaptcha, SolveMedia from module.plugins.internal.SimpleHoster import create_getInfo, replace_patterns, set_cookies, SimpleHoster from module.plugins.Plugin import Fail from module.utils import html_unescape class XFSPHoster(SimpleHoster): __name__ = "XFSPHoster" __type__ = "hoster" __version__ = "0.04" __pattern__ = None __description__ = """XFileSharingPro hoster plugin""" __license__ = "GPLv3" __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), ("stickell", "l.stickell@yahoo.it"), ("Walter Purcaro", "vuolter@gmail.com")] HOSTER_NAME = None FILE_URL_REPLACEMENTS = [] COOKIES = [(HOSTER_NAME, "lang", "english")] FILE_INFO_PATTERN = r'Filename:(?P[^<]+)\s*.*?\((?P[^<]+)\)' FILE_NAME_PATTERN = r'[\d\.\,]+) ?(?P[\w^_]+)?\)' OFFLINE_PATTERN = r'>\s*\w+ (Not Found|file (was|has been) removed)' TEMP_OFFLINE_PATTERN = r'>\s*\w+ server (is in )?(maintenance|maintainance)' WAIT_PATTERN = r'.*?>(\d+)' OVR_LINK_PATTERN = r'

Download Link

\s*]*>([^<]+)' LINK_PATTERN = None #: final download url pattern CAPTCHA_PATTERN = r'(http://[^"\']+?/captchas?/[^"\']+)' CAPTCHA_DIV_PATTERN = r'>Enter code.*?(.+?)' RECAPTCHA_PATTERN = None SOLVEMEDIA_PATTERN = None ERROR_PATTERN = r'class=["\']err["\'][^>]*>(.+?)", " ", self.errmsg)) if 'wait' in self.errmsg: wait_time = sum([int(v) * {"hour": 3600, "minute": 60, "second": 1}[u] for v, u in re.findall(r'(\d+)\s*(hour|minute|second)', self.errmsg)]) self.wait(wait_time, True) elif 'captcha' in self.errmsg: self.invalidCaptcha() elif 'premium' in self.errmsg and 'require' in self.errmsg: self.fail("File can be downloaded by premium users only") elif 'limit' in self.errmsg: self.wait(1 * 60 * 60, True) self.retry(25) elif 'countdown' in self.errmsg or 'Expired' in self.errmsg: self.retry() elif 'maintenance' in self.errmsg or 'maintainance' in self.errmsg: self.tempOffline() elif 'download files up to' in self.errmsg: self.fail("File too large for free download") else: self.fail(self.errmsg) else: self.errmsg = None return self.errmsg def getPostParameters(self): for _ in xrange(3): if not self.errmsg: self.checkErrors() if hasattr(self, "FORM_PATTERN"): action, inputs = self.parseHtmlForm(self.FORM_PATTERN) else: action, inputs = self.parseHtmlForm(input_names={"op": re.compile("^download")}) if not inputs: action, inputs = self.parseHtmlForm('F1') if not inputs: if self.errmsg: self.retry() else: self.error("Form not found") self.logDebug(self.HOSTER_NAME, inputs) if 'op' in inputs and inputs['op'] in ("download2", "download3"): if "password" in inputs: if self.passwords: inputs['password'] = self.passwords.pop(0) else: self.fail("No or invalid passport") if not self.premium: m = re.search(self.WAIT_PATTERN, self.html) if m: wait_time = int(m.group(1)) + 1 self.setWait(wait_time, False) else: wait_time = 0 self.captcha = self.handleCaptcha(inputs) if wait_time: self.wait() self.errmsg = None return inputs else: inputs['referer'] = self.pyfile.url if self.premium: inputs['method_premium'] = "Premium Download" if 'method_free' in inputs: del inputs['method_free'] else: inputs['method_free'] = "Free Download" if 'method_premium' in inputs: del inputs['method_premium'] self.html = self.load(self.pyfile.url, post=inputs, ref=True) self.errmsg = None else: self.error('FORM: %s' % (inputs['op'] if 'op' in inputs else 'UNKNOWN')) def handleCaptcha(self, inputs): m = re.search(self.CAPTCHA_PATTERN, self.html) if m: captcha_url = m.group(1) inputs['code'] = self.decryptCaptcha(captcha_url) return 1 m = re.search(self.CAPTCHA_DIV_PATTERN, self.html, re.S) if m: captcha_div = m.group(1) self.logDebug(captcha_div) numerals = re.findall(r'(\d)', html_unescape(captcha_div)) inputs['code'] = "".join([a[1] for a in sorted(numerals, key=lambda num: int(num[0]))]) self.logDebug("CAPTCHA", inputs['code'], numerals) return 2 recaptcha = ReCaptcha(self) try: captcha_key = re.search(self.RECAPTCHA_PATTERN, self.html).group(1) except: captcha_key = recaptcha.detect_key() if captcha_key: self.logDebug("ReCaptcha key: %s" % captcha_key) inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge(captcha_key) return 3 solvemedia = SolveMedia(self) try: captcha_key = re.search(self.SOLVEMEDIA_PATTERN, self.html).group(1) except: captcha_key = solvemedia.detect_key() if captcha_key: self.logDebug("SolveMedia key: %s" % captcha_key) inputs['adcopy_challenge'], inputs['adcopy_response'] = solvemedia.challenge(captcha_key) return 4 return 0