diff options
| -rw-r--r-- | module/plugins/Crypter.py | 2 | ||||
| -rw-r--r-- | module/plugins/Plugin.py | 33 | ||||
| -rw-r--r-- | module/plugins/container/RSDF.py | 2 | ||||
| -rw-r--r-- | module/plugins/internal/SimpleHoster.py | 2 | ||||
| -rw-r--r-- | module/plugins/internal/XFSPHoster.py | 5 | 
5 files changed, 27 insertions, 17 deletions
| diff --git a/module/plugins/Crypter.py b/module/plugins/Crypter.py index d2c6c624c..be6d9cbc3 100644 --- a/module/plugins/Crypter.py +++ b/module/plugins/Crypter.py @@ -42,7 +42,7 @@ class Crypter(Plugin):          """ create new packages from self.packages """          for pack in self.packages: -            self.log.debug("Parsed package %(name)s with %(len)d links" % { "name" : pack[0], "len" : len(pack[1]) } ) +            self.logDebug("Parsed package %(name)s with %(len)d links" % { "name" : pack[0], "len" : len(pack[1]) } )              links = [x.decode("utf-8") for x in pack[1]] diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index 8e66dff6c..efb20ad59 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -63,23 +63,23 @@ class Base(object):      #log functions      def logDebug(self, *args): -        self.log.debug("%s: %s" % (self.__name__, " | ".join([a if isinstance(a, basestring) else str(a) for a in args if a]))) +        self.log.debug("%s: %s" % (self.__name__, " | ".join([str(a).strip() for a in args if a])))      def logInfo(self, *args): -        self.log.info("%s: %s" % (self.__name__, " | ".join([a if isinstance(a, basestring) else str(a) for a in args if a]))) +        self.log.info("%s: %s" % (self.__name__, " | ".join([str(a).strip() for a in args if a])))      def logWarning(self, *args): -        self.log.warning("%s: %s" % (self.__name__, " | ".join([a if isinstance(a, basestring) else str(a) for a in args if a]))) +        self.log.warning("%s: %s" % (self.__name__, " | ".join([str(a).strip() for a in args if a])))      def logError(self, *args): -        self.log.error("%s: %s" % (self.__name__, " | ".join([a if isinstance(a, basestring) else str(a) for a in args if a]))) +        self.log.error("%s: %s" % (self.__name__, " | ".join([str(a).strip() for a in args if a])))      def logCritical(self, *args): -        self.log.critical("%s: %s" % (self.__name__, " | ".join([a if isinstance(a, basestring) else str(a) for a in args if a]))) +        self.log.critical("%s: %s" % (self.__name__, " | ".join([str(a).strip() for a in args if a])))      def setConf(self, option, value): @@ -351,11 +351,13 @@ class Plugin(Base):      def invalidCaptcha(self): +        self.logError("Invalid captcha")          if self.cTask:              self.cTask.invalid()      def correctCaptcha(self): +        self.logInfo("Correct captcha")          if self.cTask:              self.cTask.correct() @@ -393,7 +395,8 @@ class Plugin(Base):          if Ocr and not forceUser:              sleep(randint(3000, 5000) / 1000.0) -            if self.pyfile.abort: raise Abort +            if self.pyfile.abort: +                raise Abort              ocr = Ocr()              result = ocr.get_captcha(tmpCaptcha.name) @@ -419,7 +422,7 @@ class Plugin(Base):                  self.fail(_("No captcha result obtained in appropiate time by any of the plugins."))              result = task.result -            self.log.debug("Received captcha result: %s" % str(result)) +            self.logDebug("Received captcha result: %s" % str(result))          if not self.core.debug:              try: @@ -447,6 +450,8 @@ class Plugin(Base):          if type(url) == unicode:              url = str(url)  # encode('utf8') +        self.logDebug("Load url", *["%s: %s" % (key, val) for key, val in locals().items()]) +          res = self.req.load(url, get, post, ref, cookies, just_header, decode=decode)          if self.core.debug: @@ -505,6 +510,8 @@ class Plugin(Base):          :return: The location where the file was saved          """ +        self.logDebug("Download url", *["%s: %s" % (key, val) for key, val in locals().items()]) +          self.checkForSameFiles()          self.pyfile.setStatus("downloading") @@ -523,7 +530,7 @@ class Plugin(Base):                      chown(location, uid, gid)                  except Exception, e: -                    self.log.warning(_("Setting User and Group failed: %s") % str(e)) +                    self.logWarning(_("Setting User and Group failed: %s") % str(e))          # convert back to unicode          location = fs_decode(location) @@ -541,7 +548,7 @@ class Plugin(Base):              self.pyfile.size = self.req.size          if disposition and newname and newname != name: #triple check, just to be sure -            self.log.info("%(name)s saved as %(newname)s" % {"name": name, "newname": newname}) +            self.logInfo("%(name)s saved as %(newname)s" % {"name": name, "newname": newname})              self.pyfile.name = newname              filename = join(location, newname) @@ -557,7 +564,7 @@ class Plugin(Base):                  chown(fs_filename, uid, gid)              except Exception, e: -                self.log.warning(_("Setting User and Group failed: %s") % str(e)) +                self.logWarning(_("Setting User and Group failed: %s") % str(e))          self.lastDownload = filename          return self.lastDownload @@ -581,12 +588,12 @@ class Plugin(Base):          if api_size and api_size <= size: return None          elif size > max_size and not read_size: return None -        self.log.debug("Download Check triggered") +        self.logDebug("Download Check triggered")          f = open(lastDownload, "rb")          content = f.read(read_size if read_size else -1)          f.close()          #produces encoding errors, better log to other file in the future? -        #self.log.debug("Content: %s" % content) +        #self.logDebug("Content: %s" % content)          for name, rule in rules.iteritems():              if type(rule) in (str, unicode):                  if rule in content: @@ -639,7 +646,7 @@ class Plugin(Base):              if exists(location):                  raise SkipDownload(pyfile[0]) -            self.log.debug("File %s not skipped, because it does not exists." % self.pyfile.name) +            self.logDebug("File %s not skipped, because it does not exists." % self.pyfile.name)      def clean(self): diff --git a/module/plugins/container/RSDF.py b/module/plugins/container/RSDF.py index 4b9e3119a..60afb5600 100644 --- a/module/plugins/container/RSDF.py +++ b/module/plugins/container/RSDF.py @@ -49,4 +49,4 @@ class RSDF(Container):                  decryptedUrl = link.replace('CCF: ', '')                  self.urls.append(decryptedUrl) -            self.log.debug("%s: adding package %s with %d links" % (self.__name__,pyfile.package().name,len(links))) +            self.logDebug("%s: adding package %s with %d links" % (self.__name__,pyfile.package().name,len(links))) diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index be3e3c8fc..51010d569 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -221,10 +221,12 @@ class SimpleHoster(Hoster):              self.getFileInfo()          if self.premium and (not self.FORCE_CHECK_TRAFFIC or self.checkTrafficLeft()): +            self.logDebug("Handle as premium download")              self.handlePremium()          elif premium_only:              self.fail("This link require a premium account")          else: +            self.logDebug("Handle as free download")              self.handleFree() diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index 91a69116c..87a82beaf 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -102,8 +102,10 @@ class XFSPHoster(SimpleHoster):              if self.location:                  self.startDownload(self.location)              elif self.premium: +                self.logDebug("Handle as premium download")                  self.handlePremium()              else: +                self.logDebug("Handle as free download")                  self.handleFree() @@ -126,7 +128,6 @@ class XFSPHoster(SimpleHoster):      def handleFree(self):          url = self.getDownloadLink() -        self.logDebug("Download URL: %s" % url)          self.startDownload(url) @@ -312,7 +313,7 @@ class XFSPHoster(SimpleHoster):              inputs['code'] = self.decryptCaptcha(captcha_url)              return 1 -        m = re.search(self.CAPTCHA_DIV_PATTERN, self.html, re.DOTALL) +        m = re.search(self.CAPTCHA_DIV_PATTERN, self.html, re.S)          if m:              captcha_div = m.group(1)              self.logDebug(captcha_div) | 
