diff options
Diffstat (limited to 'pyload/plugins')
-rw-r--r-- | pyload/plugins/MultiHoster.py | 2 | ||||
-rw-r--r-- | pyload/plugins/accounts/PremiumizeMe.py | 41 | ||||
-rw-r--r-- | pyload/plugins/addons/MultiHoster.py | 7 | ||||
-rw-r--r-- | pyload/plugins/hoster/PremiumizeMe.py | 13 |
4 files changed, 41 insertions, 22 deletions
diff --git a/pyload/plugins/MultiHoster.py b/pyload/plugins/MultiHoster.py index e79e24746..bc7a0de75 100644 --- a/pyload/plugins/MultiHoster.py +++ b/pyload/plugins/MultiHoster.py @@ -22,7 +22,7 @@ class MultiHoster(Account): """ #: List of hoster names that will be replaced so pyLoad will recognize them: (orig_name, pyload_name) - replacements = [("freakshare.net", "freakshare.com")] + replacements = [("freakshare.net", "freakshare.com"), ("uploaded.net", "uploaded.to")] #: Load new hoster list every x seconds hoster_timeout = 300 diff --git a/pyload/plugins/accounts/PremiumizeMe.py b/pyload/plugins/accounts/PremiumizeMe.py index 696fdf88f..e8c2d277f 100644 --- a/pyload/plugins/accounts/PremiumizeMe.py +++ b/pyload/plugins/accounts/PremiumizeMe.py @@ -1,22 +1,22 @@ -from module.plugins.Account import Account +from pyload.plugins.MultiHoster import MultiHoster +from pyload.utils import json_loads -from module.common.json_layer import json_loads -class PremiumizeMe(Account): +class PremiumizeMe(MultiHoster): __name__ = "PremiumizeMe" __version__ = "0.11" __type__ = "account" __description__ = """Premiumize.Me account plugin""" - + __author_name__ = ("Florian Franzen") __author_mail__ = ("FlorianFranzen@gmail.com") def loadAccountInfo(self, user, req): - + # Get user data from premiumize.me status = self.getAccountStatus(user, req) self.logDebug(status) - + # Parse account info account_info = {"validuntil": float(status['result']['expires']), "trafficleft": max(0, status['result']['trafficleft_bytes'] / 1024)} @@ -27,18 +27,35 @@ class PremiumizeMe(Account): return account_info def login(self, user, data, req): - + # Get user data from premiumize.me status = self.getAccountStatus(user, req) - + # Check if user and password are valid if status['status'] != 200: self.wrongPassword() - + def getAccountStatus(self, user, req): - + # Use premiumize.me API v1 (see https://secure.premiumize.me/?show=api) to retrieve account info and return the parsed json answer - answer = req.load("https://api.premiumize.me/pm-api/v1.php?method=accountstatus¶ms[login]=%s¶ms[pass]=%s" % (user, self.accounts[user]['password'])) + answer = req.load( + "https://api.premiumize.me/pm-api/v1.php?method=accountstatus¶ms[login]=%s¶ms[pass]=%s" % ( + user, self.password)) return json_loads(answer) - + + + def loadHosterList(self, req): + + # Get supported hosters list from premiumize.me using the json API v1 (see https://secure.premiumize.me/?show=api) + answer = req.load( + "https://api.premiumize.me/pm-api/v1.php?method=hosterlist¶ms[login]=%s¶ms[pass]=%s" % ( + self.loginname, self.password)) + data = json_loads(answer) + + # If account is not valid thera are no hosters available + if data['status'] != 200: + return [] + + # Extract hosters from json file + return data['result']['hosterlist'] diff --git a/pyload/plugins/addons/MultiHoster.py b/pyload/plugins/addons/MultiHoster.py index 7ff6b834e..9eb323b2d 100644 --- a/pyload/plugins/addons/MultiHoster.py +++ b/pyload/plugins/addons/MultiHoster.py @@ -57,7 +57,12 @@ class MultiHoster(Addon): account.logDebug("New Hosters: %s" % ", ".join(sorted(new_supported))) # create new regexp - regexp = r".*(%s).*" % "|".join([klass.__pattern__] + [x.replace(".", "\\.") for x in new_supported]) + patterns = [x.replace(".", "\\.") for x in new_supported] + + if klass.__pattern__: + patterns.append(klass.__pattern__) + + regexp = r".*(%s).*" % "|".join(patterns) # recreate plugin tuple for new regexp hoster = self.core.pluginManager.getPlugins("hoster") diff --git a/pyload/plugins/hoster/PremiumizeMe.py b/pyload/plugins/hoster/PremiumizeMe.py index e72ade08f..85be4ec72 100644 --- a/pyload/plugins/hoster/PremiumizeMe.py +++ b/pyload/plugins/hoster/PremiumizeMe.py @@ -1,6 +1,5 @@ -from module.plugins.Hoster import Hoster - -from module.common.json_layer import json_loads +from pyload.plugins.Hoster import Hoster +from pyload.utils import json_loads class PremiumizeMe(Hoster): __name__ = "PremiumizeMe" @@ -16,7 +15,7 @@ class PremiumizeMe(Hoster): def process(self, pyfile): # Check account - if not self.account or not self.account.canUse(): + if not self.account or not self.account.isUsable(): self.logError(_("Please enter a valid premiumize.me account or deactivate this plugin")) self.fail("No valid premiumize.me account provided") @@ -29,11 +28,9 @@ class PremiumizeMe(Hoster): if temp.pop() in suffix_to_remove: self.pyfile.name = ".".join(temp) - # Get account data - (user, data) = self.account.selectAccount() - + # Get rewritten link using the premiumize.me api v1 (see https://secure.premiumize.me/?show=api) - answer = self.load("https://api.premiumize.me/pm-api/v1.php?method=directdownloadlink¶ms[login]=%s¶ms[pass]=%s¶ms[link]=%s" % (user, data['password'], self.pyfile.url)) + answer = self.load("https://api.premiumize.me/pm-api/v1.php?method=directdownloadlink¶ms[login]=%s¶ms[pass]=%s¶ms[link]=%s" % (self.account.loginname, self.account.password, self.pyfile.url)) data = json_loads(answer) # Check status and decide what to do |