From f2da6bca43b619121df3f76fd27c98fa662c49db Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 16 Dec 2014 14:54:12 +0100 Subject: [UnrestrictLi] Fix secondsToMidnight on python 2.5 & 2.6 --- module/plugins/hoster/UnrestrictLi.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'module/plugins/hoster/UnrestrictLi.py') diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py index 94ce1b845..615409dab 100644 --- a/module/plugins/hoster/UnrestrictLi.py +++ b/module/plugins/hoster/UnrestrictLi.py @@ -10,18 +10,26 @@ from module.plugins.Hoster import Hoster def secondsToMidnight(gmt=0): now = datetime.utcnow() + timedelta(hours=gmt) + if now.hour is 0 and now.minute < 10: midnight = now else: midnight = now + timedelta(days=1) - midnight = midnight.replace(hour=0, minute=10, second=0, microsecond=0) - return int((midnight - now).total_seconds()) + + dt = midnight.replace(hour=0, minute=10, second=0, microsecond=0) - now + + if hasattr(dt, 'total_seconds'): + res = dt.total_seconds() + else: + res = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6 + + return int(res) class UnrestrictLi(Hoster): __name__ = "UnrestrictLi" __type__ = "hoster" - __version__ = "0.12" + __version__ = "0.13" __pattern__ = r'https?://(?:[^/]*\.)?(unrestrict|unr)\.li' -- cgit v1.2.3 From d4b3941f2a494eb42a7d80ef825a57ad083ce29e Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 16 Dec 2014 14:57:35 +0100 Subject: [UnrestrictLi] Fix secondsToMidnight on python 2.5 & 2.6 (2) --- module/plugins/hoster/UnrestrictLi.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hoster/UnrestrictLi.py') diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py index 615409dab..d5c3ddc15 100644 --- a/module/plugins/hoster/UnrestrictLi.py +++ b/module/plugins/hoster/UnrestrictLi.py @@ -16,10 +16,10 @@ def secondsToMidnight(gmt=0): else: midnight = now + timedelta(days=1) - dt = midnight.replace(hour=0, minute=10, second=0, microsecond=0) - now + td = midnight.replace(hour=0, minute=10, second=0, microsecond=0) - now - if hasattr(dt, 'total_seconds'): - res = dt.total_seconds() + if hasattr(td, 'total_seconds'): + res = td.total_seconds() else: res = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6 @@ -29,7 +29,7 @@ def secondsToMidnight(gmt=0): class UnrestrictLi(Hoster): __name__ = "UnrestrictLi" __type__ = "hoster" - __version__ = "0.13" + __version__ = "0.14" __pattern__ = r'https?://(?:[^/]*\.)?(unrestrict|unr)\.li' -- cgit v1.2.3 From 8bb189cf5495b293cf574e5049c34a64ae36ffe1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 16 Dec 2014 23:04:15 +0100 Subject: Spare code cosmetics --- module/plugins/hoster/UnrestrictLi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/UnrestrictLi.py') diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py index d5c3ddc15..786e25a9a 100644 --- a/module/plugins/hoster/UnrestrictLi.py +++ b/module/plugins/hoster/UnrestrictLi.py @@ -20,7 +20,7 @@ def secondsToMidnight(gmt=0): if hasattr(td, 'total_seconds'): res = td.total_seconds() - else: + else: #@NOTE: work-around for python 2.5 and 2.6 missing timedelta.total_seconds res = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6 return int(res) -- cgit v1.2.3 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/UnrestrictLi.py | 85 ++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 41 deletions(-) (limited to 'module/plugins/hoster/UnrestrictLi.py') diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py index 786e25a9a..d0a03d7ec 100644 --- a/module/plugins/hoster/UnrestrictLi.py +++ b/module/plugins/hoster/UnrestrictLi.py @@ -5,7 +5,7 @@ import re from datetime import datetime, timedelta from module.common.json_layer import json_loads -from module.plugins.Hoster import Hoster +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo def secondsToMidnight(gmt=0): @@ -26,7 +26,7 @@ def secondsToMidnight(gmt=0): return int(res) -class UnrestrictLi(Hoster): +class UnrestrictLi(SimpleHoster): __name__ = "UnrestrictLi" __type__ = "hoster" __version__ = "0.14" @@ -39,53 +39,53 @@ class UnrestrictLi(Hoster): def setup(self): - self.chunkLimit = 16 + self.chunkLimit = 16 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") % "Unrestrict.li") - self.fail(_("No Unrestrict.li account provided")) + def handleMulti(self): + for _i in xrange(5): + page = self.load('https://unrestrict.li/unrestrict.php', + post={'link': self.pyfile.url, 'domain': 'long'}) + self.logDebug("JSON data: " + page) + if page != '': + break else: - self.logDebug("Old URL: %s" % pyfile.url) - for _i in xrange(5): - page = self.load('https://unrestrict.li/unrestrict.php', - post={'link': pyfile.url, 'domain': 'long'}) - self.logDebug("JSON data: " + page) - if page != '': - break - else: - self.logInfo(_("Unable to get API data, waiting 1 minute and retry")) - self.retry(5, 60, "Unable to get API data") - - if 'Expired session' in page or ("You are not allowed to " - "download from this host" in page and self.premium): - self.account.relogin(self.user) - self.retry() - elif "File offline" in page: - self.offline() - elif "You are not allowed to download from this host" in page: - self.fail(_("You are not allowed to download from this host")) - elif "You have reached your daily limit for this host" in page: - self.logWarning(_("Reached daily limit for this host")) - self.retry(5, secondsToMidnight(gmt=2), "Daily limit for this host reached") - elif "ERROR_HOSTER_TEMPORARILY_UNAVAILABLE" in page: - self.logInfo(_("Hoster temporarily unavailable, waiting 1 minute and retry")) - self.retry(5, 60, "Hoster is temporarily unavailable") - page = json_loads(page) - new_url = page.keys()[0] - self.api_data = page[new_url] - - if new_url != pyfile.url: - self.logDebug("New URL: " + new_url) + self.logInfo(_("Unable to get API data, waiting 1 minute and retry")) + self.retry(5, 60, "Unable to get API data") + + if 'Expired session' in page or ("You are not allowed to " + "download from this host" in page and self.premium): + self.account.relogin(self.user) + self.retry() + + elif "File offline" in page: + self.offline() + + elif "You are not allowed to download from this host" in page: + self.fail(_("You are not allowed to download from this host")) + + elif "You have reached your daily limit for this host" in page: + self.logWarning(_("Reached daily limit for this host")) + self.retry(5, secondsToMidnight(gmt=2), "Daily limit for this host reached") + + elif "ERROR_HOSTER_TEMPORARILY_UNAVAILABLE" in page: + self.logInfo(_("Hoster temporarily unavailable, waiting 1 minute and retry")) + self.retry(5, 60, "Hoster is temporarily unavailable") + + page = json_loads(page) + self.link = page.keys()[0] + self.api_data = page[self.link] + + if self.link != self.pyfile.url: + self.logDebug("New URL: " + self.link) if hasattr(self, 'api_data'): self.setNameSize() - self.download(new_url, disposition=True) + + def checkFile(self): + super(UnrestrictLi, self).checkFile() if self.getConfig("history"): self.load("https://unrestrict.li/history/", get={'delete': "all"}) @@ -97,3 +97,6 @@ class UnrestrictLi(Hoster): self.pyfile.name = self.api_data['name'] if 'size' in self.api_data: self.pyfile.size = self.api_data['size'] + + +getInfo = create_getInfo(UnrestrictLi) -- 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/UnrestrictLi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/UnrestrictLi.py') diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py index d0a03d7ec..fcdbbd284 100644 --- a/module/plugins/hoster/UnrestrictLi.py +++ b/module/plugins/hoster/UnrestrictLi.py @@ -29,7 +29,7 @@ def secondsToMidnight(gmt=0): class UnrestrictLi(SimpleHoster): __name__ = "UnrestrictLi" __type__ = "hoster" - __version__ = "0.14" + __version__ = "0.15" __pattern__ = r'https?://(?:[^/]*\.)?(unrestrict|unr)\.li' -- 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/UnrestrictLi.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'module/plugins/hoster/UnrestrictLi.py') diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py index fcdbbd284..911061f24 100644 --- a/module/plugins/hoster/UnrestrictLi.py +++ b/module/plugins/hoster/UnrestrictLi.py @@ -38,6 +38,9 @@ class UnrestrictLi(SimpleHoster): __authors__ = [("stickell", "l.stickell@yahoo.it")] + MULTI_HOSTER = True + + def setup(self): self.chunkLimit = 16 self.resumeDownload = True -- 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/UnrestrictLi.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'module/plugins/hoster/UnrestrictLi.py') diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py index 911061f24..36d866613 100644 --- a/module/plugins/hoster/UnrestrictLi.py +++ b/module/plugins/hoster/UnrestrictLi.py @@ -5,7 +5,7 @@ import re from datetime import datetime, timedelta 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 def secondsToMidnight(gmt=0): @@ -26,10 +26,10 @@ def secondsToMidnight(gmt=0): return int(res) -class UnrestrictLi(SimpleHoster): +class UnrestrictLi(MultiHoster): __name__ = "UnrestrictLi" __type__ = "hoster" - __version__ = "0.15" + __version__ = "0.16" __pattern__ = r'https?://(?:[^/]*\.)?(unrestrict|unr)\.li' @@ -38,9 +38,6 @@ class UnrestrictLi(SimpleHoster): __authors__ = [("stickell", "l.stickell@yahoo.it")] - MULTI_HOSTER = True - - def setup(self): self.chunkLimit = 16 self.resumeDownload = True -- 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/UnrestrictLi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/UnrestrictLi.py') diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py index 36d866613..7535d7b41 100644 --- a/module/plugins/hoster/UnrestrictLi.py +++ b/module/plugins/hoster/UnrestrictLi.py @@ -29,7 +29,7 @@ def secondsToMidnight(gmt=0): class UnrestrictLi(MultiHoster): __name__ = "UnrestrictLi" __type__ = "hoster" - __version__ = "0.16" + __version__ = "0.17" __pattern__ = r'https?://(?:[^/]*\.)?(unrestrict|unr)\.li' @@ -43,7 +43,7 @@ class UnrestrictLi(MultiHoster): self.resumeDownload = True - def handleMulti(self): + def handleFree(self): for _i in xrange(5): page = self.load('https://unrestrict.li/unrestrict.php', post={'link': self.pyfile.url, 'domain': 'long'}) -- cgit v1.2.3 From 136f63dc39603814b215606f888fb2e639021277 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 26 Dec 2014 04:27:41 +0100 Subject: Spare code fixes --- module/plugins/hoster/UnrestrictLi.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'module/plugins/hoster/UnrestrictLi.py') diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py index 7535d7b41..1476efa96 100644 --- a/module/plugins/hoster/UnrestrictLi.py +++ b/module/plugins/hoster/UnrestrictLi.py @@ -29,7 +29,7 @@ def secondsToMidnight(gmt=0): class UnrestrictLi(MultiHoster): __name__ = "UnrestrictLi" __type__ = "hoster" - __version__ = "0.17" + __version__ = "0.18" __pattern__ = r'https?://(?:[^/]*\.)?(unrestrict|unr)\.li' @@ -38,6 +38,9 @@ class UnrestrictLi(MultiHoster): __authors__ = [("stickell", "l.stickell@yahoo.it")] + LOGIN_ACCOUNT = False + + def setup(self): self.chunkLimit = 16 self.resumeDownload = True -- cgit v1.2.3 From b6a2bd53628bd2824bac1dafc7b4eafdf3c815dd Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 27 Dec 2014 13:48:03 +0100 Subject: Update plugins after SimpleHoster changes --- module/plugins/hoster/UnrestrictLi.py | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'module/plugins/hoster/UnrestrictLi.py') diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py index 1476efa96..6e16cace7 100644 --- a/module/plugins/hoster/UnrestrictLi.py +++ b/module/plugins/hoster/UnrestrictLi.py @@ -6,30 +6,13 @@ from datetime import datetime, timedelta from module.common.json_layer import json_loads from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo - - -def secondsToMidnight(gmt=0): - now = datetime.utcnow() + timedelta(hours=gmt) - - if now.hour is 0 and now.minute < 10: - midnight = now - else: - midnight = now + timedelta(days=1) - - td = midnight.replace(hour=0, minute=10, second=0, microsecond=0) - now - - if hasattr(td, 'total_seconds'): - res = td.total_seconds() - else: #@NOTE: work-around for python 2.5 and 2.6 missing timedelta.total_seconds - res = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6 - - return int(res) +from module.plugins.internal.SimpleHoster import secondsToMidnight class UnrestrictLi(MultiHoster): __name__ = "UnrestrictLi" __type__ = "hoster" - __version__ = "0.18" + __version__ = "0.19" __pattern__ = r'https?://(?:[^/]*\.)?(unrestrict|unr)\.li' -- cgit v1.2.3 From 88568cf127542e2757d25705ecfdb2342b7c51b8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 30 Dec 2014 19:31:19 +0100 Subject: Update some MultiHoster __pattern__ --- module/plugins/hoster/UnrestrictLi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/UnrestrictLi.py') diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py index 6e16cace7..c84f1daa7 100644 --- a/module/plugins/hoster/UnrestrictLi.py +++ b/module/plugins/hoster/UnrestrictLi.py @@ -12,9 +12,9 @@ from module.plugins.internal.SimpleHoster import secondsToMidnight class UnrestrictLi(MultiHoster): __name__ = "UnrestrictLi" __type__ = "hoster" - __version__ = "0.19" + __version__ = "0.20" - __pattern__ = r'https?://(?:[^/]*\.)?(unrestrict|unr)\.li' + __pattern__ = r'https?://(?:www\.)?(unrestrict|unr)\.li/dl/[\w^_]+' __description__ = """Unrestrict.li hoster plugin""" __license__ = "GPLv3" -- 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/UnrestrictLi.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/hoster/UnrestrictLi.py') diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py index c84f1daa7..52f12b5b8 100644 --- a/module/plugins/hoster/UnrestrictLi.py +++ b/module/plugins/hoster/UnrestrictLi.py @@ -12,11 +12,11 @@ from module.plugins.internal.SimpleHoster import secondsToMidnight class UnrestrictLi(MultiHoster): __name__ = "UnrestrictLi" __type__ = "hoster" - __version__ = "0.20" + __version__ = "0.21" __pattern__ = r'https?://(?:www\.)?(unrestrict|unr)\.li/dl/[\w^_]+' - __description__ = """Unrestrict.li hoster plugin""" + __description__ = """Unrestrict.li multi-hoster plugin""" __license__ = "GPLv3" __authors__ = [("stickell", "l.stickell@yahoo.it")] @@ -29,10 +29,10 @@ class UnrestrictLi(MultiHoster): self.resumeDownload = True - def handleFree(self): + def handleFree(self, pyfile): for _i in xrange(5): page = self.load('https://unrestrict.li/unrestrict.php', - post={'link': self.pyfile.url, 'domain': 'long'}) + post={'link': pyfile.url, 'domain': 'long'}) self.logDebug("JSON data: " + page) if page != '': break @@ -63,7 +63,7 @@ class UnrestrictLi(MultiHoster): self.link = page.keys()[0] self.api_data = page[self.link] - if self.link != self.pyfile.url: + if self.link != pyfile.url: self.logDebug("New URL: " + self.link) if hasattr(self, 'api_data'): -- cgit v1.2.3 From 99f3e73c86c84a39d3f83611d53c8fccc1b7305f Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 13 Jan 2015 14:53:58 +0100 Subject: [SimpleHoster] Fix https://github.com/pyload/pyload/issues/1039 --- module/plugins/hoster/UnrestrictLi.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'module/plugins/hoster/UnrestrictLi.py') diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py index 52f12b5b8..e87f9b97f 100644 --- a/module/plugins/hoster/UnrestrictLi.py +++ b/module/plugins/hoster/UnrestrictLi.py @@ -2,8 +2,6 @@ import re -from datetime import datetime, timedelta - from module.common.json_layer import json_loads from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo from module.plugins.internal.SimpleHoster import secondsToMidnight -- 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/UnrestrictLi.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'module/plugins/hoster/UnrestrictLi.py') diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py index e87f9b97f..99fe01257 100644 --- a/module/plugins/hoster/UnrestrictLi.py +++ b/module/plugins/hoster/UnrestrictLi.py @@ -29,40 +29,39 @@ class UnrestrictLi(MultiHoster): def handleFree(self, pyfile): for _i in xrange(5): - page = self.load('https://unrestrict.li/unrestrict.php', + self.html = self.load('https://unrestrict.li/unrestrict.php', post={'link': pyfile.url, 'domain': 'long'}) - self.logDebug("JSON data: " + page) - if page != '': + + self.logDebug("JSON data: " + self.html) + + if self.html: break else: self.logInfo(_("Unable to get API data, waiting 1 minute and retry")) self.retry(5, 60, "Unable to get API data") - if 'Expired session' in page or ("You are not allowed to " - "download from this host" in page and self.premium): + if 'Expired session' in self.html \ + or ("You are not allowed to download from this host" in self.html and self.premium): self.account.relogin(self.user) self.retry() - elif "File offline" in page: + elif "File offline" in self.html: self.offline() - elif "You are not allowed to download from this host" in page: + elif "You are not allowed to download from this host" in self.html: self.fail(_("You are not allowed to download from this host")) - elif "You have reached your daily limit for this host" in page: + elif "You have reached your daily limit for this host" in self.html: self.logWarning(_("Reached daily limit for this host")) self.retry(5, secondsToMidnight(gmt=2), "Daily limit for this host reached") - elif "ERROR_HOSTER_TEMPORARILY_UNAVAILABLE" in page: + elif "ERROR_HOSTER_TEMPORARILY_UNAVAILABLE" in self.html: self.logInfo(_("Hoster temporarily unavailable, waiting 1 minute and retry")) self.retry(5, 60, "Hoster is temporarily unavailable") - page = json_loads(page) - self.link = page.keys()[0] - self.api_data = page[self.link] - - if self.link != pyfile.url: - self.logDebug("New URL: " + self.link) + self.html = json_loads(self.html) + self.link = self.html.keys()[0] + self.api_data = self.html[self.link] if hasattr(self, 'api_data'): self.setNameSize() -- cgit v1.2.3