diff options
| author | 2010-08-02 10:48:07 +0200 | |
|---|---|---|
| committer | 2010-08-02 10:48:07 +0200 | |
| commit | 9444fa907cd128637b152db92154124cee7ec74c (patch) | |
| tree | 4c3b589731dbd9ba579402e6b321901e50204145 /module/plugins/hoster | |
| parent | wait fix (diff) | |
| download | pyload-9444fa907cd128637b152db92154124cee7ec74c.tar.xz | |
Rapidshare, Netload, Uploaded updated.
Diffstat (limited to 'module/plugins/hoster')
| -rw-r--r-- | module/plugins/hoster/NetloadIn.py | 43 | ||||
| -rw-r--r-- | module/plugins/hoster/RapidshareCom.py | 126 | ||||
| -rw-r--r-- | module/plugins/hoster/UploadedTo.py | 145 | 
3 files changed, 134 insertions, 180 deletions
diff --git a/module/plugins/hoster/NetloadIn.py b/module/plugins/hoster/NetloadIn.py index 219d69944..a374a0c4d 100644 --- a/module/plugins/hoster/NetloadIn.py +++ b/module/plugins/hoster/NetloadIn.py @@ -40,11 +40,9 @@ class NetloadIn(Hoster):              #    return True              self.download_html() -            self.setWait(self.get_wait_time()) -             -             -            self.log.debug("Netload: waiting %d seconds" % self.get_wait_time()) +            self.setWait(self.get_wait_time())             +            self.log.debug(_("Netload: waiting %d seconds" % self.get_wait_time()))              self.wait()              self.url = self.get_file_url() @@ -85,29 +83,30 @@ class NetloadIn(Hoster):          m = re.search(r"countdown\((\d+),'change\(\)'\);", url_captcha_html)          if m:              wait_time = int(m.group(1)) -            self.log.info("Netload: waiting %d seconds." % wait_time) -            sleep(wait_time) +            self.log.debug(_("Netload: waiting %d seconds." % wait_time)) +            self.setWait(wait_time) +            self.wait() -        #for i in range(6): -        self.html[1] = self.load(url_captcha_html, cookies=True) -        try: -            captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1) -        except: -            url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&.*&captcha=1)', self.html[1]).group(1).replace("amp;", "") +        for i in range(6):              self.html[1] = self.load(url_captcha_html, cookies=True) -            captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1) +            try: +                captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1) +            except: +                url_captcha_html = "http://netload.in/" + re.search('(index.php\?id=10&.*&captcha=1)', self.html[1]).group(1).replace("amp;", "") +                self.html[1] = self.load(url_captcha_html, cookies=True) +                captcha_url = "http://netload.in/" + re.search('(share/includes/captcha.php\?t=\d*)', self.html[1]).group(1) -        file_id = re.search('<input name="file_id" type="hidden" value="(.*)" />', self.html[1]).group(1) -         -        captcha = self.decryptCaptcha(captcha_url) -        sleep(5) -         -        self.html[2] = self.load("http://netload.in/index.php?id=10", post={"file_id": file_id, "captcha_check": captcha}, cookies=True) +            file_id = re.search('<input name="file_id" type="hidden" value="(.*)" />', self.html[1]).group(1) +             +            captcha = self.decryptCaptcha(captcha_url) +            sleep(5) +             +            self.html[2] = self.load("http://netload.in/index.php?id=10", post={"file_id": file_id, "captcha_check": captcha}, cookies=True) -        if re.search(r"(We will prepare your download..|We had a reqeust with the IP)", self.html[2]) != None: -            return True +            if re.search(r"(We will prepare your download..|We had a reqeust with the IP)", self.html[2]) != None: +                return True -        fail("Captcha not decrypted") +        self.fail("Captcha not decrypted")      def get_file_url(self):          try: diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index 062923ff6..2889955ce 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -12,71 +12,70 @@ class RapidshareCom(Hoster):      __name__ = "RapidshareCom"      __type__ = "hoster"      __pattern__ = r"http://[\w\.]*?rapidshare.com/files/(\d*?)/(.*)" -    __version__ = "1.0" +    __version__ = "1.1"      __description__ = """Rapidshare.com Download Hoster""" +    __config__ = [ ("server", "str", "Preferred Server", "None") ]       __author_name__ = ("spoob", "RaNaN", "mkaay")      __author_mail__ = ("spoob@pyload.org", "ranan@pyload.org", "mkaay@mkaay.de") -    def __init__(self, parent): -        Hoster.__init__(self, parent) -        self.parent = parent +    def setup(self):          self.html = [None, None] -        self.time_plus_wait = None   #time() + wait in seconds -        self.want_reconnect = False          self.no_slots = True          self.api_data = None -        self.url = self.parent.url -        self.read_config() -        self.account = None -        self.multi_dl = False -        self.usePremium = self.config['premium'] -        if self.usePremium: -            self.account = self.parent.core.pluginManager.getAccountPlugin(self.__name__) -            req = self.account.getAccountRequest(self) -            if req: -                self.req = req -                self.multi_dl = True -                self.req.canContinue = True -            else: -                self.usePremium = False +        self.multiDL = False -        self.start_dl = False - -    def prepare(self, thread): -        self.no_slots = True -        self.want_reconnect = False +        # self.usePremium = self.config['premium'] +        # if self.usePremium: +            # self.account = self.parent.core.pluginManager.getAccountPlugin(self.__name__) +            # req = self.account.getAccountRequest(self) +            # if req: +                # self.req = req +                # self.multi_dl = True +                # self.req.canContinue = True +            # else: +                # self.usePremium = False + +    def process(self, pyfile): +        self.url = self.pyfile.url         +        self.prepare() +        self.proceed(self.url) +                 +    def prepare(self): +        # self.no_slots = True +        # self.want_reconnect = False          self.download_api_data()          if self.api_data["status"] == "1": -            self.pyfile.status.filename = self.get_file_name() - -            if self.usePremium: -                info = self.account.getAccountInfo(self.account.getAccountData(self)[0]) -                self.logger.info(_("%s: Use Premium Account (%sGB left)") % (self.__name__, info["trafficleft"]/1000/1000)) -                if self.api_data["size"] / 1024 > info["trafficleft"]: -                    self.logger.info(_("%s: Not enough traffic left" % self.__name__)) -                    self.usePremium = False -                else: -                    self.pyfile.status.url = self.parent.url -                    return True +            self.pyfile.name = self.get_file_name() + +            # if self.usePremium: +                # info = self.account.getAccountInfo(self.account.getAccountData(self)[0]) +                # self.logger.info(_("%s: Use Premium Account (%sGB left)") % (self.__name__, info["trafficleft"]/1000/1000)) +                # if self.api_data["size"] / 1024 > info["trafficleft"]: +                    # self.logger.info(_("%s: Not enough traffic left" % self.__name__)) +                    # self.usePremium = False +                # else: +                    # self.pyfile.status.url = self.parent.url +                    # return True              self.download_html()              while self.no_slots: -                self.get_wait_time() -                self.pyfile.status.waituntil = self.time_plus_wait -                self.pyfile.status.want_reconnect = self.want_reconnect -                thread.wait(self.pyfile) +                self.setWait(self.get_wait_time()) +                self.wait() +                # self.pyfile.status.waituntil = self.time_plus_wait +                # self.pyfile.status.want_reconnect = self.want_reconnect +                # thread.wait(self.pyfile) -            self.pyfile.status.url = self.get_file_url() +            self.url = self.get_file_url()              return True          elif self.api_data["status"] == "2":              self.logger.info(_("Rapidshare: Traffic Share (direct download)")) -            self.pyfile.status.filename = self.get_file_name() -            self.pyfile.status.url = self.parent.url +            self.pyfile.name = self.get_file_name() +            # self.pyfile.status.url = self.parent.url              return True          else: -            return False +            self.fail("Unknown response code.")      def download_api_data(self):          """ @@ -126,31 +125,29 @@ class RapidshareCom(Hoster):          if re.search(r"is already downloading", self.html[1]):              self.logger.info(_("Rapidshare: Already downloading, wait 30 minutes")) -            self.time_plus_wait = time() + 10 * 30 -            return +            return 30 * 60          self.no_slots = False          try:              wait_minutes = re.search(r"Or try again in about (\d+) minute", self.html[1]).group(1) -            self.time_plus_wait = time() + 60 * int(wait_minutes) + 60 +            return 60 * int(wait_minutes) + 60              self.no_slots = True -            self.want_reconnect = True +            self.wantReconnect = True          except:              if re.search(r"(Currently a lot of users|no more download slots|servers are overloaded)", self.html[1], re.I) != None: -                self.time_plus_wait = time() + 130                  self.logger.info(_("Rapidshare: No free slots!"))                  self.no_slots = True -                return True +                return time() + 130              self.no_slots = False              wait_seconds = re.search(r"var c=(.*);.*", self.html[1]).group(1) -            self.time_plus_wait = time() + int(wait_seconds) + 5 +            return int(wait_seconds) + 5      def get_file_url(self):          """ returns the absolute downloadable filepath          """ -        if self.config['server'] == "": +        if self.getConf('server') == "None":              file_url_pattern = r".*name=\"dlf\" action=\"(.*)\" method=.*"          else: -            file_url_pattern = '(http://rs.*)\';" /> %s<br />' % self.config['server'] +            file_url_pattern = '(http://rs.*)\';" /> %s<br />' % getConf('server')          return re.search(file_url_pattern, self.html[1]).group(1) @@ -164,23 +161,6 @@ class RapidshareCom(Hoster):                  return file_name_search.group(1)          return self.url.split("/")[-1] -    def proceed(self, url, location): -        self.download(url, location, get={"directstart":1}, cookies=True) - -    def check_file(self, local_file): -        if self.api_data and self.api_data["checksum"]: -            h = hashlib.md5() -            f = open(local_file, "rb") -            while True: -                data = f.read(128) -                if not data: -                    break -                h.update(data) -            f.close() -            hexd = h.hexdigest() -            if hexd == self.api_data["checksum"]: -                return (True, 0) -            else: -                return (False, 1) -        else: -            return (True, 5) +    def proceed(self, url): +        self.download(url, get={"directstart":1}, cookies=True) + diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index 5a41e590c..2fefe5bcf 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -9,78 +9,72 @@ class UploadedTo(Hoster):      __name__ = "UploadedTo"      __type__ = "hoster"      __pattern__ = r"http://(?:www\.)?u(?:p)?l(?:oaded)?\.to/(?:file/|\?id=)?(.+)" -    __version__ = "0.3" +    __version__ = "0.4"      __description__ = """Uploaded.to Download Hoster"""      __author_name__ = ("spoob", "mkaay")      __author_mail__ = ("spoob@pyload.org", "mkaay@mkaay.de") -    def __init__(self, parent): -        Hoster.__init__(self, parent) -        self.parent = parent +     +    def setup(self):          self.html = None -        self.time_plus_wait = None	#time() + wait in seconds          self.api_data = None -        self.want_reconnect = False -        self.read_config() -        self.account = None -        self.multi_dl = False -        self.usePremium = self.config['premium'] -        if self.usePremium: -            self.account = self.parent.core.pluginManager.getAccountPlugin(self.__name__) -            req = self.account.getAccountRequest(self) -            if req: -                self.req = req -                self.multi_dl = True -                self.req.canContinue = True -            else: -                self.usePremium = False +        self.multiDL = False +        # self.usePremium = self.config['premium'] +        # if self.usePremium: +            # self.account = self.parent.core.pluginManager.getAccountPlugin(self.__name__) +            # req = self.account.getAccountRequest(self) +            # if req: +                # self.req = req +                # self.multi_dl = True +                # self.req.canContinue = True +            # else: +                # self.usePremium = False -        self.start_dl = False +         +    def process(self, pyfile): +        self.url = False +        self.pyfile = pyfile +        self.prepare() +        self.proceed() +                 -    def prepare(self, thread):         -        self.want_reconnect = False +    def prepare(self):                  tries = 0 -        while not self.pyfile.status.url: +        while not self.url:              self.download_html() -            self.pyfile.status.exists = self.file_exists() - -            if not self.pyfile.status.exists: -                return False +            if not self.file_exists(): +                self.offline()              self.download_api_data() -            self.pyfile.status.filename = self.get_file_name() +            # self.pyfile.name = self.get_file_name() -            if self.usePremium: -                info = self.account.getAccountInfo(self.account.getAccountData(self)[0]) -                self.logger.info(_("%s: Use Premium Account (%sGB left)") % (self.__name__, info["trafficleft"]/1024/1024)) -                if self.api_data["size"]/1024 > info["trafficleft"]: -                    self.logger.info(_("%s: Not enough traffic left" % self.__name__)) -                    self.usePremium = False -                else: -                    self.pyfile.status.url = self.parent.url -                    return True +            # if self.usePremium: +                # info = self.account.getAccountInfo(self.account.getAccountData(self)[0]) +                # self.logger.info(_("%s: Use Premium Account (%sGB left)") % (self.__name__, info["trafficleft"]/1024/1024)) +                # if self.api_data["size"]/1024 > info["trafficleft"]: +                    # self.logger.info(_("%s: Not enough traffic left" % self.__name__)) +                    # self.usePremium = False +                # else: +                    # self.pyfile.status.url = self.parent.url +                    # return True -            self.get_waiting_time() - -            self.pyfile.status.waituntil = self.time_plus_wait -            self.pyfile.status.url = self.get_file_url() -            self.pyfile.status.want_reconnect = self.want_reconnect - -            thread.wait(self.parent) +            self.url = self.get_file_url() +             +            self.setWait(self.get_waiting_time()) +            self.wait() -            self.pyfile.status.filename = self.get_file_name() +            self.pyfile.name = self.get_file_name()              tries += 1              if tries > 5: -                raise Exception, "Error while preparing DL" +                self.fail("Error while preparing DL")          return True      def download_api_data(self): -        url = self.parent.url -        match = re.compile(self.__pattern__).search(url) +        match = re.compile(self.__pattern__).search(self.pyfile.url)          if match:              src = self.load("http://uploaded.to/api/file", cookies=False, get={"id": match.group(1).split("/")[0]})              if not src.find("404 Not Found"): @@ -92,22 +86,21 @@ class UploadedTo(Hoster):              self.api_data["checksum"] = lines[2] #sha1      def download_html(self): -        url = self.parent.url -        self.html = self.load(url, cookies=False) +        self.html = self.load(self.pyfile.url, cookies=False)      def get_waiting_time(self):          try:              wait_minutes = re.search(r"Or wait ([\d\-]+) minutes", self.html).group(1) -            if int(wait_minutes) < 0: wait_minutes = 1 -            self.time_plus_wait = time() + 60 * int(wait_minutes) -            self.want_reconnect = True +            if int(wait_minutes) < 0: wait_minutes = 1             +            self.wantReconnect = True +            return 60 * int(wait_minutes)          except: -            self.time_plus_wait = 0 +            return 0      def get_file_url(self): -        if self.usePremium: -            self.start_dl = True -            return self.parent.url +        # if self.usePremium: +            # self.start_dl = True +            # return self.url          try:              file_url_pattern = r".*<form name=\"download_form\" method=\"post\" action=\"(.*)\">"              return re.search(file_url_pattern, self.html).group(1) @@ -124,7 +117,7 @@ class UploadedTo(Hoster):                  return file_name              return file_name + file_suffix.group(1)          except: -            return self.parent.url +            return self.pyfile.url.split('/')[-1]      def file_exists(self):          if re.search(r"(File doesn't exist)", self.html) != None: @@ -139,30 +132,12 @@ class UploadedTo(Hoster):          url = re.sub("/\?(.*?)&id=", "/file/", url, 1)          return url -    def proceed(self, url, location): -        if self.usePremium: -            self.load(url, cookies=True, just_header=True) -            if self.cleanUrl(self.req.lastEffectiveURL) == self.cleanUrl(url): -                self.logger.info(_("UploadedTo indirect download")) -                url = self.cleanUrl(url)+"?redirect" -            self.download(url, location, cookies=True) -        else: -            self.download(url, location, cookies=False, post={"download_submit": "Free Download"}) - -    def check_file(self, local_file): -        if self.api_data and self.api_data["checksum"]: -            h = hashlib.sha1() -            f = open(local_file, "rb") -            while True: -                data = f.read(128) -                if not data: -                    break -                h.update(data) -            f.close() -            hexd = h.hexdigest() -            if hexd == self.api_data["checksum"]: -                return (True, 0) -            else: -                return (False, 1) -        else: -            return (True, 5) +    def proceed(self): +        # if self.usePremium: +            # self.load(url, cookies=True, just_header=True) +            # if self.cleanUrl(self.req.lastEffectiveURL) == self.cleanUrl(url): +                # self.logger.info(_("UploadedTo indirect download")) +                # url = self.cleanUrl(url)+"?redirect" +            # self.download(url, location, cookies=True) +        # else: +        self.download(self.url, cookies=False, post={"download_submit": "Free Download"})  | 
