diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-07 21:26:23 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-07 21:26:23 +0200 |
commit | 034d87c836f9fba82142a06b5f666c84ca10bd50 (patch) | |
tree | 805cfda0521741b9da5a58c0c8f3ec6e010713d5 | |
parent | [ExtractArchive] Improve send2trash feature (diff) | |
download | pyload-034d87c836f9fba82142a06b5f666c84ca10bd50.tar.xz |
[YadiSk] Fix https://github.com/pyload/pyload/issues/1321
-rw-r--r-- | module/plugins/hooks/AntiVirus.py | 2 | ||||
-rw-r--r-- | module/plugins/hooks/ExtractArchive.py | 2 | ||||
-rw-r--r-- | module/plugins/hoster/YadiSk.py | 45 |
3 files changed, 24 insertions, 25 deletions
diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index f94d8d205..78f5aaa23 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -85,7 +85,7 @@ class AntiVirus(Hook): send2trash.send2trash(file) else: - self.logWarning("Unable to move file to trash, move to quarantine instead") + self.logWarning(_("Unable to move file to trash, move to quarantine instead")) pyfile.setCustomStatus(_("file moving")) shutil.move(file, self.getConfig('quardir')) diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 8b6a140cd..2f981d06b 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -478,7 +478,7 @@ class ExtractArchive(Hook): send2trash.send2trash(file) else: - self.logWarning("Unable to move %s to trash" % os.path.basename(f)) + self.logWarning(_("Unable to move %s to trash") % os.path.basename(f)) self.logInfo(name, _("Extracting finished")) extracted_files = archive.files or archive.list() diff --git a/module/plugins/hoster/YadiSk.py b/module/plugins/hoster/YadiSk.py index 57d8ae786..c3749d30d 100644 --- a/module/plugins/hoster/YadiSk.py +++ b/module/plugins/hoster/YadiSk.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- import re -import pycurl import random from module.common.json_layer import json_loads @@ -11,13 +10,13 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class YadiSk(SimpleHoster): __name__ = "YadiSk" __type__ = "hoster" - __version__ = "0.02" + __version__ = "0.03" __pattern__ = r'https?://yadi\.sk/d/\w+' __description__ = """Yadi.sk hoster plugin""" __license__ = "GPLv3" - __authors__ = [("GammaC0de", "nomail@fakemailbox.com")] + __authors__ = [("GammaC0de", None)] OFFLINE_PATTERN = r'Nothing found' @@ -32,7 +31,7 @@ class YadiSk(SimpleHoster): def handleFree(self, pyfile): m = re.search(r'<script id="models-client" type="application/json">(.+?)</script>', self.html) if m is None: - self.fail(_("could not find required json data")) + self.error(_("could not find required json data")) res = json_loads(m.group(1)) @@ -41,45 +40,45 @@ class YadiSk(SimpleHoster): yadisk_id = None yadisk_size = None yadisk_name = None - yadisk_hash = None - try: #@TODO: Copy to apiInfo method + + try: #@TODO: Copy to apiInfo for sect in res: if 'model' in sect: - if sect['model'] == 'config': + if sect['model'] == "config": yadisk_ver = sect['data']['version'] yadisk_sk = sect['data']['sk'] - elif sect['model'] == 'resource': + elif sect['model'] == "resource": yadisk_id = sect['data']['id'] yadisk_size = sect['data']['meta']['size'] yadisk_name = sect['data']['name'] - except Exception: - self.fail(_("Unexpected server response")) + except Exception, e: + self.fail(_("Unexpected server response"), e) - if None is in (yadisk_id, yadisk_sk, yadisk_id, yadisk_size, yadisk_name): - self.fail(_("json data is missing important information, cannot continue")) + if None in (yadisk_id, yadisk_sk, yadisk_id, yadisk_size, yadisk_name): + self.error(_("Missing JSON data")) self.pyfile.size = yadisk_size self.pyfile.name = yadisk_name yadisk_idclient = "" - for _i in range(1, 32): + for _i in range(32): yadisk_idclient += random.choice('0123456abcdef') - result_json = self.load("https://yadi.sk/models/?_m=do-get-resource-url", - post={'idClient': yadisk_idclient, - 'version' : yadisk_ver, - '_model.0': "do-get-resource-url", - 'sk' : yadisk_sk, - 'id.0' : yadisk_id}) - - res = json_loads(result_json) try: - self.link = res['models'][0]['data']['file'] + self.html = self.load("https://yadi.sk/models/", + get={'_m': "do-get-resource-url"}, + post={'idClient': yadisk_idclient, + 'version' : yadisk_ver, + '_model.0': "do-get-resource-url", + 'sk' : yadisk_sk, + 'id.0' : yadisk_id}) + + self.link = json_loads(self.html)['models'][0]['data']['file'] except Exception: - self.fail(_("faild to retrieve the download url")) + pass getInfo = create_getInfo(YadiSk) |