diff options
| author | 2011-06-05 16:24:21 +0200 | |
|---|---|---|
| committer | 2011-06-05 16:24:21 +0200 | |
| commit | 2c3b64a41b48f52cc721679cb108dd378cfbaf2b (patch) | |
| tree | 8b626eee93fa310dbccc1562225272eac476222e /module/plugins/hoster | |
| parent | closed #323 (diff) | |
| download | pyload-2c3b64a41b48f52cc721679cb108dd378cfbaf2b.tar.xz | |
Use new logging functions
Diffstat (limited to 'module/plugins/hoster')
| -rw-r--r-- | module/plugins/hoster/BitshareCom.py | 25 | ||||
| -rw-r--r-- | module/plugins/hoster/OneFichierCom.py | 13 | ||||
| -rw-r--r-- | module/plugins/hoster/UploadStationCom.py | 20 | 
3 files changed, 28 insertions, 30 deletions
diff --git a/module/plugins/hoster/BitshareCom.py b/module/plugins/hoster/BitshareCom.py index d5e59788a..dc9cc455c 100644 --- a/module/plugins/hoster/BitshareCom.py +++ b/module/plugins/hoster/BitshareCom.py @@ -67,7 +67,7 @@ class BitshareCom(Hoster):          # File id          m = re.match(self.__pattern__, self.pyfile.url)          self.file_id = max(m.group('id1'), m.group('id2'))  -        self.log.debug("%s: File id is [%s]" % (self.__name__, self.file_id)) +        self.logDebug("File id is [%s]" % self.file_id)          # Load main page          self.req.cj.setCookie(self.HOSTER_DOMAIN, "language_selection", "EN") @@ -84,7 +84,7 @@ class BitshareCom(Hoster):          # Ajax file id          self.ajaxid = re.search(BitshareCom.FILE_AJAXID_PATTERN, self.html).group(1) -        self.log.debug("%s: File ajax id is [%s]" % (self.__name__, self.ajaxid)) +        self.logDebug("File ajax id is [%s]" % self.ajaxid)          # Handle free downloading          self.handleFree() @@ -92,7 +92,7 @@ class BitshareCom(Hoster):      def handleFree(self):          # Get download info -        self.log.debug("%s: Getting download info" % self.__name__) +        self.logDebug("Getting download info")          response = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html",                              post={"request" : "generateID", "ajaxid" : self.ajaxid})          self.handleErrors(response, ':') @@ -100,22 +100,21 @@ class BitshareCom(Hoster):          filetype = parts[0]          wait = int(parts[1])          captcha = int(parts[2]) -        self.log.debug("%s: Download info [type: '%s', waiting: %d, captcha: %d]" %  -                       (self.__name__, filetype, wait, captcha)) +        self.logDebug("Download info [type: '%s', waiting: %d, captcha: %d]" % (filetype, wait, captcha))          # Waiting          if wait > 0: -            self.log.debug("%s: Waiting %d seconds." % (self.__name__, wait)) +            self.logDebug("Waiting %d seconds." % wait)              self.setWait(wait, True)              self.wait()          # Resolve captcha          if captcha == 1: -            self.log.debug("%s: File is captcha protected" % self.__name__) +            self.logDebug("File is captcha protected")              id = re.search(BitshareCom.CAPTCHA_KEY_PATTERN, self.html).group(1)              # Try up to 3 times              for i in range(3): -                self.log.debug("%s: Resolving ReCaptcha with key [%s], round %d" % (self.__name__, id, i+1)) +                self.logDebug("Resolving ReCaptcha with key [%s], round %d" % (id, i+1))                  recaptcha = ReCaptcha(self)                  challenge, code = recaptcha.challenge(id)                  response = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html", @@ -125,7 +124,7 @@ class BitshareCom(Hoster):          # Get download URL -        self.log.debug("%s: Getting download url" % self.__name__) +        self.logDebug("Getting download url")          response = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html",                      post={"request" : "getDownloadURL", "ajaxid" : self.ajaxid})          self.handleErrors(response, '#') @@ -133,19 +132,19 @@ class BitshareCom(Hoster):          # Request download URL          # This may either download our file or forward us to an error page -        self.log.debug("%s: Downloading file with url [%s]" % (self.__name__, url)) +        self.logDebug("Downloading file with url [%s]" % url)          self.download(url)      def handleErrors(self, response, separator): -        self.log.debug("%s: Checking response [%s]" % (self.__name__, response)) +        self.logDebug("Checking response [%s]" % response)          if "ERROR" in response:              msg = response.split(separator)[-1]              self.fail(msg)      def handleCaptchaErrors(self, response): -        self.log.debug("%s: Result of captcha resolving [%s]" % (self.__name__, response)) +        self.logDebug("Result of captcha resolving [%s]" % response)          if "SUCCESS" in response:              self.correctCaptcha()              return True -        self.log.debug("%s: Wrong captcha" % self.__name__) +        self.logDebug("Wrong captcha")          self.invalidCaptcha()
\ No newline at end of file diff --git a/module/plugins/hoster/OneFichierCom.py b/module/plugins/hoster/OneFichierCom.py index bc7a4542d..3343c7c8c 100644 --- a/module/plugins/hoster/OneFichierCom.py +++ b/module/plugins/hoster/OneFichierCom.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python  # -*- coding: utf-8 -*-  import re @@ -80,7 +79,7 @@ class OneFichierCom(Hoster):          # Check for protection           if self.isProtected():              password = self.getPassword() -            self.log.debug("%s: Submitting password [%s]" % (self.__name__, password)) +            self.logDebug("Submitting password [%s]" % password)              self.download(url, post={"password" : password})          else:              downloadLink = self.getDownloadLink() @@ -99,7 +98,7 @@ class OneFichierCom(Hoster):              m = re.search(pattern, self.html)              if m is not None:                  name = m.group('name').strip() -                self.log.debug("%s: Got file name [%s]" % (self.__name__, name)) +                self.logDebug("Got file name [%s]" % name)                  return name      def getFileSize(self): @@ -112,12 +111,12 @@ class OneFichierCom(Hoster):              except KeyError:                  multiplier = 1              bytes = int(size * multiplier) -            self.log.debug("%s: Got file size of [%s] bytes" % (self.__name__, bytes)) +            self.logDebug("Got file size of [%s] bytes" % bytes)              return bytes      def isProtected(self):          if self.PASSWORD_PROTECTED_TOKEN in self.html: -            self.log.debug("%s: Links are password protected" % self.__name__) +            self.logDebug("Links are password protected")              return True          return False @@ -125,12 +124,12 @@ class OneFichierCom(Hoster):          m = re.search(self.DOWNLOAD_LINK_PATTERN, self.html)          if m is not None:              url = m.group('url') -            self.log.debug("%s: Got file URL [%s]" % (self.__name__, url)) +            self.logDebug("Got file URL [%s]" % url)              return url      def handleErrors(self):          if re.search(self.FILE_OFFLINE_PATTERN, self.html) is not None: -            self.log.debug("%s: File not yet available." % self.__name__) +            self.logDebug("File not yet available.")              self.offline()      def handleDownloadedFile(self): diff --git a/module/plugins/hoster/UploadStationCom.py b/module/plugins/hoster/UploadStationCom.py index a4695e30a..22af20923 100644 --- a/module/plugins/hoster/UploadStationCom.py +++ b/module/plugins/hoster/UploadStationCom.py @@ -85,20 +85,20 @@ class UploadStationCom(Hoster):          # Check download
          response = self.load(self.pyfile.url, post={"checkDownload" : "check"}, utf8=True)
 -        self.log.debug("%s: Checking download, response [%s]" % (self.__name__, response.encode('ascii', 'ignore')))
 +        self.logDebug("Checking download, response [%s]" % response.encode('ascii', 'ignore'))
          self.handleErrors(response)
          # We got a captcha?
          if UploadStationCom.CAPTCHA_PRESENT_TOKEN in self.html:
              id = re.search(UploadStationCom.CAPTCHA_KEY_PATTERN, self.html).group(1)
 -            self.log.debug("%s: Resolving ReCaptcha with key [%s]" % (self.__name__, id))
 +            self.logDebug("Resolving ReCaptcha with key [%s]" % id)
              recaptcha = ReCaptcha(self)
              challenge, code = recaptcha.challenge(id)
              response = self.load('http://www.uploadstation.com/checkReCaptcha.php', 
                                    post={'recaptcha_challenge_field' : challenge,
                                          'recaptcha_response_field' : code, 
                                          'recaptcha_shortencode_field' : self.fileId})
 -            self.log.debug("%s: Result of captcha resolving [%s]" % (self.__name__, response.encode('ascii', 'ignore')))
 +            self.logDebug("Result of captcha resolving [%s]" % response.encode('ascii', 'ignore'))
              self.handleCaptchaErrors(response)
          # Process waiting
 @@ -107,10 +107,10 @@ class UploadStationCom(Hoster):          if m is not None:
              wait = int(m.group(1))
              if wait == 404:
 -                self.log.debug("No wait time returned")
 +                self.logDebug("No wait time returned")
                  self.fail("No wait time returned")
 -            self.log.debug("%s: Waiting %d seconds." % (self.__name__, wait))
 +            self.logDebug("Waiting %d seconds." % wait)
              self.setWait(wait + 3)
              self.wait()
 @@ -118,7 +118,7 @@ class UploadStationCom(Hoster):          self.load(self.pyfile.url, post={"downloadLink" : "show"})
          # This may either download our file or forward us to an error page
 -        self.log.debug("%s: Downloading file." % self.__name__)
 +        self.logDebug("Downloading file.")
          dl = self.download(self.pyfile.url, post={"download" : "normal"})
          self.handleDownloadedFile()
 @@ -131,21 +131,21 @@ class UploadStationCom(Hoster):              if m is not None:
                  wait = int(m.group(1))
 -            self.log.info("%s: Time limit reached, waiting %d seconds." % (self.__name__, wait))
 +            self.logInfo("Time limit reached, waiting %d seconds." % wait)
              self.setWait(wait, True)
              self.wait()
              self.retry()
          if UploadStationCom.DOWNLOAD_RESTRICTION_TOKEN in response:
              wait = 720
 -            self.log.info("%s: Free account time limit reached, waiting %d seconds." % (self.__name__, wait))
 +            self.logInfo("Free account time limit reached, waiting %d seconds." % wait)
              self.setWait(wait, True)
              self.wait()
              self.retry()
      def handleCaptchaErrors(self, response):
          if UploadStationCom.CAPTCHA_WRONG_TOKEN in response:
 -            self.log.info("%s: Invalid captcha response, retrying." % self.__name__)
 +            self.logInfo("Invalid captcha response, retrying.")
              self.invalidCaptcha()
              self.retry()
          else:
 @@ -157,7 +157,7 @@ class UploadStationCom(Hoster):              wait = 720
              if self.lastCheck is not None:
                  wait = int(self.lastCheck.group(1))
 -            self.log.debug("%s: Failed, you need to wait %d seconds for another download." % (self.__name__, wait))
 +            self.logDebug("Failed, you need to wait %d seconds for another download." % wait)
              self.setWait(wait + 3, True)
              self.wait()
              self.retry()
\ No newline at end of file  | 
