From 856e3e90b7863807c040faadd313adcbe45fc013 Mon Sep 17 00:00:00 2001 From: GammaC0de Date: Tue, 14 Apr 2015 02:54:11 +0300 Subject: Update SimpleHoster.py --- module/plugins/internal/SimpleHoster.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 910731f95..dc4f480b9 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -623,7 +623,10 @@ class SimpleHoster(Hoster): self.tempOffline() elif status is 8: - self.fail() + if 'error' in self.info: + self.fail(self.info['error']) + else: + self.fail("Failed") finally: self.logDebug("File status: %s" % statusMap[status]) -- cgit v1.2.3 From 5c6f3886563654eb568b78356c187ccf43814787 Mon Sep 17 00:00:00 2001 From: GammaC0de Date: Tue, 14 Apr 2015 03:34:56 +0300 Subject: Update YadiSk.py --- module/plugins/hoster/YadiSk.py | 81 +++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/module/plugins/hoster/YadiSk.py b/module/plugins/hoster/YadiSk.py index c3749d30d..ad63ffb32 100644 --- a/module/plugins/hoster/YadiSk.py +++ b/module/plugins/hoster/YadiSk.py @@ -10,7 +10,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class YadiSk(SimpleHoster): __name__ = "YadiSk" __type__ = "hoster" - __version__ = "0.03" + __version__ = "0.04" __pattern__ = r'https?://yadi\.sk/d/\w+' @@ -22,6 +22,42 @@ class YadiSk(SimpleHoster): OFFLINE_PATTERN = r'Nothing found' + @classmethod + def getInfo(cls, url="", html=""): + info = super(YadiSk, cls).getInfo(url, html) + + if html: + if 'idclient' not in info: + info['idclient'] = "" + for _i in xrange(32): + info ['idclient'] += random.choice('0123456abcdef') + + m = re.search(r'', html) + if m: + api_data = json_loads(m.group(1)) + try: + for sect in api_data: + if 'model' in sect: + if sect['model'] == "config": + info['version'] = sect['data']['version'] + info['sk'] = sect['data']['sk'] + + elif sect['model'] == "resource": + info['id'] = sect['data']['id'] + info['size'] = sect['data']['meta']['size'] + info['name'] = sect['data']['name'] + + except Exception, e: + info['status'] = 8 + info['error'] = _("Unexpected server response: %s") % e.message + + else: + info['status'] = 8 + info['error'] = _("could not find required json data") + + return info + + def setup(self): self.resumeDownload = False self.multiDL = False @@ -29,51 +65,18 @@ class YadiSk(SimpleHoster): def handleFree(self, pyfile): - m = re.search(r'', self.html) - if m is None: - self.error(_("could not find required json data")) - - res = json_loads(m.group(1)) - - yadisk_ver = None - yadisk_sk = None - yadisk_id = None - yadisk_size = None - yadisk_name = None - - try: #@TODO: Copy to apiInfo - for sect in res: - if 'model' in sect: - if sect['model'] == "config": - yadisk_ver = sect['data']['version'] - yadisk_sk = sect['data']['sk'] - - elif sect['model'] == "resource": - yadisk_id = sect['data']['id'] - yadisk_size = sect['data']['meta']['size'] - yadisk_name = sect['data']['name'] - - except Exception, e: - self.fail(_("Unexpected server response"), e) - - if None in (yadisk_id, yadisk_sk, yadisk_id, yadisk_size, yadisk_name): + if any(True for _k in ['id', 'sk', 'version', 'idclient'] if _k not in self.info): self.error(_("Missing JSON data")) - self.pyfile.size = yadisk_size - self.pyfile.name = yadisk_name - - yadisk_idclient = "" - for _i in range(32): - yadisk_idclient += random.choice('0123456abcdef') try: self.html = self.load("https://yadi.sk/models/", get={'_m': "do-get-resource-url"}, - post={'idClient': yadisk_idclient, - 'version' : yadisk_ver, + post={'idClient': self.info['idclient'], + 'version' : self.info['version'], '_model.0': "do-get-resource-url", - 'sk' : yadisk_sk, - 'id.0' : yadisk_id}) + 'sk' : self.info['sk'], + 'id.0' : self.info['id']}) self.link = json_loads(self.html)['models'][0]['data']['file'] -- cgit v1.2.3 From e0860ec5345d2392ab8a982d8e1fcf9a9986a587 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 14 Apr 2015 03:23:01 +0200 Subject: [SimpleHoster] Improve latest change a little --- module/plugins/internal/SimpleHoster.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index dc4f480b9..1400fd2b6 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -623,10 +623,7 @@ class SimpleHoster(Hoster): self.tempOffline() elif status is 8: - if 'error' in self.info: - self.fail(self.info['error']) - else: - self.fail("Failed") + self.fail(self.info['error'] if 'error' in self.info else "Failed") finally: self.logDebug("File status: %s" % statusMap[status]) -- cgit v1.2.3 From 4d3e0b374ccb1dfac1c9370c3ec824890c4dd0b8 Mon Sep 17 00:00:00 2001 From: GammaC0de Date: Tue, 14 Apr 2015 11:43:44 +0300 Subject: Version bump --- module/plugins/internal/SimpleHoster.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 1400fd2b6..d65d12403 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -245,7 +245,7 @@ def secondsToMidnight(gmt=0): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "1.37" + __version__ = "1.38" __pattern__ = r'^unmatchable$' __config__ = [("use_premium", "bool", "Use premium account if available", True)] -- cgit v1.2.3 From ae14e28b210a164c3d3f58de7656d854f5f98037 Mon Sep 17 00:00:00 2001 From: GammaC0de Date: Tue, 14 Apr 2015 12:47:39 +0300 Subject: Update UpdateManager.py --- module/plugins/hooks/UpdateManager.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index d66810d6d..33de276d2 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -29,7 +29,7 @@ def exists(path): class UpdateManager(Hook): __name__ = "UpdateManager" __type__ = "hook" - __version__ = "0.50" + __version__ = "0.51" __config__ = [("activated" , "bool", "Activated" , True ), ("checkinterval", "int" , "Check interval in hours" , 8 ), @@ -45,10 +45,13 @@ class UpdateManager(Hook): interval = 0 + restartrequired = False SERVER_URL = "http://updatemanager.pyload.org" MIN_CHECK_INTERVAL = 3 * 60 * 60 #: 3 hours + event_list = ["allDownloadsProcessed"] + def coreReady(self): if self.checkonstart: @@ -68,6 +71,14 @@ class UpdateManager(Hook): else: self.checkonstart = False + self.restartrequired = False + + + def allDownloadsProcessed(self): + if self.restartrequired is True: + self.logWarning(_("Downloads are done, restarting pyLoad to reload the updated plugins")) + self.core.api.restart() + def periodical(self): if self.core.debug: @@ -128,7 +139,12 @@ class UpdateManager(Hook): self.core.api.pauseServer() if self._update() is 2 and self.getConfig('autorestart'): - self.core.api.restart() + downloads = self.core.api.statusDownloads() + if not downloads: + self.core.api.restart() + else: + self.restartrequired = True + self.logWarning(_("Downloads are active, will restart once the download is done")) else: self.core.api.unpauseServer() @@ -258,7 +274,7 @@ class UpdateManager(Hook): if self.core.pluginManager.reloadPlugins(updated): exitcode = 1 else: - self.logWarning(_("Restart pyLoad to reload the updated plugins")) + self.logWarning(_("pyLoad restart required to reload the updated plugins")) self.info['plugins'] = True exitcode = 2 -- cgit v1.2.3 From 6b271a669cd4b08cdbd8d55d9b3b4f6deec7c8ac Mon Sep 17 00:00:00 2001 From: GammaC0de Date: Thu, 16 Apr 2015 01:29:39 +0300 Subject: HostujeNet --- module/plugins/hoster/HostujeNet.py | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 module/plugins/hoster/HostujeNet.py diff --git a/module/plugins/hoster/HostujeNet.py b/module/plugins/hoster/HostujeNet.py new file mode 100644 index 000000000..2dabb72d2 --- /dev/null +++ b/module/plugins/hoster/HostujeNet.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# + + +import re + +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + + +class HostujeNet(SimpleHoster): + __name__ = "HostujeNet" + __type__ = "hoster" + __version__ = "0.01" + + __pattern__ = r'http://(?:www\.)?hostuje\.net/\w+' + + __description__ = """Hostuje.net hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("GammaC0de", None)] + + + NAME_PATTERN = r'' + SIZE_PATTERN = r'Rozmiar: (?P[\d.,]+) (?P[\w^_]+)
' + OFFLINE_PATTERN = ur'Podany plik nie został odnaleziony\.\.\.' + + + def setup(self): + self.multiDL = True + self.chunkLimit = 1 + + + def handleFree(self, pyfile): + m = re.search(r'', self.html) + if m: + jscript = self.load("http://hostuje.net/" + m.group(1)) + m = re.search(r"\('(\w+\.php\?i=\w+)'\);", jscript) + if m: + self.load("http://hostuje.net/" + m.group(1)) + else: + self.error(_("unexpected javascript format")) + else: + self.error(_("script not found")) + + action, inputs = self.parseHtmlForm(pyfile.url.replace(".", "\.").replace( "?", "\?")) + if not action: + self.error(_("form not found")) + + self.download(action, post=inputs) + + +getInfo = create_getInfo(HostujeNet) -- cgit v1.2.3 From 11d3e8c59b1addf80a0971ea0ef97347604e45ce Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 16 Apr 2015 00:46:38 +0200 Subject: [HostujeNet] Tiny cleanup --- module/plugins/hoster/HostujeNet.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/module/plugins/hoster/HostujeNet.py b/module/plugins/hoster/HostujeNet.py index 2dabb72d2..ec91e50b9 100644 --- a/module/plugins/hoster/HostujeNet.py +++ b/module/plugins/hoster/HostujeNet.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -# - import re @@ -19,13 +17,13 @@ class HostujeNet(SimpleHoster): __authors__ = [("GammaC0de", None)] - NAME_PATTERN = r'' - SIZE_PATTERN = r'Rozmiar: (?P[\d.,]+) (?P[\w^_]+)
' + NAME_PATTERN = r'' + SIZE_PATTERN = r'Rozmiar: (?P[\d.,]+) (?P[\w^_]+)
' OFFLINE_PATTERN = ur'Podany plik nie został odnaleziony\.\.\.' def setup(self): - self.multiDL = True + self.multiDL = True self.chunkLimit = 1 -- cgit v1.2.3 From e76a0a2386915cec650ca1a8eeeadc46ebf42aff Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 16 Apr 2015 16:16:24 +0200 Subject: [UploadedTo] Set DISPOSITION to False (temp) --- module/plugins/hoster/UploadedTo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index cc64a28eb..67f82d1f7 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -11,7 +11,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class UploadedTo(SimpleHoster): __name__ = "UploadedTo" __type__ = "hoster" - __version__ = "0.85" + __version__ = "0.86" __pattern__ = r'https?://(?:www\.)?(uploaded\.(to|net)|ul\.to)(/file/|/?\?id=|.*?&id=|/)(?P\w+)' __config__ = [("use_premium", "bool", "Use premium account if available", True)] @@ -21,6 +21,8 @@ class UploadedTo(SimpleHoster): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + DISPOSITION = False + API_KEY = "lhF2IeeprweDfu9ccWlxXVVypA5nA3EL" URL_REPLACEMENTS = [(__pattern__ + ".*", r'http://uploaded.net/file/\g')] -- cgit v1.2.3 From d38fc44f61177592ce0c925b947dde6a7d39d55b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 16 Apr 2015 16:19:29 +0200 Subject: [UpdateManager] Cleanup --- module/plugins/hooks/UpdateManager.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 33de276d2..5779e7c80 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -45,7 +45,6 @@ class UpdateManager(Hook): interval = 0 - restartrequired = False SERVER_URL = "http://updatemanager.pyload.org" MIN_CHECK_INTERVAL = 3 * 60 * 60 #: 3 hours @@ -71,11 +70,11 @@ class UpdateManager(Hook): else: self.checkonstart = False - self.restartrequired = False + self.do_restart = False def allDownloadsProcessed(self): - if self.restartrequired is True: + if self.do_restart is True: self.logWarning(_("Downloads are done, restarting pyLoad to reload the updated plugins")) self.core.api.restart() @@ -139,11 +138,10 @@ class UpdateManager(Hook): self.core.api.pauseServer() if self._update() is 2 and self.getConfig('autorestart'): - downloads = self.core.api.statusDownloads() - if not downloads: + if not self.core.api.statusDownloads(): self.core.api.restart() else: - self.restartrequired = True + self.do_restart = True self.logWarning(_("Downloads are active, will restart once the download is done")) else: self.core.api.unpauseServer() -- cgit v1.2.3