diff options
| author | 2014-12-11 17:08:29 +0100 | |
|---|---|---|
| committer | 2014-12-11 17:08:29 +0100 | |
| commit | 1de45d9f4f2a39e205dd99e0dcf8b0c323537fea (patch) | |
| tree | b83d12fd13a27d798326d8a5e2fda136cab009e4 /pyload | |
| parent | Bucket and CookieJar from 0.5.0 (diff) | |
| download | pyload-1de45d9f4f2a39e205dd99e0dcf8b0c323537fea.tar.xz | |
Spare code cosmetics
Diffstat (limited to 'pyload')
| -rw-r--r-- | pyload/manager/thread/AddonThread.py | 5 | ||||
| -rw-r--r-- | pyload/manager/thread/DecrypterThread.py | 6 | ||||
| -rw-r--r-- | pyload/manager/thread/DownloadThread.py | 4 | ||||
| -rw-r--r-- | pyload/manager/thread/InfoThread.py | 3 | ||||
| -rw-r--r-- | pyload/network/XDCCRequest.py | 6 | ||||
| -rw-r--r-- | pyload/plugins/Account.py | 26 | ||||
| -rw-r--r-- | pyload/plugins/crypter/SafelinkingNet.py | 2 | ||||
| -rw-r--r-- | pyload/plugins/hoster/GigapetaCom.py | 13 | ||||
| -rw-r--r-- | pyload/plugins/hoster/QuickshareCz.py | 6 | ||||
| -rw-r--r-- | pyload/plugins/hoster/UnibytesCom.py | 6 | ||||
| -rw-r--r-- | pyload/plugins/internal/SimpleHoster.py | 7 | ||||
| -rw-r--r-- | pyload/plugins/internal/XFSHoster.py | 8 | ||||
| -rw-r--r-- | pyload/utils/packagetools.py | 2 | 
13 files changed, 30 insertions, 64 deletions
| diff --git a/pyload/manager/thread/AddonThread.py b/pyload/manager/thread/AddonThread.py index c699a93f9..a84856b0a 100644 --- a/pyload/manager/thread/AddonThread.py +++ b/pyload/manager/thread/AddonThread.py @@ -14,12 +14,7 @@ from types import MethodType  from pycurl import error -from pyload.datatype.PyFile import PyFile  from pyload.manager.thread.PluginThread import PluginThread -from pyload.plugins.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload -from pyload.utils.packagetools import parseNames -from pyload.utils import safe_join -from pyload.api import OnlineStatus  class AddonThread(PluginThread): diff --git a/pyload/manager/thread/DecrypterThread.py b/pyload/manager/thread/DecrypterThread.py index 1395fcd2f..003b5f082 100644 --- a/pyload/manager/thread/DecrypterThread.py +++ b/pyload/manager/thread/DecrypterThread.py @@ -14,12 +14,8 @@ from types import MethodType  from pycurl import error -from pyload.datatype.PyFile import PyFile  from pyload.manager.thread.PluginThread import PluginThread -from pyload.plugins.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload -from pyload.utils.packagetools import parseNames -from pyload.utils import safe_join -from pyload.api import OnlineStatus +from pyload.plugins.Plugin import Abort, Fail, Retry  class DecrypterThread(PluginThread): diff --git a/pyload/manager/thread/DownloadThread.py b/pyload/manager/thread/DownloadThread.py index 7b093f8f7..d876000da 100644 --- a/pyload/manager/thread/DownloadThread.py +++ b/pyload/manager/thread/DownloadThread.py @@ -14,12 +14,8 @@ from types import MethodType  from pycurl import error -from pyload.datatype.PyFile import PyFile  from pyload.manager.thread.PluginThread import PluginThread  from pyload.plugins.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload -from pyload.utils.packagetools import parseNames -from pyload.utils import safe_join -from pyload.api import OnlineStatus  class DownloadThread(PluginThread): diff --git a/pyload/manager/thread/InfoThread.py b/pyload/manager/thread/InfoThread.py index f8ff34f7b..99bf97fc8 100644 --- a/pyload/manager/thread/InfoThread.py +++ b/pyload/manager/thread/InfoThread.py @@ -16,9 +16,6 @@ from pycurl import error  from pyload.datatype.PyFile import PyFile  from pyload.manager.thread.PluginThread import PluginThread -from pyload.plugins.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload -from pyload.utils.packagetools import parseNames -from pyload.utils import safe_join  from pyload.api import OnlineStatus diff --git a/pyload/network/XDCCRequest.py b/pyload/network/XDCCRequest.py index 004f2d07f..7ac8165db 100644 --- a/pyload/network/XDCCRequest.py +++ b/pyload/network/XDCCRequest.py @@ -46,7 +46,7 @@ class XDCCRequest(object):          return socket.socket() -    def download(self, ip, port, filename, irc, progressNotify=None): +    def download(self, ip, port, filename, irc, progress=None):          ircbuffer = ""          lastUpdate = time() @@ -93,8 +93,8 @@ class XDCCRequest(object):                  cumRecvLen = 0                  lastUpdate = now -                if progressNotify: -                    progressNotify(self.percent) +                if progress: +                    progress(self.percent)              if not data:                  break diff --git a/pyload/plugins/Account.py b/pyload/plugins/Account.py index 79502df3a..1444a4300 100644 --- a/pyload/plugins/Account.py +++ b/pyload/plugins/Account.py @@ -188,16 +188,16 @@ class Account(Base):          :param req: `Request` instance          :return:          """ -        return {"validuntil": None,  #: -1 for unlimited -                "login": name, -                # "password": self.accounts[name]['password'],  #: commented due security reason -                "options": self.accounts[name]['options'], -                "valid": self.accounts[name]['valid'], -                "trafficleft": None,  #: in kb, -1 for unlimited -                "maxtraffic": None, -                "premium": None, -                "timestamp": 0,  #: time this info was retrieved -                "type": self.__name} +        return {"validuntil" : None,  #: -1 for unlimited +                "login"      : name, +                # "password"   : self.accounts[name]['password'],  #: commented due security reason +                "options"    : self.accounts[name]['options'], +                "valid"      : self.accounts[name]['valid'], +                "trafficleft": None,  #: in bytes, -1 for unlimited +                "maxtraffic" : None, +                "premium"    : None, +                "timestamp"  : 0,  #: time this info was retrieved +                "type"       : self.__name}      def getAllAccounts(self, force=False): @@ -262,8 +262,10 @@ class Account(Base):          return False if self.selectAccount() == (None, None) else True -    def parseTraffic(self, string): #returns kbyte -        return parseFileSize(string) +    def parseTraffic(self, value, unit=None):  #: return bytes +        if not unit and not isinstance(value, basestring): +            unit = "KB" +        return parseFileSize(value, unit)      def wrongPassword(self): diff --git a/pyload/plugins/crypter/SafelinkingNet.py b/pyload/plugins/crypter/SafelinkingNet.py index ef1110823..0ebe1a4a6 100644 --- a/pyload/plugins/crypter/SafelinkingNet.py +++ b/pyload/plugins/crypter/SafelinkingNet.py @@ -2,8 +2,6 @@  import re -from pycurl import FOLLOWLOCATION -  from BeautifulSoup import BeautifulSoup  from pyload.utils import json_loads diff --git a/pyload/plugins/hoster/GigapetaCom.py b/pyload/plugins/hoster/GigapetaCom.py index 9bcd54dbc..06d3cc6cf 100644 --- a/pyload/plugins/hoster/GigapetaCom.py +++ b/pyload/plugins/hoster/GigapetaCom.py @@ -2,7 +2,6 @@  import re -from pycurl import FOLLOWLOCATION  from random import randint  from pyload.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo @@ -31,16 +30,15 @@ class GigapetaCom(SimpleHoster):          captcha_key = str(randint(1, 100000000))          captcha_url = "http://gigapeta.com/img/captcha.gif?x=%s" % captcha_key -        self.req.http.c.setopt(FOLLOWLOCATION, 0) -          for _i in xrange(5):              self.checkErrors()              captcha = self.decryptCaptcha(captcha_url) -            self.html = self.load(self.pyfile.url, post={ -                "captcha_key": captcha_key, -                "captcha": captcha, -                "download": "Download"}) +            self.html = self.load(self.pyfile.url, +                                  post={'captcha_key': captcha_key, +                                        'captcha'    : captcha, +                                        'download'   : "Download"}, +                                  follow_location=False)              m = re.search(r'Location\s*:\s*(.+)', self.req.http.header, re.I)              if m: @@ -51,7 +49,6 @@ class GigapetaCom(SimpleHoster):          else:              self.fail(_("No valid captcha code entered")) -        self.req.http.c.setopt(FOLLOWLOCATION, 1)          self.download(download_url) diff --git a/pyload/plugins/hoster/QuickshareCz.py b/pyload/plugins/hoster/QuickshareCz.py index effbb24fb..ba0c30947 100644 --- a/pyload/plugins/hoster/QuickshareCz.py +++ b/pyload/plugins/hoster/QuickshareCz.py @@ -2,8 +2,6 @@  import re -from pycurl import FOLLOWLOCATION -  from pyload.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo @@ -60,10 +58,8 @@ class QuickshareCz(SimpleHoster):          data = dict((x, self.jsvars[x]) for x in self.jsvars if x in ("ID1", "ID2", "ID3", "ID4"))          self.logDebug("FREE URL1:" + download_url, data) -        self.req.http.c.setopt(FOLLOWLOCATION, 0) -        self.load(download_url, post=data) +        self.load(download_url, post=data, follow_location=False)          self.header = self.req.http.header -        self.req.http.c.setopt(FOLLOWLOCATION, 1)          m = re.search(r'Location\s*:\s*(.+)', self.header, re.I)          if m is None: diff --git a/pyload/plugins/hoster/UnibytesCom.py b/pyload/plugins/hoster/UnibytesCom.py index 1fcd1d89d..d0d65840d 100644 --- a/pyload/plugins/hoster/UnibytesCom.py +++ b/pyload/plugins/hoster/UnibytesCom.py @@ -4,8 +4,6 @@ import re  from urlparse import urljoin -from pycurl import FOLLOWLOCATION -  from pyload.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo @@ -32,11 +30,10 @@ class UnibytesCom(SimpleHoster):      def handleFree(self):          domain = "http://www.%s/" % self.HOSTER_DOMAIN          action, post_data = self.parseHtmlForm('id="startForm"') -        self.req.http.c.setopt(FOLLOWLOCATION, 0)          for _i in xrange(8):              self.logDebug(action, post_data) -            self.html = self.load(urljoin(domain, action), post=post_data) +            self.html = self.load(urljoin(domain, action), post=post_data, follow_location=False)              m = re.search(r'location:\s*(\S+)', self.req.http.header, re.I)              if m: @@ -67,7 +64,6 @@ class UnibytesCom(SimpleHoster):          else:              self.fail(_("No valid captcha code entered")) -        self.req.http.c.setopt(FOLLOWLOCATION, 1)          self.download(url) diff --git a/pyload/plugins/internal/SimpleHoster.py b/pyload/plugins/internal/SimpleHoster.py index af8a53534..d04044830 100644 --- a/pyload/plugins/internal/SimpleHoster.py +++ b/pyload/plugins/internal/SimpleHoster.py @@ -10,7 +10,7 @@ from pyload.datatype.PyFile import statusMap as _statusMap  from pyload.network.CookieJar import CookieJar  from pyload.network.RequestFactory import getURL  from pyload.plugins.Hoster import Hoster -from pyload.utils import fixup, parseFileSize +from pyload.utils import fixup, formatSize, parseFileSize  #@TODO: Adapt and move to PyFile in 0.4.10 @@ -523,9 +523,8 @@ class SimpleHoster(Hoster):          elif traffic == -1:              return True          else: -            size = self.pyfile.size / 1024 -            self.logInfo(_("Filesize: %i KiB, Traffic left for user %s: %i KiB") % (size, self.user, traffic)) -            return size <= traffic +            self.logInfo(_("Filesize: %s, Traffic left for user %s: %s") % (formatSize(size), self.user, formatSize(traffic))) +            return self.pyfile.size <= traffic      def error(self, reason="", type="parse"): diff --git a/pyload/plugins/internal/XFSHoster.py b/pyload/plugins/internal/XFSHoster.py index 1f9671402..8479be03f 100644 --- a/pyload/plugins/internal/XFSHoster.py +++ b/pyload/plugins/internal/XFSHoster.py @@ -5,8 +5,6 @@ import re  from random import random  from time import sleep -from pycurl import FOLLOWLOCATION, LOW_SPEED_TIME -  from pyload.plugins.hoster.UnrestrictLi import secondsToMidnight  from pyload.plugins.internal.captcha import ReCaptcha, SolveMedia  from pyload.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo @@ -119,11 +117,7 @@ class XFSHoster(SimpleHoster):              data = self.getPostParameters() -            self.req.http.c.setopt(FOLLOWLOCATION, 0) - -            self.html = self.load(self.pyfile.url, post=data, ref=True, decode=True) - -            self.req.http.c.setopt(FOLLOWLOCATION, 1) +            self.html = self.load(self.pyfile.url, post=data, ref=True, decode=True, follow_location=False)              m = re.search(r'Location\s*:\s*(.+)', self.req.http.header, re.I)              if m and not "op=" in m.group(1): diff --git a/pyload/utils/packagetools.py b/pyload/utils/packagetools.py index d930157e1..9dbde9b50 100644 --- a/pyload/utils/packagetools.py +++ b/pyload/utils/packagetools.py @@ -138,7 +138,7 @@ def parseNames(files):          # fallback: package by hoster          if not name: -            name = urlparse(file).hostname +            name = urlparse(file).netloc              if name:                  name = pat0.sub("", name) | 
