diff options
-rw-r--r-- | pavement.py | 5 | ||||
-rw-r--r-- | pyload/AccountManager.py | 12 | ||||
-rw-r--r-- | pyload/plugins/Account.py | 5 | ||||
-rw-r--r-- | pyload/plugins/Crypter.py | 27 | ||||
-rw-r--r-- | pyload/web/app/styles/default/accounts.less | 7 | ||||
-rw-r--r-- | pyload/web/app/templates/default/accounts/account.html | 2 |
6 files changed, 38 insertions, 20 deletions
diff --git a/pavement.py b/pavement.py index 1c3cfc07a..01c16fc6f 100644 --- a/pavement.py +++ b/pavement.py @@ -73,9 +73,8 @@ module_replace = [ ('from module.unescape import unescape', 'from pyload.utils import html_unescape as unescape'), ('from module.lib.BeautifulSoup import BeautifulSoup', 'from BeautifulSoup import BeautifulSoup'), ('from module.lib import feedparser', 'import feedparser'), - ('self.account.getAccountInfo(self.user, ', 'self.account.getAccountInfo('), - ('self.account.getAccountInfo(self.user)', 'self.account.getAccountInfo()'), - ('self.account.getAccountInfo()["premium"]', 'self.account.isPremium()'), + ('self.account.getAccountInfo(self.user, ', 'self.account.getAccountData('), + ('self.account.getAccountInfo(self.user)', 'self.account.getAccountData()'), ('self.account.accounts[self.user]["password"]', 'self.account.password'), ("self.account.accounts[self.user]['password']", 'self.account.password'), ('from module.', 'from pyload.') # This should be always the last one diff --git a/pyload/AccountManager.py b/pyload/AccountManager.py index 814c08615..7820d42f6 100644 --- a/pyload/AccountManager.py +++ b/pyload/AccountManager.py @@ -61,7 +61,6 @@ class AccountManager: def loadAccounts(self): """loads all accounts available from db""" - for info, password, options in self.core.db.loadAccounts(): # put into options as used in other context options = json.loads(options) if options else {} @@ -108,7 +107,7 @@ class AccountManager: account.scheduleRefresh() self.saveAccounts() - self.sendChange(plugin, loginname) + self.core.eventManager.dispatchEvent("account:updated", account.toInfoData()) return account @lock @@ -134,11 +133,7 @@ class AccountManager: @lock def getAllAccounts(self, uid): - """ Return account info, refresh afterwards if needed - - :param refresh: - :return: - """ + """ Return account info for every visible account """ # filter by owner / shared, but admins see all accounts accounts = [] for plugin, accs in self.accounts.iteritems(): @@ -151,6 +146,3 @@ class AccountManager: for p in self.accounts.itervalues(): for acc in p: acc.getAccountInfo(True) - - def sendChange(self, plugin, name): - self.core.eventManager.dispatchEvent("account:updated", plugin, name)
\ No newline at end of file diff --git a/pyload/plugins/Account.py b/pyload/plugins/Account.py index ac2aebe3e..26a6124b6 100644 --- a/pyload/plugins/Account.py +++ b/pyload/plugins/Account.py @@ -237,9 +237,10 @@ class Account(Base): self.logDebug("Deprecated method .getAccountCookies -> use account.cj") return self.cj - def getAccountData(self, user): + def getAccountData(self, *args): self.logDebug("Deprecated method .getAccountData -> use fields directly") - return {"password": self.password} + return {"password": self.password, "premium": self.premium, "trafficleft": self.trafficleft, + "maxtraffic" : self.maxtraffic, "validuntil": self.validuntil} def isPremium(self, user=None): if user: self.logDebug("Deprecated Argument user for .isPremium()", user) diff --git a/pyload/plugins/Crypter.py b/pyload/plugins/Crypter.py index 1401d68b8..d14960308 100644 --- a/pyload/plugins/Crypter.py +++ b/pyload/plugins/Crypter.py @@ -8,8 +8,10 @@ from pyload.utils.packagetools import parseNames from Base import Base, Retry + class Package: """ Container that indicates that a new package should be created """ + def __init__(self, name, urls=None, folder=None): self.name = name self.urls = urls if urls else [] @@ -40,8 +42,10 @@ class Package: def __hash__(self): return hash(self.name) ^ hash(frozenset(self.urls)) ^ hash(self.name) + class PyFileMockup: """ Legacy class needed by old crypter plugins """ + def __init__(self, url, pack): self.url = url self.name = url @@ -51,6 +55,7 @@ class PyFileMockup: def package(self): return self._package + class Crypter(Base): """ Base class for (de)crypter plugins. Overwrite decrypt* methods. @@ -74,6 +79,9 @@ class Crypter(Base): #: Prefix to annotate that the submited string for decrypting is indeed file content CONTENT_PREFIX = "filecontent:" + #: Optional name of an account plugin that should be used, but does not guarantee that one is available + USE_ACCOUNT = None + @classmethod def decrypt(cls, core, url_or_urls): """Static method to decrypt urls or content. Can be used by other plugins. @@ -100,9 +108,20 @@ class Crypter(Base): # eliminate duplicates return uniqify(ret) + # TODO: pass user to crypter + # TODO: crypter could not only know url, but also the name and size def __init__(self, core, package=None, password=None): Base.__init__(self, core) - self.req = core.requestFactory.getRequest() + + self.req = None + # load account if set + if self.USE_ACCOUNT: + self.account = self.core.accountManager.selectAccount(self.USE_ACCOUNT, self.user) + if self.account: + self.req = self.account.getAccountRequest() + + if self.req is None: + self.req = core.requestFactory.getRequest() # Package the plugin was initialized for, don't use this, its not guaranteed to be set self.package = package @@ -158,7 +177,7 @@ class Crypter(Base): :param urls: list of urls :return: list of `Package` """ - return [Package(name, purls) for name, purls in parseNames([(url,url) for url in urls]).iteritems()] + return [Package(name, purls) for name, purls in parseNames([(url, url) for url in urls]).iteritems()] def _decrypt(self, urls): """ Internal method to select decrypting method @@ -198,7 +217,7 @@ class Crypter(Base): result.extend(to_list(self.decryptFile(c))) try: if f.startswith("tmp_"): remove(f) - except : + except: pass return result @@ -264,7 +283,7 @@ class Crypter(Base): res = [Package(name, urls) for name, urls in self.packages] res.extend(self.urls) return res - + def clean(self): if hasattr(self, "req"): self.req.close() diff --git a/pyload/web/app/styles/default/accounts.less b/pyload/web/app/styles/default/accounts.less index c388015b6..e0c7342c1 100644 --- a/pyload/web/app/styles/default/accounts.less +++ b/pyload/web/app/styles/default/accounts.less @@ -1,5 +1,12 @@ @import "common"; +.account-list { + img { + width: 26px; + height: 26px; + } +} + .logo-select { width: 20px; height: 20px; diff --git a/pyload/web/app/templates/default/accounts/account.html b/pyload/web/app/templates/default/accounts/account.html index 927072350..3b3875a3e 100644 --- a/pyload/web/app/templates/default/accounts/account.html +++ b/pyload/web/app/templates/default/accounts/account.html @@ -11,5 +11,5 @@ {{ activated }} </div> <div class="span3"> - <button type="button" class="btn btn-danger">Delete</button> + <button type="button" class="btn btn-danger"><i class="icon-trash"></i></button> </div>
\ No newline at end of file |