def getRtUpdate(self): rtUpdate = self.getStorage("rtUpdate") if not rtUpdate: if ( self.getStorage("version") != self.__version__ or int(self.getStorage("timestamp", 0)) + 86400000 < timestamp() ): # that's right, we are even using jdownloader updates rtUpdate = getURL("http://update0.jdownloader.org/pluginstuff/tbupdate.js") rtUpdate = self.decrypt(rtUpdate.splitlines()[1]) # but we still need to fix the syntax to work with other engines than rhino rtUpdate = re.sub( r"for each\(var (\w+) in(\[[^\]]+\])\)\{", r"zza=\2;for(var zzi=0;zzi<zza.length;zzi++){\1=zza[zzi];", rtUpdate, ) rtUpdate = re.sub(r"for\((\w+)=", r"for(var \1=", rtUpdate) self.logDebug("rtUpdate") self.setStorage("rtUpdate", rtUpdate) self.setStorage("timestamp", timestamp()) self.setStorage("version", self.__version__) else: self.logError("Unable to download, wait for update...") self.tempOffline() return rtUpdate
def getRtUpdate(self): rtUpdate = self.getStorage("rtUpdate") if not rtUpdate: if self.getStorage("version") != self.__version__ or int( self.getStorage("timestamp", 0)) + 86400000 < timestamp(): # that's right, we are even using jdownloader updates rtUpdate = getURL( "http://update0.jdownloader.org/pluginstuff/tbupdate.js") rtUpdate = self.decrypt(rtUpdate.splitlines()[1]) # but we still need to fix the syntax to work with other engines than rhino rtUpdate = re.sub( r'for each\(var (\w+) in(\[[^\]]+\])\)\{', r'zza=\2;for(var zzi=0;zzi<zza.length;zzi++){\1=zza[zzi];', rtUpdate) rtUpdate = re.sub(r"for\((\w+)=", r"for(var \1=", rtUpdate) self.logDebug("rtUpdate") self.setStorage("rtUpdate", rtUpdate) self.setStorage("timestamp", timestamp()) self.setStorage("version", self.__version__) else: self.logError("Unable to download, wait for update...") self.tempOffline() return rtUpdate
def get_swf_values(self, swf_url, swfdump): self.logDebug('Parsing values from %s' % swf_url) multiply = modulo = None fd, fpath = tempfile.mkstemp() try: swf_data = self.load(swf_url) os.write(fd, swf_data) p = subprocess.Popen([swfdump, '-a', fpath], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() if err: self.logError(err) else: m_str = re.search(r'::break.*?{(.*?)}', out, re.S).group(1) multiply = re.search(r'pushbyte (\d+)', m_str).group(1) modulo = re.search(r'pushint (\d+)', m_str).group(1) finally: os.close(fd) os.remove(fpath) if multiply and modulo: self.setStorage("multiply", multiply) self.setStorage("modulo", modulo) self.setStorage("swf_sts", 1) self.setStorage("version", self.__version__) else: self.logError("Parsing SWF failed: swfdump not installed or plugin out of date") self.setStorage("swf_sts", 2) self.setStorage("swf_stamp", timestamp()) return multiply, modulo
def get_file_url(self): """ returns the absolute downloadable filepath """ url = multiply = modulo = None found = re.search(self.DOWNLOAD_URL_PATTERN, self.html, re.S) if found: #Method #1: JS eval js = "\n".join(found.groups()) regex = r"document.getElementById\(\\*'dlbutton\\*'\).omg" omg = re.search(regex + r" = ([^;]+);", js).group(1) js = re.sub(regex + r" = ([^;]+);", '', js) js = re.sub(regex, omg, js) url = self.js.eval(js) else: #Method #2: SWF eval seed_search = re.search(self.SEED_PATTERN, self.html) if seed_search: swf_url, file_seed = seed_search.groups() swf_sts = self.getStorage("swf_sts") swf_stamp = int(self.getStorage("swf_stamp") or 0) swf_version = self.getStorage("version") self.logDebug("SWF", swf_sts, swf_stamp, swf_version) if not swf_sts: self.logDebug('Using default values') multiply, modulo = self.LAST_KNOWN_VALUES elif swf_sts == "1": self.logDebug('Using stored values') multiply = self.getStorage("multiply") modulo = self.getStorage("modulo") elif swf_sts == "2": if swf_version < self.__version__: self.logDebug('Reverting to default values') self.setStorage("swf_sts", "") self.setStorage("version", self.__version__) multiply, modulo = self.LAST_KNOWN_VALUES elif (swf_stamp + 3600000) < timestamp(): swfdump = self.get_swfdump_path() if swfdump: multiply, modulo = self.get_swf_values( self.file_info['HOST'] + swf_url, swfdump) else: self.logWarning( "Swfdump not found. Install swftools to bypass captcha." ) if multiply and modulo: self.logDebug("TIME = (%s * %s) %s" % (file_seed, multiply, modulo)) url = "/download?key=%s&time=%d" % ( self.file_info['KEY'], (int(file_seed) * int(multiply)) % int(modulo)) if not url: #Method #3: Captcha url = self.do_recaptcha() return self.file_info['HOST'] + url
def get_file_url(self): """ returns the absolute downloadable filepath """ url = multiply = modulo = None found = re.search(self.DOWNLOAD_URL_PATTERN, self.html, re.S) if found: #Method #1: JS eval js = "\n".join(found.groups()) regex = r"document.getElementById\(\\*'dlbutton\\*'\).omg" omg = re.search(regex + r" = ([^;]+);", js).group(1) js = re.sub(regex + r" = ([^;]+);", '', js) js = re.sub(regex, omg, js) url = self.js.eval(js) else: #Method #2: SWF eval seed_search = re.search(self.SEED_PATTERN, self.html) if seed_search: swf_url, file_seed = seed_search.groups() swf_sts = self.getStorage("swf_sts") swf_stamp = int(self.getStorage("swf_stamp") or 0) swf_version = self.getStorage("version") self.logDebug("SWF", swf_sts, swf_stamp, swf_version) if not swf_sts: self.logDebug('Using default values') multiply, modulo = self.LAST_KNOWN_VALUES elif swf_sts == "1": self.logDebug('Using stored values') multiply = self.getStorage("multiply") modulo = self.getStorage("modulo") elif swf_sts == "2": if swf_version < self.__version__: self.logDebug('Reverting to default values') self.setStorage("swf_sts", "") self.setStorage("version", self.__version__) multiply, modulo = self.LAST_KNOWN_VALUES elif (swf_stamp + 3600000) < timestamp(): swfdump = self.get_swfdump_path() if swfdump: multiply, modulo = self.get_swf_values(self.file_info['HOST'] + swf_url, swfdump) else: self.logWarning("Swfdump not found. Install swftools to bypass captcha.") if multiply and modulo: self.logDebug("TIME = (%s * %s) %s" % (file_seed, multiply, modulo)) url = "/download?key=%s&time=%d" % (self.file_info['KEY'], (int(file_seed) * int(multiply)) % int(modulo)) if not url: #Method #3: Captcha url = self.do_recaptcha() return self.file_info['HOST'] + url
def handlePremium(self, pyfile): postData = { 'action': 'get_link', 'code': self.info['pattern']['ID'], 'pass': '******' } self.html = self.load( 'http://uploading.com/files/get/?JsHttpRequest=%d-xml' % timestamp(), post=postData) url = re.search(r'"link"\s*:\s*"(.*?)"', self.html) if url: self.link = url.group(1).replace("\\/", "/") raise Exception("Plugin defect")
def swf_eval(self): multiply = modulo = None seed_search = re.search(self.SEED_PATTERN, self.html) if seed_search: swf_url, file_seed = seed_search.groups() swf_sts = self.getStorage("swf_sts") swf_stamp = int(self.getStorage("swf_stamp") or 0) swf_version = self.getStorage("version") self.logDebug("SWF", swf_sts, swf_stamp, swf_version) if not swf_sts: self.logDebug('Using default values') multiply, modulo = self.LAST_KNOWN_VALUES elif swf_sts == "1": self.logDebug('Using stored values') multiply = self.getStorage("multiply") modulo = self.getStorage("modulo") elif swf_sts == "2": if swf_version < self.__version__: self.logDebug('Reverting to default values') self.setStorage("swf_sts", "") self.setStorage("version", self.__version__) multiply, modulo = self.LAST_KNOWN_VALUES elif (swf_stamp + 3600000) < timestamp(): swfdump = self.get_swfdump_path() if swfdump: multiply, modulo = self.get_swf_values( self.file_info['HOST'] + swf_url, swfdump) else: self.logWarning( "Swfdump not found. Install swftools to bypass captcha." ) if multiply and modulo: self.logDebug("TIME = (%s * %s) %s" % (file_seed, multiply, modulo)) url = "/download?key=%s&time=%d" % ( self.file_info['KEY'], (int(file_seed) * int(multiply)) % int(modulo)) return url return None
def swf_eval(self): multiply = modulo = None seed_search = re.search(self.SEED_PATTERN, self.html) if seed_search: swf_url, file_seed = seed_search.groups() swf_sts = self.getStorage("swf_sts") swf_stamp = int(self.getStorage("swf_stamp") or 0) swf_version = self.getStorage("version") self.logDebug("SWF", swf_sts, swf_stamp, swf_version) if not swf_sts: self.logDebug('Using default values') multiply, modulo = self.LAST_KNOWN_VALUES elif swf_sts == "1": self.logDebug('Using stored values') multiply = self.getStorage("multiply") modulo = self.getStorage("modulo") elif swf_sts == "2": if swf_version < self.__version__: self.logDebug('Reverting to default values') self.setStorage("swf_sts", "") self.setStorage("version", self.__version__) multiply, modulo = self.LAST_KNOWN_VALUES elif (swf_stamp + 3600000) < timestamp(): swfdump = self.get_swfdump_path() if swfdump: multiply, modulo = self.get_swf_values(self.file_info['HOST'] + swf_url, swfdump) else: self.logWarning("Swfdump not found. Install swftools to bypass captcha.") if multiply and modulo: self.logDebug("TIME = (%s * %s) %s" % (file_seed, multiply, modulo)) url = "/download?key=%s&time=%d" % (self.file_info['KEY'], (int(file_seed) * int(multiply)) % int(modulo)) return url return None
def handlePremium(self): postData = {'action': 'get_link', 'code': self.file_info['ID'], 'pass': '******'} self.html = self.load('http://uploading.com/files/get/?JsHttpRequest=%d-xml' % timestamp(), post=postData) url = re.search(r'"link"\s*:\s*"(.*?)"', self.html) if url: url = url.group(1).replace("\\/", "/") self.download(url) raise Exception("Plugin defect.")