diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-12-17 20:02:20 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-12-17 20:02:20 +0100 |
commit | 57300575fa97107d172e0c9909b244c8c8ae6c12 (patch) | |
tree | 86dcbc38175e55c3ac077ff9a894fe74bb3d54ea /module/plugins/hoster/OverLoadMe.py | |
parent | [FilerNet] Typo (diff) | |
download | pyload-57300575fa97107d172e0c9909b244c8c8ae6c12.tar.xz |
Extend SimpleHoster in multi-hoster plugins
Diffstat (limited to 'module/plugins/hoster/OverLoadMe.py')
-rw-r--r-- | module/plugins/hoster/OverLoadMe.py | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/module/plugins/hoster/OverLoadMe.py b/module/plugins/hoster/OverLoadMe.py index bb8d84742..7f3152dfa 100644 --- a/module/plugins/hoster/OverLoadMe.py +++ b/module/plugins/hoster/OverLoadMe.py @@ -6,11 +6,11 @@ from random import randrange from urllib import unquote from module.common.json_layer import json_loads -from module.plugins.Hoster import Hoster +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo from module.utils import parseFileSize -class OverLoadMe(Hoster): +class OverLoadMe(SimpleHoster): __name__ = "OverLoadMe" __type__ = "hoster" __version__ = "0.02" @@ -33,52 +33,48 @@ class OverLoadMe(Hoster): def setup(self): - self.chunkLimit = 5 + self.chunkLimit = 5 self.resumeDownload = True - def process(self, pyfile): - if re.match(self.__pattern__, pyfile.url): - new_url = pyfile.url - elif not self.account: - self.logError(_("Please enter your %s account or deactivate this plugin") % "Over-Load") - self.fail(_("No Over-Load account provided")) - else: - self.logDebug("Old URL: %s" % pyfile.url) - data = self.account.getAccountData(self.user) + def handleMulti(self): + data = self.account.getAccountData(self.user) - page = self.load("https://api.over-load.me/getdownload.php", - get={"auth": data['password'], "link": pyfile.url}) - data = json_loads(page) + page = self.load("https://api.over-load.me/getdownload.php", + get={"auth": data['password'], "link": self.pyfile.url}) + data = json_loads(page) - self.logDebug("Returned Data: %s" % data) + self.logDebug("Returned Data: %s" % data) - if data['error'] == 1: - self.logWarning(data['msg']) - self.tempOffline() - else: - if pyfile.name is not None and pyfile.name.endswith('.tmp') and data['filename']: - pyfile.name = data['filename'] - pyfile.size = parseFileSize(data['filesize']) - new_url = data['downloadlink'] + if data['error'] == 1: + self.logWarning(data['msg']) + self.tempOffline() + else: + if self.pyfile.name is not None and self.pyfile.name.endswith('.tmp') and data['filename']: + self.pyfile.name = data['filename'] + self.pyfile.size = parseFileSize(data['filesize']) + self.link = data['downloadlink'] if self.getConfig("https"): - new_url = new_url.replace("http://", "https://") + self.link = self.link.replace("http://", "https://") else: - new_url = new_url.replace("https://", "http://") + self.link = self.link.replace("https://", "http://") - if new_url != pyfile.url: - self.logDebug("New URL: %s" % new_url) + if self.link != self.pyfile.url: + self.logDebug("New URL: %s" % self.link) - if pyfile.name.startswith("http") or pyfile.name.startswith("Unknown") or pyfile.name.endswith('..'): + if self.pyfile.name.startswith("http") or self.pyfile.name.startswith("Unknown") or self.pyfile.name.endswith('..'): # only use when name wasn't already set - pyfile.name = self.getFilename(new_url) + self.pyfile.name = self.getFilename(self.link) - self.download(new_url, disposition=True) + def checkFile(self): check = self.checkDownload( {"error": "<title>An error occured while processing your request</title>"}) if check == "error": # usual this download can safely be retried self.retry(wait_time=60, reason=_("An error occured while generating link.")) + + +getInfo = create_getInfo(OverLoadMe) |