From 57300575fa97107d172e0c9909b244c8c8ae6c12 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 17 Dec 2014 20:02:20 +0100 Subject: Extend SimpleHoster in multi-hoster plugins --- module/plugins/hoster/FastixRu.py | 48 ++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 26 deletions(-) (limited to 'module/plugins/hoster/FastixRu.py') diff --git a/module/plugins/hoster/FastixRu.py b/module/plugins/hoster/FastixRu.py index 1e47638ea..a4e7338fe 100644 --- a/module/plugins/hoster/FastixRu.py +++ b/module/plugins/hoster/FastixRu.py @@ -6,10 +6,10 @@ 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 -class FastixRu(Hoster): +class FastixRu(SimpleHoster): __name__ = "FastixRu" __type__ = "hoster" __version__ = "0.04" @@ -32,41 +32,34 @@ class FastixRu(Hoster): def setup(self): - self.chunkLimit = 3 + self.chunkLimit = 3 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") % "Fastix") - self.fail(_("No Fastix account provided")) - else: - self.logDebug("Old URL: %s" % pyfile.url) - api_key = self.account.getAccountData(self.user) - api_key = api_key['api'] + def handleMulti(self): + api_key = self.account.getAccountData(self.user) + api_key = api_key['api'] - page = self.load("http://fastix.ru/api_v2/", - get={'apikey': api_key, 'sub': "getdirectlink", 'link': pyfile.url}) - data = json_loads(page) + page = self.load("http://fastix.ru/api_v2/", + get={'apikey': api_key, 'sub': "getdirectlink", 'link': self.pyfile.url}) + data = json_loads(page) - self.logDebug("Json data", data) + self.logDebug("Json data", data) - if "error\":true" in page: - self.offline() - else: - new_url = data['downloadlink'] + if "error\":true" in page: + self.offline() + else: + self.link = data['downloadlink'] - 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"): + if self.pyfile.name.startswith("http") or self.pyfile.name.startswith("Unknown"): #only use when name wasnt 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": "An error occurred while processing your request", "empty": re.compile(r"^$")}) @@ -74,3 +67,6 @@ class FastixRu(Hoster): self.retry(wait_time=60, reason=_("An error occurred while generating link")) elif check == "empty": self.retry(wait_time=60, reason=_("Downloaded File was empty")) + + +getInfo = create_getInfo(FastixRu) -- cgit v1.2.3 From 46f748a94ea5ab62ab0839ff0ce01e12e3eac688 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 17 Dec 2014 21:47:39 +0100 Subject: Extend SimpleHoster in multi-hoster plugins (2) --- module/plugins/hoster/FastixRu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/FastixRu.py') diff --git a/module/plugins/hoster/FastixRu.py b/module/plugins/hoster/FastixRu.py index a4e7338fe..379ac1cd4 100644 --- a/module/plugins/hoster/FastixRu.py +++ b/module/plugins/hoster/FastixRu.py @@ -12,7 +12,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class FastixRu(SimpleHoster): __name__ = "FastixRu" __type__ = "hoster" - __version__ = "0.04" + __version__ = "0.05" __pattern__ = r'http://(?:www\.)?fastix\.(ru|it)/file/(?P\w{24})' -- cgit v1.2.3 From 0860e09f5ff16ee3f097f6f9d444f277a38abd72 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 17 Dec 2014 23:03:46 +0100 Subject: Extend SimpleHoster in multi-hoster plugins (3) --- module/plugins/hoster/FastixRu.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'module/plugins/hoster/FastixRu.py') diff --git a/module/plugins/hoster/FastixRu.py b/module/plugins/hoster/FastixRu.py index 379ac1cd4..56d1e911a 100644 --- a/module/plugins/hoster/FastixRu.py +++ b/module/plugins/hoster/FastixRu.py @@ -21,6 +21,9 @@ class FastixRu(SimpleHoster): __authors__ = [("Massimo Rosamilia", "max@spiritix.eu")] + MULTI_HOSTER = True + + def getFilename(self, url): try: name = unquote(url.rsplit("/", 1)[1]) -- cgit v1.2.3 From 4e9c8f7ab1269966a9eac9e1b6363f5458f9f970 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 18 Dec 2014 16:07:21 +0100 Subject: Update checkFile routine in some hoster plugins --- module/plugins/hoster/FastixRu.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'module/plugins/hoster/FastixRu.py') diff --git a/module/plugins/hoster/FastixRu.py b/module/plugins/hoster/FastixRu.py index 56d1e911a..8778d770e 100644 --- a/module/plugins/hoster/FastixRu.py +++ b/module/plugins/hoster/FastixRu.py @@ -12,7 +12,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class FastixRu(SimpleHoster): __name__ = "FastixRu" __type__ = "hoster" - __version__ = "0.05" + __version__ = "0.06" __pattern__ = r'http://(?:www\.)?fastix\.(ru|it)/file/(?P\w{24})' @@ -63,13 +63,10 @@ class FastixRu(SimpleHoster): def checkFile(self): - check = self.checkDownload({"error": "An error occurred while processing your request", - "empty": re.compile(r"^$")}) + super(FastixRu, self).checkFile() - if check == "error": + if self.checkDownload({"error": "An error occurred while processing your request"}) is "error": self.retry(wait_time=60, reason=_("An error occurred while generating link")) - elif check == "empty": - self.retry(wait_time=60, reason=_("Downloaded File was empty")) getInfo = create_getInfo(FastixRu) -- cgit v1.2.3 From 87203e996fb42c172b15e29f0e394d5b328d9ac2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 23 Dec 2014 13:20:53 +0100 Subject: New plugin: MultiHoster --- module/plugins/hoster/FastixRu.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'module/plugins/hoster/FastixRu.py') diff --git a/module/plugins/hoster/FastixRu.py b/module/plugins/hoster/FastixRu.py index 8778d770e..196b8479c 100644 --- a/module/plugins/hoster/FastixRu.py +++ b/module/plugins/hoster/FastixRu.py @@ -6,13 +6,13 @@ from random import randrange from urllib import unquote from module.common.json_layer import json_loads -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -class FastixRu(SimpleHoster): +class FastixRu(MultiHoster): __name__ = "FastixRu" __type__ = "hoster" - __version__ = "0.06" + __version__ = "0.07" __pattern__ = r'http://(?:www\.)?fastix\.(ru|it)/file/(?P\w{24})' @@ -21,9 +21,6 @@ class FastixRu(SimpleHoster): __authors__ = [("Massimo Rosamilia", "max@spiritix.eu")] - MULTI_HOSTER = True - - def getFilename(self, url): try: name = unquote(url.rsplit("/", 1)[1]) -- cgit v1.2.3 From a4786e340993bbfc5d2bf971c9bec18863d3dd80 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 23 Dec 2014 19:29:15 +0100 Subject: [MultiHoster] Update --- module/plugins/hoster/FastixRu.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/FastixRu.py') diff --git a/module/plugins/hoster/FastixRu.py b/module/plugins/hoster/FastixRu.py index 196b8479c..a4c85b4ca 100644 --- a/module/plugins/hoster/FastixRu.py +++ b/module/plugins/hoster/FastixRu.py @@ -12,7 +12,7 @@ from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo class FastixRu(MultiHoster): __name__ = "FastixRu" __type__ = "hoster" - __version__ = "0.07" + __version__ = "0.08" __pattern__ = r'http://(?:www\.)?fastix\.(ru|it)/file/(?P\w{24})' @@ -36,7 +36,7 @@ class FastixRu(MultiHoster): self.resumeDownload = True - def handleMulti(self): + def handlePremium(self): api_key = self.account.getAccountData(self.user) api_key = api_key['api'] -- cgit v1.2.3 From cdb06469a640c1875229903a2dbdfa8be469b5bc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 27 Dec 2014 13:52:30 +0100 Subject: Improve a lot of plugin __pattern__ --- module/plugins/hoster/FastixRu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/FastixRu.py') diff --git a/module/plugins/hoster/FastixRu.py b/module/plugins/hoster/FastixRu.py index a4c85b4ca..5f6fd2d4c 100644 --- a/module/plugins/hoster/FastixRu.py +++ b/module/plugins/hoster/FastixRu.py @@ -14,7 +14,7 @@ class FastixRu(MultiHoster): __type__ = "hoster" __version__ = "0.08" - __pattern__ = r'http://(?:www\.)?fastix\.(ru|it)/file/(?P\w{24})' + __pattern__ = r'http://(?:www\.)?fastix\.(ru|it)/file/\w{24}' __description__ = """Fastix hoster plugin""" __license__ = "GPLv3" -- cgit v1.2.3 From ea58af3c625d90aec6becfd943289e42e4a71a9a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 2 Jan 2015 02:49:26 +0100 Subject: Code cosmetics --- module/plugins/hoster/FastixRu.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'module/plugins/hoster/FastixRu.py') diff --git a/module/plugins/hoster/FastixRu.py b/module/plugins/hoster/FastixRu.py index 5f6fd2d4c..b68c79ebc 100644 --- a/module/plugins/hoster/FastixRu.py +++ b/module/plugins/hoster/FastixRu.py @@ -32,8 +32,7 @@ class FastixRu(MultiHoster): def setup(self): - self.chunkLimit = 3 - self.resumeDownload = True + self.chunkLimit = 3 def handlePremium(self): -- cgit v1.2.3 From fd105f8e51768ec1943cda2375bdfdbe5b0a3951 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 9 Jan 2015 00:35:51 +0100 Subject: "New Year" Update: hoster plugins --- module/plugins/hoster/FastixRu.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'module/plugins/hoster/FastixRu.py') diff --git a/module/plugins/hoster/FastixRu.py b/module/plugins/hoster/FastixRu.py index b68c79ebc..9a38f5a72 100644 --- a/module/plugins/hoster/FastixRu.py +++ b/module/plugins/hoster/FastixRu.py @@ -12,11 +12,11 @@ from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo class FastixRu(MultiHoster): __name__ = "FastixRu" __type__ = "hoster" - __version__ = "0.08" + __version__ = "0.09" __pattern__ = r'http://(?:www\.)?fastix\.(ru|it)/file/\w{24}' - __description__ = """Fastix hoster plugin""" + __description__ = """Fastix multi-hoster plugin""" __license__ = "GPLv3" __authors__ = [("Massimo Rosamilia", "max@spiritix.eu")] @@ -35,12 +35,12 @@ class FastixRu(MultiHoster): self.chunkLimit = 3 - def handlePremium(self): + def handlePremium(self, pyfile): api_key = self.account.getAccountData(self.user) api_key = api_key['api'] page = self.load("http://fastix.ru/api_v2/", - get={'apikey': api_key, 'sub': "getdirectlink", 'link': self.pyfile.url}) + get={'apikey': api_key, 'sub': "getdirectlink", 'link': pyfile.url}) data = json_loads(page) self.logDebug("Json data", data) @@ -50,19 +50,19 @@ class FastixRu(MultiHoster): else: self.link = data['downloadlink'] - if self.link != self.pyfile.url: + if self.link != pyfile.url: self.logDebug("New URL: %s" % self.link) - if self.pyfile.name.startswith("http") or self.pyfile.name.startswith("Unknown"): + if pyfile.name.startswith("http") or pyfile.name.startswith("Unknown"): #only use when name wasnt already set - self.pyfile.name = self.getFilename(self.link) + pyfile.name = self.getFilename(self.link) def checkFile(self): - super(FastixRu, self).checkFile() - - if self.checkDownload({"error": "An error occurred while processing your request"}) is "error": + if self.checkDownload({"error": "An error occurred while processing your request"}): self.retry(wait_time=60, reason=_("An error occurred while generating link")) + return super(FastixRu, self).checkFile() + getInfo = create_getInfo(FastixRu) -- cgit v1.2.3 From b25bc61dd47d8d3c42969bd0f72443b21c4b059e Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 8 Feb 2015 02:09:45 +0100 Subject: Spare code cosmetics --- module/plugins/hoster/FastixRu.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'module/plugins/hoster/FastixRu.py') diff --git a/module/plugins/hoster/FastixRu.py b/module/plugins/hoster/FastixRu.py index 9a38f5a72..d534101d8 100644 --- a/module/plugins/hoster/FastixRu.py +++ b/module/plugins/hoster/FastixRu.py @@ -39,20 +39,18 @@ class FastixRu(MultiHoster): api_key = self.account.getAccountData(self.user) api_key = api_key['api'] - page = self.load("http://fastix.ru/api_v2/", + self.html = self.load("http://fastix.ru/api_v2/", get={'apikey': api_key, 'sub': "getdirectlink", 'link': pyfile.url}) - data = json_loads(page) + + data = json_loads(self.html) self.logDebug("Json data", data) - if "error\":true" in page: + if "error\":true" in self.html: self.offline() else: self.link = data['downloadlink'] - if self.link != pyfile.url: - self.logDebug("New URL: %s" % self.link) - if pyfile.name.startswith("http") or pyfile.name.startswith("Unknown"): #only use when name wasnt already set pyfile.name = self.getFilename(self.link) -- cgit v1.2.3