def start_regular(self): page_data = self.MAIN_URL_OPEN(self.url) try: self.regular_url = REGULAR_URL_RE.search(page_data).group(1) self.regular_url = "http://www.wupload.com/file/" + self.regular_url except Exception, e: msg = "Regular link not found" log.error(msg) log.error(e.message) tmp_dump(page_data, link) raise DownloadError(msg)
def start_regular(self): if self.user and self.password and ACCOUNT.account_type == "Premium": console("trying with cool API") id_ = URL_ID_RE.search(self.url).group(1) self.file_url = API_DOWNLOAD % (self.user, self.password, id_) console(self.file_url) return False page_data = self.MAIN_URL_OPEN(self.url) try: self.regular_url = REGULAR_URL_RE.search(page_data).group(1) self.regular_url = "http://www.wupload.com/file/" + self.regular_url except Exception, e: msg = "Regular link not found" log.error(msg) log.error(e.message) tmp_dump(page_data, link) raise DownloadError(msg)
log.debug("Megaupload link: %s" % self.url) try: page_data = URL_OPEN(self.url) except Exception, error: raise DownloadError(error) try: link = MEGALINK_RE.search(page_data).group(1) except: raise Exception("File was removed.\n\nVisit: %s to " \ "make sure." % self.url) if not link: tmp_dump(page_data, link) raise Exception("No real file found") log.debug("Link obtained: %s" % link) return link def _on_megalink_finish(self, (is_error, result)): """ Called on finish finding the real link. """ if is_error: message = gettext("Error obtaining megaupload's link: %s") % result self.gui_manager.report_error(message) return self.megalink = result
class Wupload(BaseDownloader): """ Wupload's Downloader. """ name = "Wupload" icon_path = HOSTS_IMAGES_DIR + SEP + "wupload.png" accept_ranges = True def __init__(self, gui_manager, url): self.MAIN_URL_OPEN = UrlOpen(use_cache=False) BaseDownloader.__init__(self, self.MAIN_URL_OPEN, gui_manager, url) self.url = url self.gui_manager = gui_manager self.config = Config.get() self.user = None self.password = None accounts = self.config.get_key("accounts") for host, data in accounts: if host == "wupload": self.user = data["username"] self.password = base64.b64decode(data["password"]) self.captcha_window = CaptchaWindow(gui_manager, self._on_captcha_ok) self.MAIN_URL_OPEN.add_headers({ "Referer": url, "Origin": "http://www.wupload.com", "Host": "www.wupload.com", }) CAPTCHA_URL_OPEN.add_headers({"referer": url}) def process_url(self, play_callback, file_path): self.play_callback = play_callback self.file_path = file_path self.gui_manager.background_task(self.start_regular, self.on_waiting_finish, unfreeze=False) def start_regular(self): if self.user and self.password and ACCOUNT.account_type == "Premium": console("trying with cool API") id_ = URL_ID_RE.search(self.url).group(1) self.file_url = API_DOWNLOAD % (self.user, self.password, id_) console(self.file_url) return False page_data = self.MAIN_URL_OPEN(self.url) if "this file has been removed" in page_data: raise Exception(gettext("File removed")) try: self.regular_url = REGULAR_URL_RE.search(page_data).group(1) self.regular_url = "http://www.wupload.com/file/" + self.regular_url + "/" + self.regular_url + "?start=1" except Exception, e: msg = "Regular link not found" log.error(msg) log.error(e.message) tmp_dump(page_data, link) raise DownloadError(msg) self.MAIN_URL_OPEN.add_headers({"X-Requested-With": "XMLHttpRequest"}) print "REGULAR URL", self.regular_url regular_data = self.MAIN_URL_OPEN(self.regular_url) if "countDownDelay" in regular_data: waiting_time = int(WAITING_TIME_RE.search(regular_data).group(1)) try: tm = int(TM_RE.search(regular_data).group(1)) tm_hash = TM_HASH_RE.search(regular_data).group("value") tm_data = {"tm": tm, "tm_hash": tm_hash} except: tm_data = None for i in range(waiting_time, 0, -1): gobject.idle_add( self.gui_manager.set_status_message, gettext("Please wait %d second%s...") % (i, "s" * (i > 1))) time.sleep(1) log.info("Trying to get captcha..") log.info(tm_data) regular_data = self.MAIN_URL_OPEN(self.regular_url, data=tm_data) if "Download Ready" in regular_data: has_captcha = False self.file_url = FILE_URL_RE.search(regular_data).group(1) else: has_captcha = True try: self.recaptcha_challenge_id = RECAPTCHA_CHALLENGE_ID_RE.search( regular_data).group(1) except Exception, e: msg = "Captcha challenge not found!" log.error(msg) log.error(e.message) tmp_dump(page_data, self.url) raise DownloadError(msg)