diff options
| author | 2014-07-15 16:25:41 +0200 | |
|---|---|---|
| committer | 2014-07-15 16:25:41 +0200 | |
| commit | 5060e4c6374a5116d0d8b02528f910f8c5f8bcf9 (patch) | |
| tree | b3f80dbd9e759747f9c2acb60f614c5daa7af69e /module | |
| parent | Fix class definition (diff) | |
| download | pyload-5060e4c6374a5116d0d8b02528f910f8c5f8bcf9.tar.xz | |
Fix code indentation, some bad whitespaces and missing authors + use 'not' instead 'is None' + replace __pattern__'s r" with r' + other minor cosmetics
Diffstat (limited to 'module')
86 files changed, 207 insertions, 167 deletions
| diff --git a/module/plugins/Account.py b/module/plugins/Account.py index abeafad3a..21f65816a 100644 --- a/module/plugins/Account.py +++ b/module/plugins/Account.py @@ -25,6 +25,7 @@ from threading import RLock  from Plugin import Base  from module.utils import compare_time, parseFileSize, lock +  class WrongPassword(Exception):      pass diff --git a/module/plugins/AccountManager.py b/module/plugins/AccountManager.py index 1de55effc..80441066f 100644 --- a/module/plugins/AccountManager.py +++ b/module/plugins/AccountManager.py @@ -27,6 +27,7 @@ from module.utils import chmod, lock  ACC_VERSION = 1 +  class AccountManager():      """manages all accounts""" @@ -47,7 +48,6 @@ class AccountManager():          self.initAccountPlugins()          self.loadAccounts() -      def getAccountPlugin(self, plugin):          """get account instance for plugin or None if anonymous"""          if plugin in self.accounts: @@ -66,6 +66,7 @@ class AccountManager():              plugins.append(self.getAccountPlugin(plugin))          return plugins +      #----------------------------------------------------------------------      def loadAccounts(self):          """loads all accounts available""" @@ -112,6 +113,7 @@ class AccountManager():              elif ":" in line:                  name, sep, pw = line.partition(":")                  self.accounts[plugin][name] = {"password": pw, "options": {}, "valid": True} +      #----------------------------------------------------------------------      def saveAccounts(self):          """save all account information""" diff --git a/module/plugins/Container.py b/module/plugins/Container.py index 685ceac20..8dc0581af 100644 --- a/module/plugins/Container.py +++ b/module/plugins/Container.py @@ -23,6 +23,7 @@ from os.path import join, exists, basename  from os import remove  import re +  class Container(Crypter):      __name__ = "Container"      __version__ = "0.1" diff --git a/module/plugins/Crypter.py b/module/plugins/Crypter.py index b2e6528e9..b613ff023 100644 --- a/module/plugins/Crypter.py +++ b/module/plugins/Crypter.py @@ -19,6 +19,7 @@  from module.plugins.Plugin import Plugin +  class Crypter(Plugin):      __name__ = "Crypter"      __version__ = "0.1" diff --git a/module/plugins/Hook.py b/module/plugins/Hook.py index 6f5abffed..b9c7b832f 100644 --- a/module/plugins/Hook.py +++ b/module/plugins/Hook.py @@ -22,6 +22,7 @@ from traceback import print_exc  from Plugin import Base +  class Expose(object):      """ used for decoration to declare rpc services """ @@ -29,11 +30,14 @@ class Expose(object):          hookManager.addRPC(f.__module__, f.func_name, f.func_doc)          return f +  def threaded(f): +      def run(*args,**kwargs):          hookManager.startThread(f, *args, **kwargs)      return run +  class Hook(Base):      """      Base class for hook plugins. diff --git a/module/plugins/Hoster.py b/module/plugins/Hoster.py index 4979d383b..67692a94f 100644 --- a/module/plugins/Hoster.py +++ b/module/plugins/Hoster.py @@ -23,6 +23,7 @@ def getInfo(self):          #result = [ .. (name, size, status, url) .. ]          return +  class Hoster(Plugin):      __name__ = "Hoster"      __version__ = "0.1" diff --git a/module/plugins/PluginManager.py b/module/plugins/PluginManager.py index e976b2c4a..b290c2746 100644 --- a/module/plugins/PluginManager.py +++ b/module/plugins/PluginManager.py @@ -29,6 +29,7 @@ from traceback import print_exc  from module.lib.SafeEval import const_eval as literal_eval  from module.ConfigParser import IGNORE +  class PluginManager:      ROOT = "module.plugins."      USERROOT = "userplugins." diff --git a/module/plugins/ReCaptcha.py b/module/plugins/ReCaptcha.py index 3e8b33fbd..143ecfb83 100644 --- a/module/plugins/ReCaptcha.py +++ b/module/plugins/ReCaptcha.py @@ -2,7 +2,9 @@  import re +  class ReCaptcha(): +      def __init__(self, plugin):          self.plugin = plugin diff --git a/module/plugins/accounts/EuroshareEu.py b/module/plugins/accounts/EuroshareEu.py index cb03749b7..93c193625 100644 --- a/module/plugins/accounts/EuroshareEu.py +++ b/module/plugins/accounts/EuroshareEu.py @@ -34,7 +34,7 @@ class EuroshareEu(Account):          html = req.load("http://euroshare.eu/customer-zone/settings/")          found = re.search('id="input_expire_date" value="(\d+\.\d+\.\d+ \d+:\d+)"', html) -        if found is None: +        if not found:              premium, validuntil = False, -1          else:              premium = True diff --git a/module/plugins/accounts/HellshareCz.py b/module/plugins/accounts/HellshareCz.py index 824adbd1e..9b16741fc 100644 --- a/module/plugins/accounts/HellshareCz.py +++ b/module/plugins/accounts/HellshareCz.py @@ -36,7 +36,7 @@ class HellshareCz(Account):          html = req.load("http://www.hellshare.com/")          found = re.search(self.CREDIT_LEFT_PATTERN, html) -        if found is None: +        if not found:              trafficleft = None              validuntil = None              premium = False diff --git a/module/plugins/accounts/OneFichierCom.py b/module/plugins/accounts/OneFichierCom.py index b10e34314..7c14f8191 100644 --- a/module/plugins/accounts/OneFichierCom.py +++ b/module/plugins/accounts/OneFichierCom.py @@ -12,11 +12,12 @@ class OneFichierCom(Account):      __version__ = "0.1"      __type__ = "account"      __description__ = """1fichier.com account plugin""" -    __author_name__ = ("Elrick69") -    __author_mail__ = ("elrick69[AT]rocketmail[DOT]com") +    __author_name__ = "Elrick69" +    __author_mail__ = "elrick69[AT]rocketmail[DOT]com"      VALID_UNTIL_PATTERN = r'You are a premium user until (?P<d>\d{2})/(?P<m>\d{2})/(?P<y>\d{4})' +      def loadAccountInfo(self, user, req):          html = req.load("http://1fichier.com/console/abo.pl") diff --git a/module/plugins/accounts/SimplyPremiumCom.py b/module/plugins/accounts/SimplyPremiumCom.py index 1e6d66806..6ae8396db 100644 --- a/module/plugins/accounts/SimplyPremiumCom.py +++ b/module/plugins/accounts/SimplyPremiumCom.py @@ -1,5 +1,4 @@  # -*- coding: utf-8 -*- -  ############################################################################  # This program is free software: you can redistribute it and/or modify     #  # it under the terms of the GNU Affero General Public License as           # @@ -15,17 +14,17 @@  # along with this program.  If not, see <http://www.gnu.org/licenses/>.    #  ############################################################################ -from module.plugins.Account import Account  from module.common.json_layer import json_loads +from module.plugins.Account import Account  class SimplyPremiumCom(Account):      __name__ = "SimplyPremiumCom"      __version__ = "0.01"      __type__ = "account" -    __description__ = """Simply-Premium.Com account plugin""" -    __author_name__ = ("EvolutionClip") -    __author_mail__ = ("evolutionclip@live.de") +    __description__ = """Simply-Premium.com account plugin""" +    __author_name__ = "EvolutionClip" +    __author_mail__ = "evolutionclip@live.de"      def loadAccountInfo(self, user, req):          json_data = req.load('http://www.simply-premium.com/api/user.php?format=json') diff --git a/module/plugins/captcha/ShareonlineBiz.py b/module/plugins/captcha/ShareonlineBiz.py index 7b739c295..a3fbbed7c 100644 --- a/module/plugins/captcha/ShareonlineBiz.py +++ b/module/plugins/captcha/ShareonlineBiz.py @@ -20,6 +20,7 @@  from module.plugins.OCR import OCR +  class ShareonlineBiz(OCR):      __name__ = "ShareonlineBiz"      __version__ = "0.1" @@ -33,7 +34,7 @@ class ShareonlineBiz(OCR):      def __init__(self):          OCR.__init__(self) -    def get_captcha(self, image):  +    def get_captcha(self, image):          self.load_image(image)          self.to_greyscale()          self.image = self.image.resize((160, 50)) diff --git a/module/plugins/captcha/captcha.py b/module/plugins/captcha/captcha.py index aa84a1a75..48f4a4217 100644 --- a/module/plugins/captcha/captcha.py +++ b/module/plugins/captcha/captcha.py @@ -149,19 +149,28 @@ class OCR(object):          for x in xrange(w):              for y in xrange(h): -                if pixels[x, y] == 255: continue -                # no point in processing white pixels since we only want to remove black pixel +                if pixels[x, y] == 255: +                    continue +                # No point in processing white pixels since we only want to remove black pixel                  count = 0                  try: -                    if pixels[x-1, y-1] != 255: count += 1 -                    if pixels[x-1, y] != 255: count += 1 -                    if pixels[x-1, y + 1] != 255: count += 1 -                    if pixels[x, y + 1] != 255: count += 1 -                    if pixels[x + 1, y + 1] != 255: count += 1 -                    if pixels[x + 1, y] != 255: count += 1 -                    if pixels[x + 1, y-1] != 255: count += 1 -                    if pixels[x, y-1] != 255: count += 1 +                    if pixels[x-1, y-1] != 255: +                        count += 1 +                    if pixels[x-1, y] != 255: +                        count += 1 +                    if pixels[x-1, y + 1] != 255: +                        count += 1 +                    if pixels[x, y + 1] != 255: +                        count += 1 +                    if pixels[x + 1, y + 1] != 255: +                        count += 1 +                    if pixels[x + 1, y] != 255: +                        count += 1 +                    if pixels[x + 1, y-1] != 255: +                        count += 1 +                    if pixels[x, y-1] != 255: +                        count += 1                  except:                      pass @@ -173,7 +182,8 @@ class OCR(object):              # second pass: this time set all 1's to 255 (white)          for x in xrange(w):              for y in xrange(h): -                if pixels[x, y] == 1: pixels[x, y] = 255 +                if pixels[x, y] == 1: +                    pixels[x, y] = 255          self.pixels = pixels @@ -268,9 +278,12 @@ class OCR(object):                          firstX = x                          lastX = x -                    if y > bottomY: bottomY = y -                    if y < topY: topY = y -                    if x > lastX: lastX = x +                    if y > bottomY: +                        bottomY = y +                    if y < topY: +                        topY = y +                    if x > lastX: +                        lastX = x                      black_pixel_in_col = True diff --git a/module/plugins/container/CCF.py b/module/plugins/container/CCF.py index 8aec97f6a..eb27aaae3 100644 --- a/module/plugins/container/CCF.py +++ b/module/plugins/container/CCF.py @@ -9,6 +9,7 @@ from module.lib.MultipartPostHandler import MultipartPostHandler  from os import makedirs  from os.path import exists, join +  class CCF(Container):      __name__ = "CCF"      __version__ = "0.2" diff --git a/module/plugins/container/LinkList.py b/module/plugins/container/LinkList.py index ab7700181..b8f1b9de5 100644 --- a/module/plugins/container/LinkList.py +++ b/module/plugins/container/LinkList.py @@ -4,6 +4,7 @@ import codecs  from module.utils import fs_encode  from module.plugins.Container import Container +  class LinkList(Container):      __name__ = "LinkList"      __version__ = "0.12" @@ -33,7 +34,8 @@ class LinkList(Container):          for link in links:              link = link.strip() -            if not link: continue +            if not link: +                continue              if link.startswith(";"):                  continue diff --git a/module/plugins/crypter/CzshareComFolder.py b/module/plugins/crypter/CzshareComFolder.py index d1ba8335c..c3606fdab 100644 --- a/module/plugins/crypter/CzshareComFolder.py +++ b/module/plugins/crypter/CzshareComFolder.py @@ -22,7 +22,8 @@ class CzshareComFolder(Crypter):          new_links = []          found = re.search(self.FOLDER_PATTERN, html, re.DOTALL) -        if found is None: self.fail("Parse error (FOLDER)") +        if not found: +            self.fail("Parse error (FOLDER)")          new_links.extend(re.findall(self.LINK_PATTERN, found.group(1)))          if new_links: diff --git a/module/plugins/crypter/DuckCryptInfo.py b/module/plugins/crypter/DuckCryptInfo.py index f44bac2e9..4cd3ec197 100644 --- a/module/plugins/crypter/DuckCryptInfo.py +++ b/module/plugins/crypter/DuckCryptInfo.py @@ -32,7 +32,6 @@ class DuckCryptInfo(Crypter):          else:              self.handleFolder(found) -      def handleFolder(self, found):          src = self.load("http://duckcrypt.info/ajax/auth.php?hash=" + str(found.group(2)))          found = re.match(self.__pattern__, src) diff --git a/module/plugins/crypter/FilerNetFolder.py b/module/plugins/crypter/FilerNetFolder.py index 70c932d00..c4cf658bd 100644 --- a/module/plugins/crypter/FilerNetFolder.py +++ b/module/plugins/crypter/FilerNetFolder.py @@ -8,7 +8,7 @@ class FilerNetFolder(SimpleCrypter):      __type__ = "crypter"      __version__ = "0.3"      __description__ = """Filer.net decrypter plugin""" -    __pattern__ = r"https?://filer\.net/folder/\w{16}" +    __pattern__ = r'https?://filer\.net/folder/\w{16}'      __author_name_ = ("nath_schwarz", "stickell")      __author_mail_ = ("nathan.notwhite@gmail.com", "l.stickell@yahoo.it") diff --git a/module/plugins/crypter/FileserveComFolder.py b/module/plugins/crypter/FileserveComFolder.py index c3c8b58fe..74d7806e6 100644 --- a/module/plugins/crypter/FileserveComFolder.py +++ b/module/plugins/crypter/FileserveComFolder.py @@ -23,7 +23,8 @@ class FileserveComFolder(Crypter):          new_links = []          folder = re.search(self.FOLDER_PATTERN, html, re.DOTALL) -        if folder is None: self.fail("Parse error (FOLDER)") +        if not folder: +            self.fail("Parse error (FOLDER)")          new_links.extend(re.findall(self.LINK_PATTERN, folder.group(1))) diff --git a/module/plugins/crypter/ImgurComAlbum.py b/module/plugins/crypter/ImgurComAlbum.py index 267f92e1a..79306fc6c 100644 --- a/module/plugins/crypter/ImgurComAlbum.py +++ b/module/plugins/crypter/ImgurComAlbum.py @@ -9,7 +9,7 @@ class ImgurComAlbum(SimpleCrypter):      __type__ = "crypter"      __version__ = "0.4"      __description__ = """Imgur.com decrypter plugin""" -    __pattern__ = r"https?://(?:www\.|m\.)?imgur\.com/(a|gallery|)/?\w{5,7}" +    __pattern__ = r'https?://(?:www\.|m\.)?imgur\.com/(a|gallery|)/?\w{5,7}'      __author_name_ = "nath_schwarz"      __author_mail_ = "nathan.notwhite@gmail.com" diff --git a/module/plugins/crypter/LetitbitNetFolder.py b/module/plugins/crypter/LetitbitNetFolder.py index 8e994984b..8ae2ad118 100644 --- a/module/plugins/crypter/LetitbitNetFolder.py +++ b/module/plugins/crypter/LetitbitNetFolder.py @@ -22,7 +22,7 @@ class LetitbitNetFolder(Crypter):          new_links = []          folder = re.search(self.FOLDER_PATTERN, html, re.DOTALL) -        if folder is None: +        if not folder:              self.fail("Parse error (FOLDER)")          new_links.extend(re.findall(self.LINK_PATTERN, folder.group(0))) diff --git a/module/plugins/crypter/LinkSaveIn.py b/module/plugins/crypter/LinkSaveIn.py index 13277e3f3..e4497eb09 100644 --- a/module/plugins/crypter/LinkSaveIn.py +++ b/module/plugins/crypter/LinkSaveIn.py @@ -37,7 +37,6 @@ class LinkSaveIn(Crypter):          self.preferred_sources = ['cnl2', 'rsdf', 'ccf', 'dlc', 'web']      def decrypt(self, pyfile): -          # Init          self.package = pyfile.package()          self.fileid = re.match(self.__pattern__, pyfile.url).group('id') @@ -124,11 +123,11 @@ class LinkSaveIn(Crypter):                  self.correctCaptcha()      def handleLinkSource(self, type_): -        if type_ == 'cnl2': +        if type_ == "cnl2":              return self.handleCNL2() -        elif type_ in ('rsdf', 'ccf', 'dlc'): +        elif type_ in ("rsdf", "ccf", "dlc"):              return self.handleContainer(type_) -        elif type_ == 'web': +        elif type_ == "web":              return self.handleWebLinks()          else:              self.fail('unknown source type "%s" (this is probably a bug)' % type_) @@ -189,7 +188,6 @@ class LinkSaveIn(Crypter):          return package_links      def _getCipherParams(self): -          # Get jk          jk_re = r'<INPUT.*?NAME="%s".*?VALUE="(.*?)"' % LinkSaveIn._JK_KEY_          vjk = re.findall(jk_re, self.html) @@ -203,7 +201,6 @@ class LinkSaveIn(Crypter):          return vcrypted, vjk      def _getLinks(self, crypted, jk): -          # Get key          jreturn = self.js.eval("%s f()" % jk)          self.logDebug("JsEngine returns value [%s]" % jreturn) diff --git a/module/plugins/crypter/MultiUpOrg.py b/module/plugins/crypter/MultiUpOrg.py index a565b3888..d08daaf75 100644 --- a/module/plugins/crypter/MultiUpOrg.py +++ b/module/plugins/crypter/MultiUpOrg.py @@ -24,7 +24,7 @@ from module.plugins.internal.SimpleCrypter import SimpleCrypter  class MultiUpOrg(SimpleCrypter):      __name__ = "MultiUpOrg"      __type__ = "crypter" -    __pattern__ = r"http://(?:www\.)?multiup\.org/(en|fr)/(?P<TYPE>project|download|miror)/\w+(/\w+)?" +    __pattern__ = r'http://(?:www\.)?multiup\.org/(en|fr)/(?P<TYPE>project|download|miror)/\w+(/\w+)?'      __version__ = "0.01"      __description__ = """MultiUp.org crypter plugin"""      __author_name__ = "Walter Purcaro" diff --git a/module/plugins/crypter/NCryptIn.py b/module/plugins/crypter/NCryptIn.py index eacd4aa8d..cadf2760f 100644 --- a/module/plugins/crypter/NCryptIn.py +++ b/module/plugins/crypter/NCryptIn.py @@ -32,7 +32,6 @@ class NCryptIn(Crypter):          self.protection_type = None      def decrypt(self, pyfile): -          # Init          self.package = pyfile.package()          package_links = [] @@ -75,7 +74,7 @@ class NCryptIn(Crypter):      def isSingleLink(self):          link_type = re.match(self.__pattern__, self.pyfile.url).group('type') -        return link_type in ('link', 'frame') +        return link_type in ("link", "frame")      def requestFolderHome(self):          return self.load(self.pyfile.url, decode=True) @@ -163,7 +162,6 @@ class NCryptIn(Crypter):          return self.load(self.pyfile.url, post=postData, decode=True)      def handleErrors(self): -          if self.protection_type == "password":              if "This password is invalid!" in self.cleanedHtml:                  self.logDebug("Incorrect password, please set right password on 'Edit package' form and retry") @@ -178,9 +176,8 @@ class NCryptIn(Crypter):                  self.correctCaptcha()      def handleLinkSource(self, link_source_type): -          # Check for JS engine -        require_js_engine = link_source_type in ('cnl2', 'rsdf', 'ccf', 'dlc') +        require_js_engine = link_source_type in ("cnl2", "rsdf", "ccf", "dlc")          if require_js_engine and not self.js:              self.logDebug("No JS engine available, skip %s links" % link_source_type)              return [] @@ -190,9 +187,9 @@ class NCryptIn(Crypter):              return self.handleSingleLink()          if link_source_type == 'cnl2':              return self.handleCNL2() -        elif link_source_type in ('rsdf', 'ccf', 'dlc'): +        elif link_source_type in ("rsdf", "ccf", "dlc"):              return self.handleContainer(link_source_type) -        elif link_source_type == 'web': +        elif link_source_type == "web":              return self.handleWebLinks()          else:              self.fail('unknown source type "%s" (this is probably a bug)' % link_source_type) @@ -279,7 +276,6 @@ class NCryptIn(Crypter):          return vcrypted, vjk      def _getLinks(self, crypted, jk): -          # Get key          jreturn = self.js.eval("%s f()" % jk)          self.logDebug("JsEngine returns value [%s]" % jreturn) diff --git a/module/plugins/crypter/NetfolderIn.py b/module/plugins/crypter/NetfolderIn.py index 28ee3a9dd..286b9366b 100644 --- a/module/plugins/crypter/NetfolderIn.py +++ b/module/plugins/crypter/NetfolderIn.py @@ -23,7 +23,7 @@ class NetfolderIn(SimpleCrypter):          # Check for password protection              if self.isPasswordProtected():              self.html = self.submitPassword() -            if self.html is None: +            if not self.html:                  self.fail("Incorrect password, please set right password on Add package form and retry")          # Get package name and folder @@ -36,7 +36,6 @@ class NetfolderIn(SimpleCrypter):          self.packages = [(package_name, package_links, folder_name)]      def isPasswordProtected(self): -          if '<input type="password" name="password"' in self.html:              self.logDebug("Links are password protected")              return True diff --git a/module/plugins/crypter/QuickshareCzFolder.py b/module/plugins/crypter/QuickshareCzFolder.py index 13d7671bf..a412a5d18 100644 --- a/module/plugins/crypter/QuickshareCzFolder.py +++ b/module/plugins/crypter/QuickshareCzFolder.py @@ -21,7 +21,7 @@ class QuickshareCzFolder(Crypter):          new_links = []          found = re.search(self.FOLDER_PATTERN, html, re.DOTALL) -        if found is None: +        if not found:              self.fail("Parse error (FOLDER)")          new_links.extend(re.findall(self.LINK_PATTERN, found.group(1))) diff --git a/module/plugins/crypter/RelinkUs.py b/module/plugins/crypter/RelinkUs.py index f6503374f..f5c158d2e 100644 --- a/module/plugins/crypter/RelinkUs.py +++ b/module/plugins/crypter/RelinkUs.py @@ -51,7 +51,6 @@ class RelinkUs(Crypter):          self.captcha = False      def decrypt(self, pyfile): -          # Init          self.initPackage(pyfile) @@ -226,7 +225,6 @@ class RelinkUs(Crypter):          return package_links      def _getCipherParams(self, cnl2_form): -          # Get jk          jk_re = self.CNL2_FORMINPUT_REGEX % self.CNL2_JK_KEY          vjk = re.findall(jk_re, cnl2_form, re.IGNORECASE) @@ -240,7 +238,6 @@ class RelinkUs(Crypter):          return vcrypted, vjk      def _getLinks(self, crypted, jk): -          # Get key          jreturn = self.js.eval("%s f()" % jk)          self.logDebug("JsEngine returns value [%s]" % jreturn) diff --git a/module/plugins/crypter/SafelinkingNet.py b/module/plugins/crypter/SafelinkingNet.py index 4a907c28d..cb2617168 100644 --- a/module/plugins/crypter/SafelinkingNet.py +++ b/module/plugins/crypter/SafelinkingNet.py @@ -10,10 +10,10 @@ from module.lib.BeautifulSoup import BeautifulSoup  class SafelinkingNet(Crypter): -    __name__ = 'SafelinkingNet' -    __type__ = 'crypter' +    __name__ = "SafelinkingNet" +    __type__ = "crypter"      __pattern__ = r'https?://(?:www\.)?safelinking.net/([pd])/\w+' -    __version__ = '0.1' +    __version__ = "0.1"      __description__ = """Safelinking.net decrypter plugin"""      __author_name__ = "quareevo"      __author_mail__ = "quareevo@arcor.de" diff --git a/module/plugins/crypter/ShareLinksBiz.py b/module/plugins/crypter/ShareLinksBiz.py index bd23d4751..4ea5955db 100644 --- a/module/plugins/crypter/ShareLinksBiz.py +++ b/module/plugins/crypter/ShareLinksBiz.py @@ -25,7 +25,6 @@ class ShareLinksBiz(Crypter):          self.captcha = False      def decrypt(self, pyfile): -          # Init          self.initFile(pyfile) @@ -111,7 +110,7 @@ class ShareLinksBiz(Crypter):          # Resolve captcha          href = self._resolveCoords(coords, captchaMap) -        if href is None: +        if not href:              self.logDebug("Invalid captcha resolving, retrying")              self.invalidCaptcha()              self.setWait(5, False) @@ -223,7 +222,6 @@ class ShareLinksBiz(Crypter):          return package_links      def _getCipherParams(self): -          # Request CNL2          code = re.search(r'ClicknLoad.swf\?code=(.*?)"', self.html).group(1)          url = "%s/get/cnl2/%s" % (self.baseUrl, code) @@ -244,7 +242,6 @@ class ShareLinksBiz(Crypter):          return crypted, jk      def _getLinks(self, crypted, jk): -          # Get key          jreturn = self.js.eval("%s f()" % jk)          self.logDebug("JsEngine returns value [%s]" % jreturn) diff --git a/module/plugins/crypter/UlozToFolder.py b/module/plugins/crypter/UlozToFolder.py index eebb14497..6c7729fee 100644 --- a/module/plugins/crypter/UlozToFolder.py +++ b/module/plugins/crypter/UlozToFolder.py @@ -24,7 +24,7 @@ class UlozToFolder(Crypter):          for i in xrange(1, 100):              self.logInfo("Fetching links from page %i" % i)              found = re.search(self.FOLDER_PATTERN, html, re.DOTALL) -            if found is None: +            if not found:                  self.fail("Parse error (FOLDER)")              new_links.extend(re.findall(self.LINK_PATTERN, found.group(1))) diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index 1c9c4e722..05cf29500 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -27,6 +27,7 @@ PYLOAD_KEY = "4f771155b640970d5607f919a615bdefc67e7d32"  class BypassCaptchaException(Exception): +      def __init__(self, err):          self.err = err diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index 86768b76b..b413bdb59 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -29,6 +29,7 @@ from module.plugins.Hook import Hook  class CaptchaBrotherhoodException(Exception): +      def __init__(self, err):          self.err = err diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index 48b262392..1c80facc9 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -20,8 +20,8 @@ from module.plugins.Hook import Hook  class DeleteFinished(Hook): -    __name__ = 'DeleteFinished' -    __version__ = '1.09' +    __name__ = "DeleteFinished" +    __version__ = "1.09"      __type__ = "hook"      __config__ = [('activated', 'bool', 'Activated', 'False'), @@ -29,8 +29,8 @@ class DeleteFinished(Hook):                    ('deloffline', 'bool', 'Delete packages with offline links', 'False')]      __description__ = """Automatically delete all finished packages from queue""" -    __author_name__ = ('Walter Purcaro') -    __author_mail__ = ('vuolter@gmail.com') +    __author_name__ = "Walter Purcaro" +    __author_mail__ = "vuolter@gmail.com"      ## overwritten methods ## diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index 070c0634e..dbc1019e3 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -43,7 +43,7 @@ class DownloadScheduler(Hook):          self.updateSchedule()      def updateSchedule(self, schedule=None): -        if schedule is None: +        if not schedule:              schedule = self.getConfig("timetable")          schedule = re.findall("(\d{1,2}):(\d{2})[\s]*(-?\d+)", diff --git a/module/plugins/hooks/Ev0InFetcher.py b/module/plugins/hooks/Ev0InFetcher.py index d2caa19ac..3a98abbf7 100644 --- a/module/plugins/hooks/Ev0InFetcher.py +++ b/module/plugins/hooks/Ev0InFetcher.py @@ -57,7 +57,9 @@ class Ev0InFetcher(Hook):                  continue          return [] +      def periodical(self): +          def normalizefiletitle(filename):              filename = filename.replace('.', ' ')              filename = filename.replace('_', ' ') diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py index bd57712af..08ef93812 100644 --- a/module/plugins/hooks/HotFolder.py +++ b/module/plugins/hooks/HotFolder.py @@ -46,7 +46,6 @@ class HotFolder(Hook):          self.interval = 10      def periodical(self): -          if not exists(join(self.getConfig("folder"), "finished")):              makedirs(join(self.getConfig("folder"), "finished")) diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 41ca352a4..7dbe835c7 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -311,12 +311,10 @@ class IRCInterface(Thread, Hook):          return lines      def event_start(self, args): -          self.api.unpauseServer()          return ["INFO: Starting downloads."]      def event_stop(self, args): -          self.api.pauseServer()          return ["INFO: No new downloads will be started."] @@ -415,6 +413,7 @@ class IRCInterface(Thread, Hook):  class IRCError(Exception): +      def __init__(self, value):          self.value = value diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index 3c23f9567..794db3913 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -25,6 +25,7 @@ from module.plugins.Hook import Hook  class ImageTyperzException(Exception): +      def __init__(self, err):          self.err = err diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index 5a7e53b0d..31bbbcc9a 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -73,6 +73,7 @@ class MultiHome(Hook):  class Interface(object): +      def __init__(self, adress):          self.adress = adress          self.history = {} diff --git a/module/plugins/hooks/SimplyPremiumCom.py b/module/plugins/hooks/SimplyPremiumCom.py index dbba3d1e9..41268e231 100644 --- a/module/plugins/hooks/SimplyPremiumCom.py +++ b/module/plugins/hooks/SimplyPremiumCom.py @@ -1,5 +1,4 @@  # -*- coding: utf-8 -*- -  ############################################################################  # This program is free software: you can redistribute it and/or modify     #  # it under the terms of the GNU Affero General Public License as           # @@ -15,9 +14,9 @@  # along with this program.  If not, see <http://www.gnu.org/licenses/>.    #  ############################################################################ -from module.plugins.internal.MultiHoster import MultiHoster -from module.network.RequestFactory import getURL  from module.common.json_layer import json_loads +from module.network.RequestFactory import getURL +from module.plugins.internal.MultiHoster import MultiHoster  class SimplyPremiumCom(MultiHoster): @@ -31,7 +30,7 @@ class SimplyPremiumCom(MultiHoster):                    ("unloadFailing", "bool", "Revert to standard download if download fails", "False"),                    ("interval", "int", "Reload interval in hours (0 to disable)", "24")] -    __description__ = """Simply-Premium.Com hook plugin""" +    __description__ = """Simply-Premium.com hook plugin"""      __author_name__ = "EvolutionClip"      __author_mail__ = "evolutionclip@live.de" diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index f25482b79..d40854e99 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -22,8 +22,8 @@ from module.PyFile import PyFile  class UnSkipOnFail(Hook): -    __name__ = 'UnSkipOnFail' -    __version__ = '0.01' +    __name__ = "UnSkipOnFail" +    __version__ = "0.01"      __type__ = "hook"      __config__ = [("activated", "bool", "Activated", True)] diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index 7b179d41a..57a997a4b 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -130,7 +130,7 @@ class XMPPInterface(IRCInterface, JabberClient):          subject = stanza.get_subject()          body = stanza.get_body()          t = stanza.get_type() -        self.logDebug(u'pyLoad XMPP: Message from %s received.' % (unicode(stanza.get_from(), ))) +        self.logDebug(u'pyLoad XMPP: Message from %s received.' % (unicode(stanza.get_from(),)))          self.logDebug(u'pyLoad XMPP: Body: %s Subject: %s Type: %s' % (body, subject, t))          if t == "headline": diff --git a/module/plugins/hoster/CzshareCom.py b/module/plugins/hoster/CzshareCom.py index b4a1d77cc..7866a771e 100644 --- a/module/plugins/hoster/CzshareCom.py +++ b/module/plugins/hoster/CzshareCom.py @@ -89,7 +89,7 @@ class CzshareCom(SimpleHoster):      def handleFree(self):          # get free url          found = re.search(self.FREE_URL_PATTERN, self.html) -        if found is None: +        if not found:              self.parseError('Free URL')          parsed_url = "http://sdilej.cz" + found.group(1)          self.logDebug("PARSED_URL:" + parsed_url) diff --git a/module/plugins/hoster/DlFreeFr.py b/module/plugins/hoster/DlFreeFr.py index 68ffd7619..03c8f10cd 100644 --- a/module/plugins/hoster/DlFreeFr.py +++ b/module/plugins/hoster/DlFreeFr.py @@ -10,12 +10,13 @@ from module.network.CookieJar import CookieJar  class CustomBrowser(Browser): +      def __init__(self, bucket=None, options={}):          Browser.__init__(self, bucket, options)      def load(self, *args, **kwargs):          post = kwargs.get("post") -        if post is None: +        if not post:              if len(args) > 2:                  post = args[2]          if post: diff --git a/module/plugins/hoster/EdiskCz.py b/module/plugins/hoster/EdiskCz.py index c753e64a1..fae85d2b6 100644 --- a/module/plugins/hoster/EdiskCz.py +++ b/module/plugins/hoster/EdiskCz.py @@ -44,7 +44,7 @@ class EdiskCz(SimpleHoster):          self.logDebug('URL:' + url)          found = re.search(self.ACTION_PATTERN, url) -        if found is None: +        if not found:              self.parseError("ACTION")          action = found.group(1) diff --git a/module/plugins/hoster/EuroshareEu.py b/module/plugins/hoster/EuroshareEu.py index 3ec319129..a2a13ebf7 100644 --- a/module/plugins/hoster/EuroshareEu.py +++ b/module/plugins/hoster/EuroshareEu.py @@ -62,7 +62,7 @@ class EuroshareEu(SimpleHoster):              self.longWait(5 * 60, 12)          found = re.search(self.FREE_URL_PATTERN, self.html) -        if found is None: +        if not found:              self.parseError("Parse error (URL)")          parsed_url = "http://euroshare.eu%s" % found.group(1)          self.logDebug("URL", parsed_url) diff --git a/module/plugins/hoster/FileshareInUa.py b/module/plugins/hoster/FileshareInUa.py index 4ec33485e..52e084b9c 100644 --- a/module/plugins/hoster/FileshareInUa.py +++ b/module/plugins/hoster/FileshareInUa.py @@ -46,7 +46,7 @@ class FileshareInUa(Hoster):      def _getName(self):          name = re.search(self.PATTERN_FILENAME, self.html) -        if name is None: +        if not name:              self.fail("%s: Plugin broken." % self.__name__)          return name.group(1) @@ -66,7 +66,7 @@ def getInfo(urls):          else:              name = re.search(FileshareInUa.PATTERN_FILENAME, html) -            if name is None: +            if not name:                  result.append((url, 0, 1, url))                  continue diff --git a/module/plugins/hoster/FreakshareCom.py b/module/plugins/hoster/FreakshareCom.py index 5b043d53d..ddb5a9ec0 100644 --- a/module/plugins/hoster/FreakshareCom.py +++ b/module/plugins/hoster/FreakshareCom.py @@ -82,7 +82,7 @@ class FreakshareCom(Hoster):      def get_file_url(self):          """ returns the absolute downloadable filepath          """ -        if self.html is None: +        if not self.html:              self.download_html()          if not self.wantReconnect:              self.req_opts = self.get_download_options()  # get the Post options for the Request @@ -92,7 +92,7 @@ class FreakshareCom(Hoster):              self.offline()      def get_file_name(self): -        if self.html is None: +        if not self.html:              self.download_html()          if not self.wantReconnect:              file_name = re.search(r"<h1\sclass=\"box_heading\"\sstyle=\"text-align:center;\">([^ ]+)", self.html) @@ -106,7 +106,7 @@ class FreakshareCom(Hoster):      def get_file_size(self):          size = 0 -        if self.html is None: +        if not self.html:              self.download_html()          if not self.wantReconnect:              file_size_check = re.search( @@ -119,7 +119,7 @@ class FreakshareCom(Hoster):          return size      def get_waiting_time(self): -        if self.html is None: +        if not self.html:              self.download_html()          if "Your Traffic is used up for today" in self.html: @@ -135,7 +135,7 @@ class FreakshareCom(Hoster):      def file_exists(self):          """ returns True or False          """ -        if self.html is None: +        if not self.html:              self.download_html()          if re.search(r"This file does not exist!", self.html) is not None:              return False diff --git a/module/plugins/hoster/FreevideoCz.py b/module/plugins/hoster/FreevideoCz.py index ffad94418..94c17760b 100644 --- a/module/plugins/hoster/FreevideoCz.py +++ b/module/plugins/hoster/FreevideoCz.py @@ -59,7 +59,7 @@ class FreevideoCz(Hoster):              self.offline()          found = re.search(self.LINK_PATTERN, self.html) -        if found is None: +        if not found:              self.fail("Parse error (URL)")          download_url = found.group(1) diff --git a/module/plugins/hoster/GamefrontCom.py b/module/plugins/hoster/GamefrontCom.py index 941aa2d50..112451636 100644 --- a/module/plugins/hoster/GamefrontCom.py +++ b/module/plugins/hoster/GamefrontCom.py @@ -47,7 +47,7 @@ class GamefrontCom(Hoster):      def _getName(self):          name = re.search(self.PATTERN_FILENAME, self.html) -        if name is None: +        if not name:              self.fail("%s: Plugin broken." % self.__name__)          return name.group(1) @@ -71,7 +71,7 @@ def getInfo(urls):          else:              name = re.search(GamefrontCom.PATTERN_FILENAME, html) -            if name is None: +            if not name:                  result.append((url, 0, 1, url))                  continue diff --git a/module/plugins/hoster/LetitbitNet.py b/module/plugins/hoster/LetitbitNet.py index 3814cfd9b..3df1e8330 100644 --- a/module/plugins/hoster/LetitbitNet.py +++ b/module/plugins/hoster/LetitbitNet.py @@ -92,8 +92,9 @@ class LetitbitNet(SimpleHoster):          self.html = self.load(domain + action, post=inputs, cookies=True)          # action, inputs = self.parseHtmlForm('id="d3_form"') -        # if not action: self.parseError("page 2 / d3_form") -        # #self.logDebug(action, inputs) +        # if not action: +        #     self.parseError("page 2 / d3_form") +        # self.logDebug(action, inputs)          #          # self.html = self.load(action, post = inputs, cookies = True)          # diff --git a/module/plugins/hoster/MegaNz.py b/module/plugins/hoster/MegaNz.py index a55220bc2..a396204ab 100644 --- a/module/plugins/hoster/MegaNz.py +++ b/module/plugins/hoster/MegaNz.py @@ -22,8 +22,8 @@ class MegaNz(Hoster):      __pattern__ = r'https?://([a-z0-9]+\.)?mega\.co\.nz/#!([a-zA-Z0-9!_\-]+)'      __version__ = "0.14"      __description__ = """Mega.co.nz hoster plugin""" -    __author_name__ = ("RaNaN", ) -    __author_mail__ = ("ranan@pyload.org", ) +    __author_name__ = "RaNaN" +    __author_mail__ = "ranan@pyload.org"      API_URL = "https://g.api.mega.co.nz/cs?id=%d"      FILE_SUFFIX = ".crypted" diff --git a/module/plugins/hoster/MegacrypterCom.py b/module/plugins/hoster/MegacrypterCom.py index 9fcf40214..378acd856 100644 --- a/module/plugins/hoster/MegacrypterCom.py +++ b/module/plugins/hoster/MegacrypterCom.py @@ -12,8 +12,8 @@ class MegacrypterCom(MegaNz):      __pattern__ = r'(https?://[a-z0-9]{0,10}\.?megacrypter\.com/[a-zA-Z0-9!_\-]+)'      __version__ = "0.2"      __description__ = """Megacrypter.com decrypter plugin""" -    __author_name__ = ("GonzaloSR", ) -    __author_mail__ = ("gonzalo@gonzalosr.com", ) +    __author_name__ = "GonzaloSR" +    __author_mail__ = "gonzalo@gonzalosr.com"      API_URL = "http://megacrypter.com/api"      FILE_SUFFIX = ".crypted" diff --git a/module/plugins/hoster/MegareleaseOrg.py b/module/plugins/hoster/MegareleaseOrg.py index cb8c7aa01..eea265323 100644 --- a/module/plugins/hoster/MegareleaseOrg.py +++ b/module/plugins/hoster/MegareleaseOrg.py @@ -30,4 +30,5 @@ class MegareleaseOrg(XFileSharingPro):      FILE_INFO_PATTERN = r'<font color="red">%s/(?P<N>.+)</font> \((?P<S>[^)]+)\)</font>' % __pattern__ +  getInfo = create_getInfo(MegareleaseOrg) diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py index 3284865ce..2fde7c0d3 100644 --- a/module/plugins/hoster/MegasharesCom.py +++ b/module/plugins/hoster/MegasharesCom.py @@ -56,7 +56,8 @@ class MegasharesCom(SimpleHoster):              self.retry(wait_time=5 * 60)          self.getFileInfo() -        #if self.pyfile.size > 576716800: self.fail("This file is too large for free download") +        # if self.pyfile.size > 576716800: +        #     self.fail("This file is too large for free download")          # Reactivate passport if needed          found = re.search(self.REACTIVATE_PASSPORT_PATTERN, self.html) diff --git a/module/plugins/hoster/MovReelCom.py b/module/plugins/hoster/MovReelCom.py index f719982cb..266e9dc55 100644 --- a/module/plugins/hoster/MovReelCom.py +++ b/module/plugins/hoster/MovReelCom.py @@ -5,6 +5,7 @@ from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInf  #from pycurl import FOLLOWLOCATION, LOW_SPEED_TIME +  class MovReelCom(XFileSharingPro):      __name__ = "MovReelCom"      __type__ = "hoster" diff --git a/module/plugins/hoster/NetloadIn.py b/module/plugins/hoster/NetloadIn.py index a011d87b4..043de5463 100644 --- a/module/plugins/hoster/NetloadIn.py +++ b/module/plugins/hoster/NetloadIn.py @@ -24,7 +24,7 @@ def getInfo(urls):          api = getURL(apiurl + ids, decode=True) -        if api is None or len(api) < 10: +        if not api or len(api) < 10:              print "Netload prefetch: failed "              return          if api.find("unknown_auth") >= 0: diff --git a/module/plugins/hoster/OneFichierCom.py b/module/plugins/hoster/OneFichierCom.py index 2d539f851..e43f807a2 100644 --- a/module/plugins/hoster/OneFichierCom.py +++ b/module/plugins/hoster/OneFichierCom.py @@ -83,4 +83,5 @@ class OneFichierCom(SimpleHoster):          self.retry() +  getInfo = create_getInfo(OneFichierCom) diff --git a/module/plugins/hoster/PornhostCom.py b/module/plugins/hoster/PornhostCom.py index 61b382c81..18032519c 100644 --- a/module/plugins/hoster/PornhostCom.py +++ b/module/plugins/hoster/PornhostCom.py @@ -21,7 +21,7 @@ class PornhostCom(Hoster):          pyfile.name = self.get_file_name()          self.download(self.get_file_url()) -    ###   old interface +    # Old interface      def download_html(self):          url = self.pyfile.url          self.html = self.load(url) @@ -29,7 +29,7 @@ class PornhostCom(Hoster):      def get_file_url(self):          """ returns the absolute downloadable filepath          """ -        if self.html is None: +        if not self.html:              self.download_html()          file_url = re.search(r'download this file</label>.*?<a href="(.*?)"', self.html) @@ -46,7 +46,7 @@ class PornhostCom(Hoster):          return file_url      def get_file_name(self): -        if self.html is None: +        if not self.html:              self.download_html()          name = re.search(r'<title>pornhost\.com - free file hosting with a twist - gallery(.*?)</title>', self.html) @@ -64,7 +64,7 @@ class PornhostCom(Hoster):      def file_exists(self):          """ returns True or False          """ -        if self.html is None: +        if not self.html:              self.download_html()          if (re.search(r'gallery not found', self.html) is not None or diff --git a/module/plugins/hoster/PornhubCom.py b/module/plugins/hoster/PornhubCom.py index 29205b381..2fc08cfd3 100644 --- a/module/plugins/hoster/PornhubCom.py +++ b/module/plugins/hoster/PornhubCom.py @@ -28,7 +28,7 @@ class PornhubCom(Hoster):      def get_file_url(self):          """ returns the absolute downloadable filepath          """ -        if self.html is None: +        if not self.html:              self.download_html()          url = "http://www.pornhub.com//gateway.php" @@ -56,7 +56,7 @@ class PornhubCom(Hoster):          return file_url      def get_file_name(self): -        if self.html is None: +        if not self.html:              self.download_html()          match = re.search(r'<title[^>]+>([^<]+) - ', self.html) @@ -74,7 +74,7 @@ class PornhubCom(Hoster):      def file_exists(self):          """ returns True or False          """ -        if self.html is None: +        if not self.html:              self.download_html()          if re.search(r'This video is no longer in our database or is in conversion', self.html) is not None: diff --git a/module/plugins/hoster/PotloadCom.py b/module/plugins/hoster/PotloadCom.py index ffcfad1a5..7b3b25c34 100644 --- a/module/plugins/hoster/PotloadCom.py +++ b/module/plugins/hoster/PotloadCom.py @@ -1,18 +1,20 @@  # -*- coding: utf-8 -*- +  from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo  class PotloadCom(XFileSharingPro):      __name__ = "PotloadCom"      __type__ = "hoster" -    __pattern__ = r"http://(?:www\.)?potload\.com/\w{12}" +    __pattern__ = r'http://(?:www\.)?potload\.com/\w{12}'      __version__ = "0.01" -    __description__ = """billionuploads.com hoster plugin""" -    __author_name__ = ("stickell") -    __author_mail__ = ("l.stickell@yahoo.it") +    __description__ = """Potload.com hoster plugin""" +    __author_name__ = "stickell" +    __author_mail__ = "l.stickell@yahoo.it" -    FILE_INFO_PATTERN = r'<h[1-6]>(?P<N>.+) \((?P<S>\d+) (?P<U>\w+)\)</h'      HOSTER_NAME = "potload.com" +    FILE_INFO_PATTERN = r'<h[1-6]>(?P<N>.+) \((?P<S>\d+) (?P<U>\w+)\)</h' +  getInfo = create_getInfo(PotloadCom) diff --git a/module/plugins/hoster/PromptfileCom.py b/module/plugins/hoster/PromptfileCom.py index 0b20094aa..ac3af3753 100644 --- a/module/plugins/hoster/PromptfileCom.py +++ b/module/plugins/hoster/PromptfileCom.py @@ -1,5 +1,4 @@  # -*- coding: utf-8 -*- -  ############################################################################  # This program is free software: you can redistribute it and/or modify     #  # it under the terms of the GNU Affero General Public License as           # @@ -23,10 +22,11 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo  class PromptfileCom(SimpleHoster):      __name__ = "PromptfileCom"      __type__ = "hoster" -    __pattern__ = r"https?://(?:www\.)?promptfile\.com/" +    __pattern__ = r'https?://(?:www\.)?promptfile\.com/'      __version__ = "0.1" -    __description__ = """Promptfile.Com File Download Hoster""" -    __author_name__ = ("igel") +    __description__ = """Promptfile.com hoster plugin""" +    __author_name__ = "igel" +    __author_mail__ = "igelkun@myopera.com"      FILE_INFO_PATTERN = r'<span style="[^"]*" title="[^"]*">(?P<N>.*?) \((?P<S>[\d.]+) (?P<U>\w+)\)</span>'      OFFLINE_PATTERN = r'<span style="[^"]*" title="File Not Found">File Not Found</span>' @@ -49,7 +49,7 @@ class PromptfileCom(SimpleHoster):          if not m:              self.parseError("Unable to detect direct link")          direct = m.group(1) -        self.logDebug('found direct link: ' + direct) +        self.logDebug("found direct link: " + direct)          self.download(direct, disposition=True) diff --git a/module/plugins/hoster/QuickshareCz.py b/module/plugins/hoster/QuickshareCz.py index b4693f7ba..35506c5da 100644 --- a/module/plugins/hoster/QuickshareCz.py +++ b/module/plugins/hoster/QuickshareCz.py @@ -66,7 +66,7 @@ class QuickshareCz(SimpleHoster):      def handleFree(self):          # get download url          download_url = '%s/download.php' % self.jsvars['server'] -        data = dict((x, self.jsvars[x]) for x in self.jsvars if x in ('ID1', 'ID2', 'ID3', 'ID4')) +        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) @@ -95,7 +95,7 @@ class QuickshareCz(SimpleHoster):      def handlePremium(self):          download_url = '%s/download_premium.php' % self.jsvars['server'] -        data = dict((x, self.jsvars[x]) for x in self.jsvars if x in ('ID1', 'ID2', 'ID4', 'ID5')) +        data = dict((x, self.jsvars[x]) for x in self.jsvars if x in ("ID1", "ID2", "ID4", "ID5"))          self.logDebug("PREMIUM URL:" + download_url, data)          self.download(download_url, get=data) diff --git a/module/plugins/hoster/RPNetBiz.py b/module/plugins/hoster/RPNetBiz.py index 57c22698d..7c6892d8d 100644 --- a/module/plugins/hoster/RPNetBiz.py +++ b/module/plugins/hoster/RPNetBiz.py @@ -20,7 +20,6 @@ class RPNetBiz(Hoster):          self.resumeDownload = True      def process(self, pyfile): -          if re.match(self.__pattern__, pyfile.url):              link_status = {'generated': pyfile.url}          elif not self.account: diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index e5ab6b445..4ecd3c841 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -109,7 +109,6 @@ class RapidshareCom(Hoster):              self.fail("Unknown response code.")      def handleFree(self): -          while self.no_download:              self.dl_dict = self.freeWait() diff --git a/module/plugins/hoster/RedtubeCom.py b/module/plugins/hoster/RedtubeCom.py index a2bbf3883..465803a1c 100644 --- a/module/plugins/hoster/RedtubeCom.py +++ b/module/plugins/hoster/RedtubeCom.py @@ -29,7 +29,7 @@ class RedtubeCom(Hoster):      def get_file_url(self):          """ returns the absolute downloadable filepath          """ -        if self.html is None: +        if not self.html:              self.download_html()          file_url = unescape(re.search(r'hashlink=(http.*?)"', self.html).group(1)) @@ -37,7 +37,7 @@ class RedtubeCom(Hoster):          return file_url      def get_file_name(self): -        if self.html is None: +        if not self.html:              self.download_html()          name = re.search('<title>(.*?)- RedTube - Free Porn Videos</title>', self.html).group(1).strip() + ".flv" @@ -46,7 +46,7 @@ class RedtubeCom(Hoster):      def file_exists(self):          """ returns True or False          """ -        if self.html is None: +        if not self.html:              self.download_html()          if re.search(r'This video has been removed.', self.html) is not None: diff --git a/module/plugins/hoster/RgHostNet.py b/module/plugins/hoster/RgHostNet.py index b6d34e4fc..fafa6f2f8 100644 --- a/module/plugins/hoster/RgHostNet.py +++ b/module/plugins/hoster/RgHostNet.py @@ -24,4 +24,5 @@ class RgHostNet(SimpleHoster):          download_link = found.group(1)          self.download(download_link, disposition=True) +  getInfo = create_getInfo(RgHostNet) diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py index a5bd9c250..78cc29fdb 100644 --- a/module/plugins/hoster/ShareonlineBiz.py +++ b/module/plugins/hoster/ShareonlineBiz.py @@ -144,7 +144,7 @@ class ShareonlineBiz(Hoster):          else:              self.correctCaptcha() -    def handlePremium(self):  # should be working better loading (account) api internally +    def handlePremium(self):  #: should be working better loading (account) api internally          self.account.getAccountInfo(self.user, True)          src = self.load("http://api.share-online.biz/account.php",                          {"username": self.user, "password": self.account.accounts[self.user]["password"], @@ -179,9 +179,9 @@ class ShareonlineBiz(Hoster):          msg = found.group(1) if found else ""          self.logError(err, msg or "Unknown error occurred") -        if err in ('invalid'): +        if err == "invalid":              self.fail(msg or "File not available") -        elif err in ('freelimit', 'size', 'proxy'): +        elif err in ("freelimit", "size", "proxy"):              self.fail(msg or "Premium account needed")          else:              if err in 'server': diff --git a/module/plugins/hoster/ShareplaceCom.py b/module/plugins/hoster/ShareplaceCom.py index 4c81cf149..cfc2807f9 100644 --- a/module/plugins/hoster/ShareplaceCom.py +++ b/module/plugins/hoster/ShareplaceCom.py @@ -31,7 +31,7 @@ class ShareplaceCom(Hoster):          self.wait()      def get_waiting_time(self): -        if self.html is None: +        if not self.html:              self.download_html()          #var zzipitime = 15; @@ -62,7 +62,7 @@ class ShareplaceCom(Hoster):              self.fail("absolute filepath could not be found. offline? ")      def get_file_name(self): -        if self.html is None: +        if not self.html:              self.download_html()          return re.search("<title>\s*(.*?)\s*</title>", self.html).group(1) @@ -70,7 +70,7 @@ class ShareplaceCom(Hoster):      def file_exists(self):          """ returns True or False          """ -        if self.html is None: +        if not self.html:              self.download_html()          if re.search(r"HTTP Status 404", self.html) is not None: diff --git a/module/plugins/hoster/SimplyPremiumCom.py b/module/plugins/hoster/SimplyPremiumCom.py index dcd97d1e3..c0be4b145 100644 --- a/module/plugins/hoster/SimplyPremiumCom.py +++ b/module/plugins/hoster/SimplyPremiumCom.py @@ -1,5 +1,4 @@  # -*- coding: utf-8 -*- -  ############################################################################  # This program is free software: you can redistribute it and/or modify     #  # it under the terms of the GNU Affero General Public License as           # @@ -26,8 +25,8 @@ class SimplyPremiumCom(Hoster):      __name__ = "SimplyPremiumCom"      __version__ = "0.03"      __type__ = "hoster" -    __pattern__ = r"https?://.*(simply-premium)\.com" -    __description__ = """Simply-Premium.Com hoster plugin""" +    __pattern__ = r'https?://.*(simply-premium)\.com' +    __description__ = """Simply-Premium.com hoster plugin"""      __author_name__ = "EvolutionClip"      __author_mail__ = "evolutionclip@live.de" diff --git a/module/plugins/hoster/StreamCz.py b/module/plugins/hoster/StreamCz.py index 9e5b6233f..1b2439d98 100644 --- a/module/plugins/hoster/StreamCz.py +++ b/module/plugins/hoster/StreamCz.py @@ -59,7 +59,7 @@ class StreamCz(Hoster):              self.offline()          found = re.search(self.CDN_PATTERN, self.html) -        if found is None: +        if not found:              self.fail("Parse error (CDN)")          cdn = found.groupdict()          self.logDebug(cdn) @@ -71,7 +71,7 @@ class StreamCz(Hoster):              self.fail("Stream URL not found")          found = re.search(self.FILE_NAME_PATTERN, self.html) -        if found is None: +        if not found:              self.fail("Parse error (NAME)")          pyfile.name = "%s-%s.%s.mp4" % (found.group(2), found.group(1), cdnkey[-2:]) diff --git a/module/plugins/hoster/UlozTo.py b/module/plugins/hoster/UlozTo.py index 1299287c4..a111240ca 100644 --- a/module/plugins/hoster/UlozTo.py +++ b/module/plugins/hoster/UlozTo.py @@ -98,7 +98,7 @@ class UlozTo(SimpleHoster):          self.logDebug('inputs.keys() = ' + str(inputs.keys()))          # get and decrypt captcha -        if all(key in inputs for key in ('captcha_value', 'captcha_id', 'captcha_key')): +        if all(key in inputs for key in ("captcha_value", "captcha_id", "captcha_key")):              # Old version - last seen 9.12.2013              self.logDebug('Using "old" version') @@ -107,7 +107,7 @@ class UlozTo(SimpleHoster):              inputs.update({'captcha_id': inputs['captcha_id'], 'captcha_key': inputs['captcha_key'], 'captcha_value': captcha_value}) -        elif all(key in inputs for key in ('captcha_value', 'timestamp', 'salt', 'hash')): +        elif all(key in inputs for key in ("captcha_value", "timestamp", "salt", "hash")):              # New version - better to get new parameters (like captcha reload) because of image url - since 6.12.2013              self.logDebug('Using "new" version') diff --git a/module/plugins/hoster/UloziskoSk.py b/module/plugins/hoster/UloziskoSk.py index f2d5ce227..055083af2 100644 --- a/module/plugins/hoster/UloziskoSk.py +++ b/module/plugins/hoster/UloziskoSk.py @@ -51,19 +51,19 @@ class UloziskoSk(SimpleHoster):      def handleFree(self):          found = re.search(self.LINK_PATTERN, self.html) -        if found is None: +        if not found:              self.parseError('URL')          parsed_url = 'http://www.ulozisko.sk' + found.group(1)          found = re.search(self.ID_PATTERN, self.html) -        if found is None: +        if not found:              self.parseError('ID')          id = found.group(1)          self.logDebug('URL:' + parsed_url + ' ID:' + id)          found = re.search(self.CAPTCHA_PATTERN, self.html) -        if found is None: +        if not found:              self.parseError('CAPTCHA')          captcha_url = 'http://www.ulozisko.sk' + found.group(1) diff --git a/module/plugins/hoster/UnibytesCom.py b/module/plugins/hoster/UnibytesCom.py index 6f0fe36b8..61f254476 100644 --- a/module/plugins/hoster/UnibytesCom.py +++ b/module/plugins/hoster/UnibytesCom.py @@ -69,7 +69,7 @@ class UnibytesCom(SimpleHoster):              if last_step == 'timer':                  found = re.search(self.WAIT_PATTERN, self.html)                  self.wait(int(found.group(1)) if found else 60, False) -            elif last_step in ('captcha', 'last'): +            elif last_step in ("captcha", "last"):                  post_data['captcha'] = self.decryptCaptcha(domain + '/captcha.jpg')          else:              self.fail("No valid captcha code entered") diff --git a/module/plugins/hoster/UpstoreNet.py b/module/plugins/hoster/UpstoreNet.py index 50dc431a9..adda573bc 100644 --- a/module/plugins/hoster/UpstoreNet.py +++ b/module/plugins/hoster/UpstoreNet.py @@ -8,10 +8,11 @@ from module.plugins.internal.CaptchaService import ReCaptcha  class UpstoreNet(SimpleHoster):      __name__ = "UpstoreNet"      __type__ = "hoster" -    __pattern__ = r"https?://(?:www\.)?upstore\.net/" +    __pattern__ = r'https?://(?:www\.)?upstore\.net/'      __version__ = "0.02"      __description__ = """Upstore.Net File Download Hoster""" -    __author_name__ = ("igel") +    __author_name__ = "igel" +    __author_mail__ = "igelkun@myopera.com"      FILE_INFO_PATTERN = r'<div class="comment">.*?</div>\s*\n<h2 style="margin:0">(?P<N>.*?)</h2>\s*\n<div class="comment">\s*\n\s*(?P<S>[\d.]+) (?P<U>\w+)'      OFFLINE_PATTERN = r'<span class="error">File not found</span>' @@ -20,6 +21,7 @@ class UpstoreNet(SimpleHoster):      CHASH_PATTERN = r'<input type="hidden" name="hash" value="([^"]*)">'      LINK_PATTERN = r'<a href="(https?://.*?)" target="_blank"><b>' +      def handleFree(self):          # STAGE 1: get link to continue          m = re.search(self.CHASH_PATTERN, self.html) diff --git a/module/plugins/hoster/VeehdCom.py b/module/plugins/hoster/VeehdCom.py index 22fc4b207..fd804d3f9 100644 --- a/module/plugins/hoster/VeehdCom.py +++ b/module/plugins/hoster/VeehdCom.py @@ -5,12 +5,12 @@ from module.plugins.Hoster import Hoster  class VeehdCom(Hoster): -    __name__ = 'VeehdCom' -    __type__ = 'hoster' +    __name__ = "VeehdCom" +    __type__ = "hoster"      __pattern__ = r'http://veehd\.com/video/\d+_\S+'      __config__ = [("filename_spaces", "bool", "Allow spaces in filename", False),                    ("replacement_char", "str", "Filename replacement character", "_")] -    __version__ = '0.23' +    __version__ = "0.23"      __description__ = """Veehd.com hoster plugin"""      __author_name__ = "cat"      __author_mail__ = "cat@pyload" @@ -36,7 +36,7 @@ class VeehdCom(Hoster):          self.html = self.load(url)      def file_exists(self): -        if self.html is None: +        if not self.html:              self.download_html()          if '<title>Veehd</title>' in self.html: @@ -44,7 +44,7 @@ class VeehdCom(Hoster):          return True      def get_file_name(self): -        if self.html is None: +        if not self.html:              self.download_html()          match = re.search(r'<title[^>]*>([^<]+) on Veehd</title>', self.html) @@ -65,7 +65,7 @@ class VeehdCom(Hoster):      def get_file_url(self):          """ returns the absolute downloadable filepath          """ -        if self.html is None: +        if not self.html:              self.download_html()          match = re.search(r'<embed type="video/divx" src="(http://([^/]*\.)?veehd\.com/dl/[^"]+)"', diff --git a/module/plugins/hoster/Vipleech4uCom.py b/module/plugins/hoster/Vipleech4uCom.py index 5e0613be1..d4ccf997a 100644 --- a/module/plugins/hoster/Vipleech4uCom.py +++ b/module/plugins/hoster/Vipleech4uCom.py @@ -7,7 +7,7 @@ class Vipleech4uCom(DeadHoster):      __name__ = "Vipleech4uCom"      __version__ = "0.2"      __type__ = "hoster" -    __pattern__ = r"http://(?:www\.)?vipleech4u\.com/manager\.php" +    __pattern__ = r'http://(?:www\.)?vipleech4u\.com/manager\.php'      __description__ = """Vipleech4u.com hoster plugin"""      __author_name__ = "Kagenoshin"      __author_mail__ = "kagenoshin@gmx.ch" diff --git a/module/plugins/hoster/XHamsterCom.py b/module/plugins/hoster/XHamsterCom.py index 0f0371f21..b5b548620 100644 --- a/module/plugins/hoster/XHamsterCom.py +++ b/module/plugins/hoster/XHamsterCom.py @@ -42,13 +42,13 @@ class XHamsterCom(Hoster):      def get_file_url(self):          """ returns the absolute downloadable filepath          """ -        if self.html is None: +        if not self.html:              self.download_html()          flashvar_pattern = re.compile('flashvars = ({.*?});', re.DOTALL)          json_flashvar = flashvar_pattern.search(self.html) -        if json_flashvar is None: +        if not json_flashvar:              self.fail("Parse error (flashvars)")          j = clean_json(json_flashvar.group(1)) @@ -66,7 +66,7 @@ class XHamsterCom(Hoster):          if self.desired_fmt == ".mp4":              file_url = re.search(r"<a href=\"" + srv_url + "(.+?)\"", self.html) -            if file_url is None: +            if not file_url:                  self.fail("Parse error (file_url)")              file_url = file_url.group(1)              long_url = srv_url + file_url @@ -87,21 +87,21 @@ class XHamsterCom(Hoster):          return long_url      def get_file_name(self): -        if self.html is None: +        if not self.html:              self.download_html()          file_name_pattern = r"<title>(.*?) - xHamster\.com</title>"          file_name = re.search(file_name_pattern, self.html) -        if file_name is None: +        if not file_name:              file_name_pattern = r"<h1 >(.*)</h1>"              file_name = re.search(file_name_pattern, self.html) -            if file_name is None: +            if not file_name:                  file_name_pattern = r"http://[www.]+xhamster\.com/movies/.*/(.*?)\.html?"                  file_name = re.match(file_name_pattern, self.pyfile.url) -                if file_name is None: +                if not file_name:                      file_name_pattern = r"<div id=\"element_str_id\" style=\"display:none;\">(.*)</div>"                      file_name = re.search(file_name_pattern, self.html) -                    if file_name is None: +                    if not file_name:                          return "Unknown"          return file_name.group(1) @@ -109,7 +109,7 @@ class XHamsterCom(Hoster):      def file_exists(self):          """ returns True or False          """ -        if self.html is None: +        if not self.html:              self.download_html()          if re.search(r"(.*Video not found.*)", self.html) is not None:              return False diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py index cc9f4719c..d6083e4f7 100644 --- a/module/plugins/hoster/Xdcc.py +++ b/module/plugins/hoster/Xdcc.py @@ -62,7 +62,7 @@ class Xdcc(Hoster):                  else:                      errno = e.args[0] -                if errno in (10054,): +                if errno == 10054:                      self.logDebug("XDCC: Server blocked our ip, retry in 5 min")                      self.setWait(300)                      self.wait() diff --git a/module/plugins/hoster/YibaishiwuCom.py b/module/plugins/hoster/YibaishiwuCom.py index fc30c2f4b..0aca311ce 100644 --- a/module/plugins/hoster/YibaishiwuCom.py +++ b/module/plugins/hoster/YibaishiwuCom.py @@ -44,9 +44,16 @@ class YibaishiwuCom(SimpleHoster):          self.logDebug(('FREEUSER' if found.group(2) == 'download' else 'GUEST') + ' URL', url)          response = json_loads(self.load("http://115.com" + url, decode=False)) -        for mirror in (response['urls'] if 'urls' in response else response['data'] if 'data' in response else []): +        if "urls" in response: +            mirrors = response['urls']  +        elif "data" in response: +            mirrors = response['data'] +        else: +            mirrors = None + +        for m in mirrors:              try: -                url = mirror['url'].replace('\\', '') +                url = m['url'].replace('\\', '')                  self.logDebug("Trying URL: " + url)                  self.download(url)                  break diff --git a/module/plugins/hoster/YoupornCom.py b/module/plugins/hoster/YoupornCom.py index 9dc1dc6e9..d5ba1f5d0 100644 --- a/module/plugins/hoster/YoupornCom.py +++ b/module/plugins/hoster/YoupornCom.py @@ -29,14 +29,14 @@ class YoupornCom(Hoster):      def get_file_url(self):          """ returns the absolute downloadable filepath          """ -        if self.html is None: +        if not self.html:              self.download_html()          file_url = re.search(r'(http://download\.youporn\.com/download/\d+\?save=1)">', self.html).group(1)          return file_url      def get_file_name(self): -        if self.html is None: +        if not self.html:              self.download_html()          file_name_pattern = r"<title>(.*) - Free Porn Videos - YouPorn</title>" @@ -45,7 +45,7 @@ class YoupornCom(Hoster):      def file_exists(self):          """ returns True or False          """ -        if self.html is None: +        if not self.html:              self.download_html()          if re.search(r"(.*invalid video_id.*)", self.html) is not None:              return False diff --git a/module/plugins/hoster/YourfilesTo.py b/module/plugins/hoster/YourfilesTo.py index c8c5c523c..3fb517eef 100644 --- a/module/plugins/hoster/YourfilesTo.py +++ b/module/plugins/hoster/YourfilesTo.py @@ -31,7 +31,7 @@ class YourfilesTo(Hoster):          self.wait()      def get_waiting_time(self): -        if self.html is None: +        if not self.html:              self.download_html()          #var zzipitime = 15; @@ -59,7 +59,7 @@ class YourfilesTo(Hoster):              self.fail("absolute filepath could not be found. offline? ")      def get_file_name(self): -        if self.html is None: +        if not self.html:              self.download_html()          return re.search("<title>(.*)</title>", self.html).group(1) @@ -67,7 +67,7 @@ class YourfilesTo(Hoster):      def file_exists(self):          """ returns True or False          """ -        if self.html is None: +        if not self.html:              self.download_html()          if re.search(r"HTTP Status 404", self.html) is not None: diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index b2f73e4ea..d8306bbb7 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -60,6 +60,7 @@ class ReCaptcha:  class AdsCaptcha(CaptchaService): +      def challenge(self, src):          js = self.plugin.req.load(src, cookies=True) diff --git a/module/plugins/internal/DeadHoster.py b/module/plugins/internal/DeadHoster.py index 77ee7c74f..a7cf1f3ea 100644 --- a/module/plugins/internal/DeadHoster.py +++ b/module/plugins/internal/DeadHoster.py @@ -4,8 +4,10 @@ from module.plugins.Hoster import Hoster as _Hoster  def create_getInfo(plugin): +      def getInfo(urls):          yield [('#N/A: ' + url, 0, 1, url) for url in urls] +      return getInfo diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index e9ba59c0d..ba143f4d8 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -53,7 +53,7 @@ def parseHtmlForm(attr_str, html, input_names=None):              name = parseHtmlTagAttrValue("name", inputtag.group(1))              if name:                  value = parseHtmlTagAttrValue("value", inputtag.group(1)) -                if value is None: +                if not value:                      inputs[name] = inputtag.group(3) or ''                  else:                      inputs[name] = value @@ -135,6 +135,7 @@ def parseFileInfo(self, url='', html=''):  def create_getInfo(plugin): +      def getInfo(urls):          for url in urls:              cj = CookieJar(plugin.__name__) @@ -152,6 +153,7 @@ def timestamp():  class PluginParseError(Exception): +      def __init__(self, msg):          Exception.__init__(self)          self.value = 'Parse error (%s) - plugin may be out of date' % msg | 
