From c2e18511923ebda7a8a87ef9c35a9cb88c799e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= Date: Sun, 22 Feb 2015 17:53:32 +0100 Subject: [ExtractArchive] preventing duplicate files extraction --- module/plugins/hooks/ExtractArchive.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index a1e85ba57..8b84966fd 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -104,7 +104,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.30" + __version__ = "1.31" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -269,7 +269,8 @@ class ExtractArchive(Hook): matched = False success = True - files_ids = [(save_join(dl, pypack.folder, pylink['name']), pylink['id'], out) for pylink in pypack.getChildren().itervalues()] + files_ids = dict((pylink['name'],((save_join(dl, pypack.folder, pylink['name'])), pylink['id'], out)) for pylink \ + in sorted(pypack.getChildren().itervalues(), key=lambda k: k['name'])).values() # remove duplicates # check as long there are unseen files while files_ids: -- cgit v1.2.3 From 64f4b1f856f3653136f8f0ac7150491598966f67 Mon Sep 17 00:00:00 2001 From: flubshi Date: Mon, 23 Feb 2015 12:26:22 +0100 Subject: [Hook] Free-way.me: Use login data while getting host list --- module/plugins/hooks/FreeWayMe.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/FreeWayMe.py b/module/plugins/hooks/FreeWayMe.py index 6fec037d8..f819f730d 100644 --- a/module/plugins/hooks/FreeWayMe.py +++ b/module/plugins/hooks/FreeWayMe.py @@ -6,7 +6,7 @@ from module.plugins.internal.MultiHook import MultiHook class FreeWayMe(MultiHook): __name__ = "FreeWayMe" __type__ = "hook" - __version__ = "0.14" + __version__ = "0.15" __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), @@ -22,6 +22,13 @@ class FreeWayMe(MultiHook): def getHosters(self): - hostis = self.getURL("https://www.free-way.me/ajax/jd.php", get={'id': 3}).replace("\"", "").strip() - self.logDebug("Hosters", hostis) + # Get account data + if not self.account or not self.account.canUse(): + hostis = self.getURL("https://www.free-way.me/ajax/jd.php", get={"id": 3}).replace("\"", "").strip() + else: + self.logDebug("AccountInfo available - Get HosterList with User Pass") + (user, data) = self.account.selectAccount() + hostis = self.getURL("https://www.free-way.me/ajax/jd.php", get={"id": 3, "user": user, "pass": data['password']}).replace("\"", "").strip() + + self.logDebug("hosters: %s" % hostis) return [x.strip() for x in hostis.split(",") if x.strip()] -- cgit v1.2.3 From 9599ff3a6217aeb38c7d9d4c4257106c1ff79f1b Mon Sep 17 00:00:00 2001 From: sebdelsol Date: Mon, 23 Feb 2015 14:18:42 +0100 Subject: Zippyshare bug #1191 correction This version use the internal `Beatifulsoup`. When you decide to get rid of it I suggest to add a dependency to `lxml`. I've found a way to handle deliberate errors in the JS scripts without relying on PyV8: I've added JS `try/catch` statements around zippyshare scripts. --- module/plugins/hoster/ZippyshareCom.py | 49 +++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 13 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index 615559989..ad4688bac 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -5,17 +5,18 @@ import re from module.plugins.internal.CaptchaService import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.lib.BeautifulSoup import BeautifulSoup class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.73" + __version__ = "0.74" __pattern__ = r'http://www\d{0,2}\.zippyshare\.com/v(/|iew\.jsp.*key=)(?P[\w^_]+)' __description__ = """Zippyshare.com hoster plugin""" __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("Walter Purcaro", "vuolter@gmail.com", "sebdelsol")] COOKIES = [("zippyshare.com", "ziplocale", "en")] @@ -46,20 +47,42 @@ class ZippyshareCom(SimpleHoster): self.error(e) else: - self.link = '/'.join(("d", self.info['pattern']['KEY'], str(self.get_checksum()), self.pyfile.name)) + self.link = self.get_link() - - def get_checksum(self): + def get_link(self): try: - b1 = eval(re.search(r'\.omg = (.+?);', self.html).group(1)) - b2 = eval(re.search(r'\* \((.+?)\)', self.html).group(1)) - checksum = b1 * b2 + 18 + # get all the scripts inside the html body + soup = BeautifulSoup(self.html) + scripts = (s.getText() for s in soup.body.findAll('script', type='text/javascript')) + + # meant to be populated with the initialization of all the DOM elements found in the scripts + initScripts = set() + + def replElementById(element): + id, attr = element.group(1), element.group(4) # attr might be None + + varName = '%s_%s' %(id, attr) + + initValues = (elt.get(attr, None) for elt in soup.findAll(id=id)) + initValues = [v for v in initValues if v is not None] + initValue = '"%s"' %initValues[-1] if initValues else 'null' + + initScripts.add('var %s = %s;' %(varName, initValue)) + return varName + + # handle all getElementById + reVar = r'document.getElementById\([\'"](\w+)[\'"]\)(\.)?(getAttribute\([\'"])?(\w+)?([\'"]\))?' + scripts = [re.sub(reVar, replElementById, script) for script in scripts] + + # add try/catch in JS to handle deliberate errors + tryJS, catchJS = u'try{', u'} catch(err){}' # '', '' to see where the script fails + scripts = ['\n'.join((tryJS, script, catchJS)) for script in scripts if script.strip()] + + # get the file's url by evaluating all the scripts + scripts = '\n'.join(list(initScripts) + scripts + ['dlbutton_href']) + return self.js.eval(scripts) except Exception: - self.error(_("Unable to calculate checksum")) - - else: - return checksum - + self.error(_("Unable to calculate the link")) getInfo = create_getInfo(ZippyshareCom) -- cgit v1.2.3 From bc4f746e241a819bb5678125bbb96cb9a1272d82 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 24 Feb 2015 03:49:00 +0100 Subject: [RSDF] Fix https://github.com/pyload/pyload/issues/1204 --- module/plugins/container/DLC.py | 4 ++-- module/plugins/container/RSDF.py | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/container/DLC.py b/module/plugins/container/DLC.py index b01e3098c..d1c34ef50 100644 --- a/module/plugins/container/DLC.py +++ b/module/plugins/container/DLC.py @@ -49,9 +49,9 @@ class DLC(Container): except AttributeError: self.fail(_("Container is corrupted")) - cipher = AES.new(self.KEY, AES.MODE_CBC, self.IV).decrypt(rc) + key = iv = AES.new(self.KEY, AES.MODE_CBC, self.IV).decrypt(rc) - self.data = AES.new(cipher, AES.MODE_CBC, cipher).decrypt(dlc_data).decode('base64') + self.data = AES.new(key, AES.MODE_CBC, iv).decrypt(dlc_data).decode('base64') self.packages = [(entry[0] if entry[0] else pyfile.name, entry[1], entry[0] if entry[0] else pyfile.name) \ for entry in self.getPackages()] diff --git a/module/plugins/container/RSDF.py b/module/plugins/container/RSDF.py index 8f9bfc0d5..222c8d6ae 100644 --- a/module/plugins/container/RSDF.py +++ b/module/plugins/container/RSDF.py @@ -14,7 +14,7 @@ from module.utils import fs_encode class RSDF(Container): __name__ = "RSDF" __type__ = "container" - __version__ = "0.27" + __version__ = "0.28" __pattern__ = r'.+\.rsdf$' @@ -31,9 +31,10 @@ class RSDF(Container): def decrypt(self, pyfile): KEY = binascii.unhexlify(self.KEY) - IV = AES.new(Key, AES.MODE_ECB).encrypt(binascii.unhexlify(self.IV)) + IV = binascii.unhexlify(self.IV) - cipher = AES.new(KEY, AES.MODE_CFB, IV) + iv = AES.new(KEY, AES.MODE_ECB).encrypt(IV) + cipher = AES.new(KEY, AES.MODE_CFB, iv) try: file = fs_encode(pyfile.url.strip()) -- cgit v1.2.3 From 0e7a0295c60e93a7e095207176e465e82c03dc9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= Date: Tue, 24 Feb 2015 10:28:47 +0100 Subject: [ExtractArchive] fixes https://github.com/pyload/pyload/issues/1206 --- module/plugins/hooks/ExtractArchive.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 8b84966fd..dc0ee3f41 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -104,7 +104,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.31" + __version__ = "1.32" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -254,6 +254,7 @@ class ExtractArchive(Hook): pypack = self.core.files.getPackage(pid) if not pypack: + self.queue.remove(pid) continue self.logInfo(_("Check package: %s") % pypack.name) -- cgit v1.2.3 From baecc72778bac0e0076d30d0459a65abe8dc076c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 24 Feb 2015 22:08:30 +0100 Subject: [ZippyshareCom] Cleanup --- module/plugins/hoster/ZippyshareCom.py | 72 +++++++++++++++++----------------- 1 file changed, 35 insertions(+), 37 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index ad4688bac..c7a568e79 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -2,10 +2,11 @@ import re +from module.lib.BeautifulSoup import BeautifulSoup + from module.plugins.internal.CaptchaService import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.lib.BeautifulSoup import BeautifulSoup class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" @@ -16,7 +17,8 @@ class ZippyshareCom(SimpleHoster): __description__ = """Zippyshare.com hoster plugin""" __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com", "sebdelsol")] + __authors__ = [("Walter Purcaro", "vuolter@gmail.com"), + ("sebdelsol", "seb.morin@gmail.com")] COOKIES = [("zippyshare.com", "ziplocale", "en")] @@ -25,7 +27,7 @@ class ZippyshareCom(SimpleHoster): SIZE_PATTERN = r'>Size:.+?">(?P[\d.,]+) (?P[\w^_]+)' OFFLINE_PATTERN = r'>File does not exist on this server' - LINK_PREMIUM_PATTERN = r'document.location = \'(.+?)\'' + LINK_PREMIUM_PATTERN = r"document.location = '(.+?)'" def setup(self): @@ -49,40 +51,36 @@ class ZippyshareCom(SimpleHoster): else: self.link = self.get_link() + def get_link(self): - try: - # get all the scripts inside the html body - soup = BeautifulSoup(self.html) - scripts = (s.getText() for s in soup.body.findAll('script', type='text/javascript')) - - # meant to be populated with the initialization of all the DOM elements found in the scripts - initScripts = set() - - def replElementById(element): - id, attr = element.group(1), element.group(4) # attr might be None - - varName = '%s_%s' %(id, attr) - - initValues = (elt.get(attr, None) for elt in soup.findAll(id=id)) - initValues = [v for v in initValues if v is not None] - initValue = '"%s"' %initValues[-1] if initValues else 'null' - - initScripts.add('var %s = %s;' %(varName, initValue)) - return varName - - # handle all getElementById - reVar = r'document.getElementById\([\'"](\w+)[\'"]\)(\.)?(getAttribute\([\'"])?(\w+)?([\'"]\))?' - scripts = [re.sub(reVar, replElementById, script) for script in scripts] - - # add try/catch in JS to handle deliberate errors - tryJS, catchJS = u'try{', u'} catch(err){}' # '', '' to see where the script fails - scripts = ['\n'.join((tryJS, script, catchJS)) for script in scripts if script.strip()] - - # get the file's url by evaluating all the scripts - scripts = '\n'.join(list(initScripts) + scripts + ['dlbutton_href']) - return self.js.eval(scripts) - - except Exception: - self.error(_("Unable to calculate the link")) + # get all the scripts inside the html body + soup = BeautifulSoup(self.html) + scripts = (s.getText() for s in soup.body.findAll('script', type='text/javascript')) + + # meant to be populated with the initialization of all the DOM elements found in the scripts + initScripts = set() + + def replElementById(element): + id = element.group(1) + attr = element.group(4) #: attr might be None + + varName = '%s_%s' % (id, attr) + initValues = filter(None, [elt.get(attr, None) for elt in soup.findAll(id=id)]) + initValue = '"%s"' % initValues[-1] if initValues else 'null' + + initScripts.add('var %s = %s;' % (varName, initValue)) + return varName + + # handle all getElementById + reVar = r'document.getElementById\([\'"](\w+)[\'"]\)(\.)?(getAttribute\([\'"])?(\w+)?([\'"]\))?' + scripts = [re.sub(reVar, replElementById, script) for script in scripts] + + # add try/catch in JS to handle deliberate errors + scripts = ["\n".join(("try{", script, "} catch(err){}")) for script in scripts if script.strip()] + + # get the file's url by evaluating all the scripts + scripts = "\n".join(list(initScripts) + scripts + ['dlbutton_href']) + return self.js.eval(scripts) + getInfo = create_getInfo(ZippyshareCom) -- cgit v1.2.3 From de32c12bfc05b3d04df2686373e84494eefed44f Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 24 Feb 2015 22:22:15 +0100 Subject: captcha -> OCR --- module/plugins/captcha/GigasizeCom.py | 4 +- module/plugins/captcha/LinksaveIn.py | 4 +- module/plugins/captcha/NetloadIn.py | 4 +- module/plugins/captcha/OCR.py | 319 +++++++++++++++++++++++++++++++ module/plugins/captcha/ShareonlineBiz.py | 4 +- module/plugins/captcha/captcha.py | 319 ------------------------------- 6 files changed, 327 insertions(+), 327 deletions(-) create mode 100644 module/plugins/captcha/OCR.py delete mode 100644 module/plugins/captcha/captcha.py (limited to 'module/plugins') diff --git a/module/plugins/captcha/GigasizeCom.py b/module/plugins/captcha/GigasizeCom.py index 244cf6a2a..52c41729b 100644 --- a/module/plugins/captcha/GigasizeCom.py +++ b/module/plugins/captcha/GigasizeCom.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- -from module.plugins.captcha.captcha import OCR +from module.plugins.captcha.OCR import OCR class GigasizeCom(OCR): __name__ = "GigasizeCom" __type__ = "ocr" - __version__ = "0.10" + __version__ = "0.11" __description__ = """Gigasize.com ocr plugin""" __license__ = "GPLv3" diff --git a/module/plugins/captcha/LinksaveIn.py b/module/plugins/captcha/LinksaveIn.py index de6b0e7ff..b5cb0f608 100644 --- a/module/plugins/captcha/LinksaveIn.py +++ b/module/plugins/captcha/LinksaveIn.py @@ -9,13 +9,13 @@ from glob import glob from os import sep from os.path import abspath, dirname -from module.plugins.captcha.captcha import OCR +from module.plugins.captcha.OCR import OCR class LinksaveIn(OCR): __name__ = "LinksaveIn" __type__ = "ocr" - __version__ = "0.10" + __version__ = "0.11" __description__ = """Linksave.in ocr plugin""" __license__ = "GPLv3" diff --git a/module/plugins/captcha/NetloadIn.py b/module/plugins/captcha/NetloadIn.py index 28eb18fb5..1fb258c47 100644 --- a/module/plugins/captcha/NetloadIn.py +++ b/module/plugins/captcha/NetloadIn.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- -from module.plugins.captcha.captcha import OCR +from module.plugins.captcha.OCR import OCR class NetloadIn(OCR): __name__ = "NetloadIn" __type__ = "ocr" - __version__ = "0.10" + __version__ = "0.11" __description__ = """Netload.in ocr plugin""" __license__ = "GPLv3" diff --git a/module/plugins/captcha/OCR.py b/module/plugins/captcha/OCR.py new file mode 100644 index 000000000..1874ba07d --- /dev/null +++ b/module/plugins/captcha/OCR.py @@ -0,0 +1,319 @@ +# -*- coding: utf-8 -*- + +from __future__ import with_statement + +try: + from PIL import Image, GifImagePlugin, JpegImagePlugin, PngImagePlugin, TiffImagePlugin + +except ImportError: + import Image, GifImagePlugin, JpegImagePlugin, PngImagePlugin, TiffImagePlugin + +import logging +import os +import subprocess +#import tempfile + +from module.utils import save_join + + +class OCR(object): + __name__ = "OCR" + __type__ = "ocr" + __version__ = "0.11" + + __description__ = """OCR base plugin""" + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] + + + def __init__(self): + self.logger = logging.getLogger("log") + + + def load_image(self, image): + self.image = Image.open(image) + self.pixels = self.image.load() + self.result_captcha = '' + + + def unload(self): + """delete all tmp images""" + pass + + + def threshold(self, value): + self.image = self.image.point(lambda a: a * value + 10) + + + def run(self, command): + """Run a command""" + + popen = subprocess.Popen(command, bufsize = -1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + popen.wait() + output = popen.stdout.read() +" | "+ popen.stderr.read() + popen.stdout.close() + popen.stderr.close() + self.logger.debug("Tesseract ReturnCode %s Output: %s" % (popen.returncode, output)) + + + def run_tesser(self, subset=False, digits=True, lowercase=True, uppercase=True): + #tmpTif = tempfile.NamedTemporaryFile(suffix=".tif") + try: + tmpTif = open(save_join("tmp", "tmpTif_%s.tif" % self.__name__), "wb") + tmpTif.close() + + #tmpTxt = tempfile.NamedTemporaryFile(suffix=".txt") + tmpTxt = open(save_join("tmp", "tmpTxt_%s.txt" % self.__name__), "wb") + tmpTxt.close() + + except IOError, e: + self.logError(e) + return + + self.logger.debug("save tiff") + self.image.save(tmpTif.name, 'TIFF') + + if os.name == "nt": + tessparams = [os.path.join(pypath, "tesseract", "tesseract.exe")] + else: + tessparams = ["tesseract"] + + tessparams.extend( [os.path.abspath(tmpTif.name), os.path.abspath(tmpTxt.name).replace(".txt", "")] ) + + if subset and (digits or lowercase or uppercase): + #tmpSub = tempfile.NamedTemporaryFile(suffix=".subset") + with open(save_join("tmp", "tmpSub_%s.subset" % self.__name__), "wb") as tmpSub: + tmpSub.write("tessedit_char_whitelist ") + + if digits: + tmpSub.write("0123456789") + if lowercase: + tmpSub.write("abcdefghijklmnopqrstuvwxyz") + if uppercase: + tmpSub.write("ABCDEFGHIJKLMNOPQRSTUVWXYZ") + + tmpSub.write("\n") + tessparams.append("nobatch") + tessparams.append(os.path.abspath(tmpSub.name)) + + self.logger.debug("run tesseract") + self.run(tessparams) + self.logger.debug("read txt") + + try: + with open(tmpTxt.name, 'r') as f: + self.result_captcha = f.read().replace("\n", "") + except Exception: + self.result_captcha = "" + + self.logger.debug(self.result_captcha) + try: + os.remove(tmpTif.name) + os.remove(tmpTxt.name) + if subset and (digits or lowercase or uppercase): + os.remove(tmpSub.name) + except Exception: + pass + + + def get_captcha(self, name): + raise NotImplementedError + + + def to_greyscale(self): + if self.image.mode != 'L': + self.image = self.image.convert('L') + + self.pixels = self.image.load() + + + def eval_black_white(self, limit): + self.pixels = self.image.load() + w, h = self.image.size + for x in xrange(w): + for y in xrange(h): + if self.pixels[x, y] > limit: + self.pixels[x, y] = 255 + else: + self.pixels[x, y] = 0 + + + def clean(self, allowed): + pixels = self.pixels + + w, h = self.image.size + + for x in xrange(w): + for y in xrange(h): + if pixels[x, y] == 255: + continue + # No point in processing white pixels since we only want to remove black pixel + count = 0 + + try: + if pixels[x-1, y-1] != 255: + count += 1 + if pixels[x-1, y] != 255: + count += 1 + if pixels[x-1, y + 1] != 255: + count += 1 + if pixels[x, y + 1] != 255: + count += 1 + if pixels[x + 1, y + 1] != 255: + count += 1 + if pixels[x + 1, y] != 255: + count += 1 + if pixels[x + 1, y-1] != 255: + count += 1 + if pixels[x, y-1] != 255: + count += 1 + except Exception: + pass + + # not enough neighbors are dark pixels so mark this pixel + # to be changed to white + if count < allowed: + pixels[x, y] = 1 + + # second pass: this time set all 1's to 255 (white) + for x in xrange(w): + for y in xrange(h): + if pixels[x, y] == 1: + pixels[x, y] = 255 + + self.pixels = pixels + + + def derotate_by_average(self): + """rotate by checking each angle and guess most suitable""" + + w, h = self.image.size + pixels = self.pixels + + for x in xrange(w): + for y in xrange(h): + if pixels[x, y] == 0: + pixels[x, y] = 155 + + highest = {} + counts = {} + + for angle in xrange(-45, 45): + + tmpimage = self.image.rotate(angle) + + pixels = tmpimage.load() + + w, h = self.image.size + + for x in xrange(w): + for y in xrange(h): + if pixels[x, y] == 0: + pixels[x, y] = 255 + + + count = {} + + for x in xrange(w): + count[x] = 0 + for y in xrange(h): + if pixels[x, y] == 155: + count[x] += 1 + + sum = 0 + cnt = 0 + + for x in count.values(): + if x != 0: + sum += x + cnt += 1 + + avg = sum / cnt + counts[angle] = cnt + highest[angle] = 0 + for x in count.values(): + if x > highest[angle]: + highest[angle] = x + + highest[angle] = highest[angle] - avg + + hkey = 0 + hvalue = 0 + + for key, value in highest.iteritems(): + if value > hvalue: + hkey = key + hvalue = value + + self.image = self.image.rotate(hkey) + pixels = self.image.load() + + for x in xrange(w): + for y in xrange(h): + if pixels[x, y] == 0: + pixels[x, y] = 255 + + if pixels[x, y] == 155: + pixels[x, y] = 0 + + self.pixels = pixels + + + def split_captcha_letters(self): + captcha = self.image + started = False + letters = [] + width, height = captcha.size + bottomY, topY = 0, height + pixels = captcha.load() + + for x in xrange(width): + black_pixel_in_col = False + for y in xrange(height): + if pixels[x, y] != 255: + if not started: + started = True + firstX = x + lastX = x + + if y > bottomY: + bottomY = y + if y < topY: + topY = y + if x > lastX: + lastX = x + + black_pixel_in_col = True + + if black_pixel_in_col is False and started is True: + rect = (firstX, topY, lastX, bottomY) + new_captcha = captcha.crop(rect) + + w, h = new_captcha.size + if w > 5 and h > 5: + letters.append(new_captcha) + + started = False + bottomY, topY = 0, height + + return letters + + + def correct(self, values, var=None): + if var: + result = var + else: + result = self.result_captcha + + for key, item in values.iteritems(): + + if key.__class__ == str: + result = result.replace(key, item) + else: + for expr in key: + result = result.replace(expr, item) + + if var: + return result + else: + self.result_captcha = result diff --git a/module/plugins/captcha/ShareonlineBiz.py b/module/plugins/captcha/ShareonlineBiz.py index 8210e8859..6fad66600 100644 --- a/module/plugins/captcha/ShareonlineBiz.py +++ b/module/plugins/captcha/ShareonlineBiz.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- -from module.plugins.captcha.captcha import OCR +from module.plugins.captcha.OCR import OCR class ShareonlineBiz(OCR): __name__ = "ShareonlineBiz" __type__ = "ocr" - __version__ = "0.10" + __version__ = "0.11" __description__ = """Shareonline.biz ocr plugin""" __license__ = "GPLv3" diff --git a/module/plugins/captcha/captcha.py b/module/plugins/captcha/captcha.py deleted file mode 100644 index 1874ba07d..000000000 --- a/module/plugins/captcha/captcha.py +++ /dev/null @@ -1,319 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import with_statement - -try: - from PIL import Image, GifImagePlugin, JpegImagePlugin, PngImagePlugin, TiffImagePlugin - -except ImportError: - import Image, GifImagePlugin, JpegImagePlugin, PngImagePlugin, TiffImagePlugin - -import logging -import os -import subprocess -#import tempfile - -from module.utils import save_join - - -class OCR(object): - __name__ = "OCR" - __type__ = "ocr" - __version__ = "0.11" - - __description__ = """OCR base plugin""" - __license__ = "GPLv3" - __authors__ = [("pyLoad Team", "admin@pyload.org")] - - - def __init__(self): - self.logger = logging.getLogger("log") - - - def load_image(self, image): - self.image = Image.open(image) - self.pixels = self.image.load() - self.result_captcha = '' - - - def unload(self): - """delete all tmp images""" - pass - - - def threshold(self, value): - self.image = self.image.point(lambda a: a * value + 10) - - - def run(self, command): - """Run a command""" - - popen = subprocess.Popen(command, bufsize = -1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - popen.wait() - output = popen.stdout.read() +" | "+ popen.stderr.read() - popen.stdout.close() - popen.stderr.close() - self.logger.debug("Tesseract ReturnCode %s Output: %s" % (popen.returncode, output)) - - - def run_tesser(self, subset=False, digits=True, lowercase=True, uppercase=True): - #tmpTif = tempfile.NamedTemporaryFile(suffix=".tif") - try: - tmpTif = open(save_join("tmp", "tmpTif_%s.tif" % self.__name__), "wb") - tmpTif.close() - - #tmpTxt = tempfile.NamedTemporaryFile(suffix=".txt") - tmpTxt = open(save_join("tmp", "tmpTxt_%s.txt" % self.__name__), "wb") - tmpTxt.close() - - except IOError, e: - self.logError(e) - return - - self.logger.debug("save tiff") - self.image.save(tmpTif.name, 'TIFF') - - if os.name == "nt": - tessparams = [os.path.join(pypath, "tesseract", "tesseract.exe")] - else: - tessparams = ["tesseract"] - - tessparams.extend( [os.path.abspath(tmpTif.name), os.path.abspath(tmpTxt.name).replace(".txt", "")] ) - - if subset and (digits or lowercase or uppercase): - #tmpSub = tempfile.NamedTemporaryFile(suffix=".subset") - with open(save_join("tmp", "tmpSub_%s.subset" % self.__name__), "wb") as tmpSub: - tmpSub.write("tessedit_char_whitelist ") - - if digits: - tmpSub.write("0123456789") - if lowercase: - tmpSub.write("abcdefghijklmnopqrstuvwxyz") - if uppercase: - tmpSub.write("ABCDEFGHIJKLMNOPQRSTUVWXYZ") - - tmpSub.write("\n") - tessparams.append("nobatch") - tessparams.append(os.path.abspath(tmpSub.name)) - - self.logger.debug("run tesseract") - self.run(tessparams) - self.logger.debug("read txt") - - try: - with open(tmpTxt.name, 'r') as f: - self.result_captcha = f.read().replace("\n", "") - except Exception: - self.result_captcha = "" - - self.logger.debug(self.result_captcha) - try: - os.remove(tmpTif.name) - os.remove(tmpTxt.name) - if subset and (digits or lowercase or uppercase): - os.remove(tmpSub.name) - except Exception: - pass - - - def get_captcha(self, name): - raise NotImplementedError - - - def to_greyscale(self): - if self.image.mode != 'L': - self.image = self.image.convert('L') - - self.pixels = self.image.load() - - - def eval_black_white(self, limit): - self.pixels = self.image.load() - w, h = self.image.size - for x in xrange(w): - for y in xrange(h): - if self.pixels[x, y] > limit: - self.pixels[x, y] = 255 - else: - self.pixels[x, y] = 0 - - - def clean(self, allowed): - pixels = self.pixels - - w, h = self.image.size - - for x in xrange(w): - for y in xrange(h): - if pixels[x, y] == 255: - continue - # No point in processing white pixels since we only want to remove black pixel - count = 0 - - try: - if pixels[x-1, y-1] != 255: - count += 1 - if pixels[x-1, y] != 255: - count += 1 - if pixels[x-1, y + 1] != 255: - count += 1 - if pixels[x, y + 1] != 255: - count += 1 - if pixels[x + 1, y + 1] != 255: - count += 1 - if pixels[x + 1, y] != 255: - count += 1 - if pixels[x + 1, y-1] != 255: - count += 1 - if pixels[x, y-1] != 255: - count += 1 - except Exception: - pass - - # not enough neighbors are dark pixels so mark this pixel - # to be changed to white - if count < allowed: - pixels[x, y] = 1 - - # second pass: this time set all 1's to 255 (white) - for x in xrange(w): - for y in xrange(h): - if pixels[x, y] == 1: - pixels[x, y] = 255 - - self.pixels = pixels - - - def derotate_by_average(self): - """rotate by checking each angle and guess most suitable""" - - w, h = self.image.size - pixels = self.pixels - - for x in xrange(w): - for y in xrange(h): - if pixels[x, y] == 0: - pixels[x, y] = 155 - - highest = {} - counts = {} - - for angle in xrange(-45, 45): - - tmpimage = self.image.rotate(angle) - - pixels = tmpimage.load() - - w, h = self.image.size - - for x in xrange(w): - for y in xrange(h): - if pixels[x, y] == 0: - pixels[x, y] = 255 - - - count = {} - - for x in xrange(w): - count[x] = 0 - for y in xrange(h): - if pixels[x, y] == 155: - count[x] += 1 - - sum = 0 - cnt = 0 - - for x in count.values(): - if x != 0: - sum += x - cnt += 1 - - avg = sum / cnt - counts[angle] = cnt - highest[angle] = 0 - for x in count.values(): - if x > highest[angle]: - highest[angle] = x - - highest[angle] = highest[angle] - avg - - hkey = 0 - hvalue = 0 - - for key, value in highest.iteritems(): - if value > hvalue: - hkey = key - hvalue = value - - self.image = self.image.rotate(hkey) - pixels = self.image.load() - - for x in xrange(w): - for y in xrange(h): - if pixels[x, y] == 0: - pixels[x, y] = 255 - - if pixels[x, y] == 155: - pixels[x, y] = 0 - - self.pixels = pixels - - - def split_captcha_letters(self): - captcha = self.image - started = False - letters = [] - width, height = captcha.size - bottomY, topY = 0, height - pixels = captcha.load() - - for x in xrange(width): - black_pixel_in_col = False - for y in xrange(height): - if pixels[x, y] != 255: - if not started: - started = True - firstX = x - lastX = x - - if y > bottomY: - bottomY = y - if y < topY: - topY = y - if x > lastX: - lastX = x - - black_pixel_in_col = True - - if black_pixel_in_col is False and started is True: - rect = (firstX, topY, lastX, bottomY) - new_captcha = captcha.crop(rect) - - w, h = new_captcha.size - if w > 5 and h > 5: - letters.append(new_captcha) - - started = False - bottomY, topY = 0, height - - return letters - - - def correct(self, values, var=None): - if var: - result = var - else: - result = self.result_captcha - - for key, item in values.iteritems(): - - if key.__class__ == str: - result = result.replace(key, item) - else: - for expr in key: - result = result.replace(expr, item) - - if var: - return result - else: - self.result_captcha = result -- cgit v1.2.3 From 4195dff3ebe911c6532d0afd130085cc566e11cc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 24 Feb 2015 23:23:21 +0100 Subject: [RSDF] Check if broken --- module/plugins/container/RSDF.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/container/RSDF.py b/module/plugins/container/RSDF.py index 222c8d6ae..60e15e2b5 100644 --- a/module/plugins/container/RSDF.py +++ b/module/plugins/container/RSDF.py @@ -14,7 +14,7 @@ from module.utils import fs_encode class RSDF(Container): __name__ = "RSDF" __type__ = "container" - __version__ = "0.28" + __version__ = "0.29" __pattern__ = r'.+\.rsdf$' @@ -47,7 +47,12 @@ class RSDF(Container): if re.search(r"404 - Not Found", data): return - for link in binascii.unhexlify(''.join(data.split())).splitlines(): - if link: + try: + for link in binascii.unhexlify(''.join(data.split())).splitlines(): + if not link: + continue link = cipher.decrypt(link.decode('base64')).replace('CCF: ', '') self.urls.append(link) + + except TypeError: + self.fail(_("Container is corrupted")) -- cgit v1.2.3 From ed9bbe7332d8f6e2bf33b09ae5382a4925d2eac3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 24 Feb 2015 23:57:38 +0100 Subject: [ExternalScripts] Code cosmetics --- module/plugins/hooks/ExternalScripts.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 8bd803308..3b9c9ca05 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -3,8 +3,6 @@ import os import subprocess -from itertools import chain - from module.plugins.Hook import Hook from module.utils import save_join @@ -142,10 +140,10 @@ class ExternalScripts(Hook): def allDownloadsFinished(self): - for script in chain(self.scripts['all_downloads_finished'], self.scripts['all_dls_finished']): + for script in self.scripts['all_downloads_finished'] + self.scripts['all_dls_finished']): self.callScript(script) def allDownloadsProcessed(self): - for script in chain(self.scripts['all_downloads_processed'], self.scripts['all_dls_processed']): + for script in self.scripts['all_downloads_processed'] + self.scripts['all_dls_processed']: self.callScript(script) -- cgit v1.2.3 From 808d8036fc8cc13c4b26240818bd86ac82567e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= Date: Wed, 25 Feb 2015 20:25:20 +0100 Subject: [ExternalScripts] Code cosmetics - cosmetics --- module/plugins/hooks/ExternalScripts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 3b9c9ca05..f49220c2a 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -140,7 +140,7 @@ class ExternalScripts(Hook): def allDownloadsFinished(self): - for script in self.scripts['all_downloads_finished'] + self.scripts['all_dls_finished']): + for script in self.scripts['all_downloads_finished'] + self.scripts['all_dls_finished']: self.callScript(script) -- cgit v1.2.3 From dbeb21da8cb2eca52bcfcf8e8686947f41f71683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= Date: Wed, 25 Feb 2015 20:55:13 +0100 Subject: * [ExtractArchive] fixes 'Could not activate UnRar' --- module/plugins/internal/SevenZip.py | 5 +++-- module/plugins/internal/UnRar.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index bfa7f3943..8a3c67f0e 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -11,7 +11,7 @@ from module.utils import fs_encode, save_join class SevenZip(UnRar): __name__ = "SevenZip" - __version__ = "0.09" + __version__ = "0.10" __description__ = """7-Zip extractor plugin""" __license__ = "GPLv3" @@ -47,7 +47,8 @@ class SevenZip(UnRar): p = Popen([cls.CMD], stdout=PIPE, stderr=PIPE) out, err = p.communicate() - cls.VERSION = cls.re_version.search(out).group(1) + m = cls.re_version.search(out) + cls.VERSION = m.group(1) if m else '(version unknown)' return True diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index ca8fdd326..7a02ba6bd 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -22,7 +22,7 @@ def renice(pid, value): class UnRar(Extractor): __name__ = "UnRar" - __version__ = "1.14" + __version__ = "1.15" __description__ = """Rar extractor plugin""" __license__ = "GPLv3" @@ -70,7 +70,8 @@ class UnRar(Extractor): p = Popen([cls.CMD], stdout=PIPE, stderr=PIPE) out, err = p.communicate() - cls.VERSION = cls.re_version.search(out).group(1) + m = cls.re_version.search(out) + cls.VERSION = m.group(1) if m else '(version unknown)' return True -- cgit v1.2.3 From c039d5822c4c53661813b6fd8e2252a3b633532e Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 27 Feb 2015 04:39:45 +0100 Subject: [container] Code cosmetics --- module/plugins/container/CCF.py | 6 +++--- module/plugins/container/DLC.py | 8 ++++---- module/plugins/container/RSDF.py | 19 +++++++++++-------- module/plugins/container/TXT.py | 10 +++++----- 4 files changed, 23 insertions(+), 20 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/container/CCF.py b/module/plugins/container/CCF.py index 452b9bb65..79d7879a7 100644 --- a/module/plugins/container/CCF.py +++ b/module/plugins/container/CCF.py @@ -26,13 +26,13 @@ class CCF(Container): def decrypt(self, pyfile): - file = fs_encode(pyfile.url.strip()) - opener = build_opener(MultipartPostHandler) + fs_filename = fs_encode(pyfile.url.strip()) + opener = build_opener(MultipartPostHandler) dlc_content = opener.open('http://service.jdownloader.net/dlcrypt/getDLC.php', {'src' : "ccf", 'filename': "test.ccf", - 'upload' : open(file, "rb")}).read() + 'upload' : open(fs_filename, "rb")}).read() download_folder = self.config['general']['download_folder'] dlc_file = save_join(download_folder, "tmp_%s.dlc" % pyfile.name) diff --git a/module/plugins/container/DLC.py b/module/plugins/container/DLC.py index d1c34ef50..ff2f0104a 100644 --- a/module/plugins/container/DLC.py +++ b/module/plugins/container/DLC.py @@ -33,8 +33,8 @@ class DLC(Container): def decrypt(self, pyfile): - file = fs_encode(pyfile.url.strip()) - with open(file) as dlc: + fs_filename = fs_encode(pyfile.url.strip()) + with open(fs_filename) as dlc: data = dlc.read().strip() data += '=' * (-len(data) % 4) @@ -52,8 +52,8 @@ class DLC(Container): key = iv = AES.new(self.KEY, AES.MODE_CBC, self.IV).decrypt(rc) self.data = AES.new(key, AES.MODE_CBC, iv).decrypt(dlc_data).decode('base64') - self.packages = [(entry[0] if entry[0] else pyfile.name, entry[1], entry[0] if entry[0] else pyfile.name) \ - for entry in self.getPackages()] + self.packages = [(name or pyfile.name, links, name or pyfile.name) \ + for name, links in self.getPackages()] def getPackages(self): diff --git a/module/plugins/container/RSDF.py b/module/plugins/container/RSDF.py index 60e15e2b5..dd2d14cf7 100644 --- a/module/plugins/container/RSDF.py +++ b/module/plugins/container/RSDF.py @@ -37,22 +37,25 @@ class RSDF(Container): cipher = AES.new(KEY, AES.MODE_CFB, iv) try: - file = fs_encode(pyfile.url.strip()) - with open(file, 'r') as rsdf: + fs_filename = fs_encode(pyfile.url.strip()) + with open(fs_filename, 'r') as rsdf: data = rsdf.read() except IOError, e: self.fail(e) if re.search(r"404 - Not Found", data): - return + pyfile.setStatus("offline") - try: - for link in binascii.unhexlify(''.join(data.split())).splitlines(): + else: + try: + raw_links = binascii.unhexlify(''.join(data.split())).splitlines() + + except TypeError: + self.fail(_("Container is corrupted")) + + for link in raw_links: if not link: continue link = cipher.decrypt(link.decode('base64')).replace('CCF: ', '') self.urls.append(link) - - except TypeError: - self.fail(_("Container is corrupted")) diff --git a/module/plugins/container/TXT.py b/module/plugins/container/TXT.py index 585da8ac6..98ca426d7 100644 --- a/module/plugins/container/TXT.py +++ b/module/plugins/container/TXT.py @@ -28,10 +28,10 @@ class TXT(Container): except Exception: encoding = "utf-8" - file = fs_encode(pyfile.url.strip()) - txt = codecs.open(file, 'r', encoding) - curPack = "Parsed links from %s" % pyfile.name - packages = {curPack:[],} + fs_filename = fs_encode(pyfile.url.strip()) + txt = codecs.open(fs_filename, 'r', encoding) + curPack = "Parsed links from %s" % pyfile.name + packages = {curPack:[],} for link in txt.readlines(): link = link.strip() @@ -59,7 +59,7 @@ class TXT(Container): if self.getConfig("flush"): try: - txt = open(file, 'wb') + txt = open(fs_filename, 'wb') txt.close() except IOError: -- cgit v1.2.3 From ddd43db82de4f6a431740c321e93a13c2e6d754d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 28 Feb 2015 18:30:33 +0100 Subject: [NowDownloadSx][NowVideoSx] Improve __pattern__ --- module/plugins/hoster/NowDownloadSx.py | 4 ++-- module/plugins/hoster/NowVideoSx.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hoster/NowDownloadSx.py b/module/plugins/hoster/NowDownloadSx.py index b69242a86..f110e69ed 100644 --- a/module/plugins/hoster/NowDownloadSx.py +++ b/module/plugins/hoster/NowDownloadSx.py @@ -9,9 +9,9 @@ from module.utils import fixup class NowDownloadSx(SimpleHoster): __name__ = "NowDownloadSx" __type__ = "hoster" - __version__ = "0.07" + __version__ = "0.08" - __pattern__ = r'http://(?:www\.)?(nowdownload\.(at|ch|co|eu|sx)/(dl/|download\.php\?id=)|likeupload\.org/)\w+' + __pattern__ = r'http://(?:www\.)?(nowdownload\.[a-zA-Z]{2,}/(dl/|download\.php\?id=)|likeupload\.org/)\w+' __description__ = """NowDownload.sx hoster plugin""" __license__ = "GPLv3" diff --git a/module/plugins/hoster/NowVideoSx.py b/module/plugins/hoster/NowVideoSx.py index 3f75a33f7..ff6fd43f8 100644 --- a/module/plugins/hoster/NowVideoSx.py +++ b/module/plugins/hoster/NowVideoSx.py @@ -8,9 +8,9 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class NowVideoSx(SimpleHoster): __name__ = "NowVideoSx" __type__ = "hoster" - __version__ = "0.10" + __version__ = "0.11" - __pattern__ = r'http://(?:www\.)?nowvideo\.(at|ch|co|eu|li|sx)/(video|mobile/#/videos)/(?P\w+)' + __pattern__ = r'http://(?:www\.)?nowvideo\.[a-zA-Z]{2,}/(video|mobile/#/videos)/(?P\w+)' __description__ = """NowVideo.sx hoster plugin""" __license__ = "GPLv3" -- cgit v1.2.3 From 93eb54614d512396a5505cb9bdea4e201920b434 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 1 Mar 2015 00:33:21 +0100 Subject: Spare code cosmetics --- module/plugins/hooks/ClickAndLoad.py | 2 +- module/plugins/hooks/ExtractArchive.py | 12 ++++++------ module/plugins/hooks/FreeWayMe.py | 2 +- module/plugins/hooks/JustPremium.py | 2 +- module/plugins/internal/CaptchaService.py | 6 +++++- module/plugins/internal/Extractor.py | 4 ++-- module/plugins/internal/SevenZip.py | 2 +- module/plugins/internal/UnRar.py | 2 +- 8 files changed, 18 insertions(+), 14 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 6691bb1fe..5b21aec96 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -53,7 +53,7 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): - self.logInfo(_("Proxy listening on %s:%s") % (ip, cnlport)) + self.logInfo(_("Proxy listening on %s:%s") % (ip or "0.0.0.0", cnlport)) self.manager.startThread(self._server, ip, webport, cnlport) lock = Lock() lock.acquire() diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index dc0ee3f41..c9e43eaaf 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -327,10 +327,10 @@ class ExtractArchive(Hook): if recursive and os.path.isfile(file): new_files_ids.append((filename, fid, os.path.dirname(filename))) # append as new target - + pyfile = self.core.files.getFile(fid) self.manager.dispatchEvent("archive_extracted", pyfile, archive.out, archive.filename, new_files) - + files_ids = new_files_ids # also check extracted files if matched: @@ -381,7 +381,7 @@ class ExtractArchive(Hook): pyfile.setProgress(100) else: archive.check(pw) - + self.addPassword(pw) break @@ -389,7 +389,7 @@ class ExtractArchive(Hook): if not encrypted: self.logInfo(name, _("Password protected")) encrypted = True - + except CRCError, e: self.logDebug(name, e) self.logInfo(name, _("CRC Error")) @@ -407,9 +407,9 @@ class ExtractArchive(Hook): self.addPassword(pw) break - + raise CRCError("Archive damaged") - + except ArchiveError, e: raise ArchiveError(e) diff --git a/module/plugins/hooks/FreeWayMe.py b/module/plugins/hooks/FreeWayMe.py index f819f730d..4e79783bb 100644 --- a/module/plugins/hooks/FreeWayMe.py +++ b/module/plugins/hooks/FreeWayMe.py @@ -29,6 +29,6 @@ class FreeWayMe(MultiHook): self.logDebug("AccountInfo available - Get HosterList with User Pass") (user, data) = self.account.selectAccount() hostis = self.getURL("https://www.free-way.me/ajax/jd.php", get={"id": 3, "user": user, "pass": data['password']}).replace("\"", "").strip() - + self.logDebug("hosters: %s" % hostis) return [x.strip() for x in hostis.split(",") if x.strip()] diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index b70d8dd2c..30a72c70f 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -12,7 +12,7 @@ class JustPremium(Hook): __config__ = [("excluded", "str", "Exclude hosters (comma separated)", "")] - __description__ = """Remove all not premium links from urls added""" + __description__ = """Remove not-premium links from added urls""" __license__ = "GPLv3" __authors__ = [("mazleu", "mazleica@gmail.com"), ("Walter Purcaro", "vuolter@gmail.com"), diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 6f2c8e06d..fcb8f0095 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -14,6 +14,7 @@ from module.plugins.Plugin import Base #@TODO: Extend (new) Plugin class; remove all `html` args class CaptchaService(Base): __name__ = "CaptchaService" + __type__ = "captcha" __version__ = "0.25" __description__ = """Base captcha service plugin""" @@ -43,6 +44,7 @@ class CaptchaService(Base): class ReCaptcha(CaptchaService): __name__ = "ReCaptcha" + __type__ = "captcha" __version__ = "0.14" __description__ = """ReCaptcha captcha service plugin""" @@ -239,9 +241,9 @@ class ReCaptcha(CaptchaService): return result, None - class AdsCaptcha(CaptchaService): __name__ = "AdsCaptcha" + __type__ = "captcha" __version__ = "0.08" __description__ = """AdsCaptcha captcha service plugin""" @@ -314,6 +316,7 @@ class AdsCaptcha(CaptchaService): class SolveMedia(CaptchaService): __name__ = "SolveMedia" + __type__ = "captcha" __version__ = "0.12" __description__ = """SolveMedia captcha service plugin""" @@ -422,6 +425,7 @@ class SolveMedia(CaptchaService): class AdYouLike(CaptchaService): __name__ = "AdYouLike" + __type__ = "captcha" __version__ = "0.05" __description__ = """AdYouLike captcha service plugin""" diff --git a/module/plugins/internal/Extractor.py b/module/plugins/internal/Extractor.py index 8bf1875cf..ee62ebcb7 100644 --- a/module/plugins/internal/Extractor.py +++ b/module/plugins/internal/Extractor.py @@ -99,11 +99,11 @@ class Extractor: :raises ArchiveError """ raise NotImplementedError - + def test(self): """Testing with Extractors buildt-in method Raises error if password is needed, integrity is questionable or else. - + :raises PasswordError :raises CRCError :raises ArchiveError diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index 8a3c67f0e..a3df52559 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -46,7 +46,7 @@ class SevenZip(UnRar): else: p = Popen([cls.CMD], stdout=PIPE, stderr=PIPE) out, err = p.communicate() - + m = cls.re_version.search(out) cls.VERSION = m.group(1) if m else '(version unknown)' diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index 7a02ba6bd..eb969bb60 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -90,7 +90,7 @@ class UnRar(Extractor): p = self.call_cmd("t", "-v", fs_encode(self.filename), password=password) self._progress(p) err = p.stderr.read().strip() - + if self.re_wrongpwd.search(err): raise PasswordError -- cgit v1.2.3 From 5eb1729ab45fcdb4862f2b4e54bdb79d7f59a6a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20H=C3=B6rnlein?= Date: Sun, 1 Mar 2015 14:14:32 +0100 Subject: [JustPremium] Include hoster to remove --- module/plugins/hooks/JustPremium.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index 30a72c70f..daefbc30f 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -8,9 +8,10 @@ from module.plugins.Hook import Hook class JustPremium(Hook): __name__ = "JustPremium" __type__ = "hook" - __version__ = "0.21" + __version__ = "0.22" - __config__ = [("excluded", "str", "Exclude hosters (comma separated)", "")] + __config__ = [("excluded", "str", "Exclude hosters (comma separated)", ""), + ("included", "str", "Include hosters (comma separated)", "")] __description__ = """Remove not-premium links from added urls""" __license__ = "GPLv3" @@ -32,14 +33,18 @@ class JustPremium(Hook): if 'new_name' in hosterdict[hoster] \ and hosterdict[hoster]['new_name'] in premiumplugins) - #: Found at least one hoster with account or multihoster - if not any(True for pluginname in linkdict if pluginname in premiumplugins | multihosters): - return - excluded = map(lambda domain: "".join(part.capitalize() for part in re.split(r'(\.|\d+)', domain) if part != '.'), self.getConfig('excluded').replace(' ', '').replace(',', '|').replace(';', '|').split('|')) + included = map(lambda domain: "".join(part.capitalize() for part in re.split(r'(\.|\d+)', domain) if part != '.'), + self.getConfig('included').replace(' ', '').replace(',', '|').replace(';', '|').split('|')) + + hosterlist = (premiumplugins | multihosters).union(excluded).difference(included) + + #: Found at least one hoster with account or multihoster + if not any( True for pluginname in linkdict if pluginname in hosterlist ): + return - for pluginname in set(linkdict.keys()) - (premiumplugins | multihosters).union(excluded): + for pluginname in set(linkdict.keys()) - hosterlist: self.logInfo(_("Remove links of plugin: %s") % pluginname) for link in linkdict[pluginname]: self.logDebug("Remove link: %s" % link) -- cgit v1.2.3 From 6c6ff624f7445ad8fb92c5947ad23248d62058c6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 1 Mar 2015 21:56:38 +0100 Subject: [UpdateManager] Fix https://github.com/pyload/pyload/issues/1089 --- module/plugins/hooks/UpdateManager.py | 76 +++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 31 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index b6a8bac7c..a0b044edb 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -2,21 +2,33 @@ from __future__ import with_statement +import os import re import sys from operator import itemgetter -from os import path, remove, stat from module.network.RequestFactory import getURL from module.plugins.Hook import Expose, Hook, threaded from module.utils import save_join +# Case-sensitive os.path.exists +def exists(path): + if os.path.exists(path): + if os.name == 'nt': + dir, name = os.path.split(path) + return name in os.listdir(dir) + else: + return True + else: + return False + + class UpdateManager(Hook): __name__ = "UpdateManager" __type__ = "hook" - __version__ = "0.43" + __version__ = "0.44" __config__ = [("activated" , "bool" , "Activated" , True ), ("mode" , "pyLoad + plugins;plugins only", "Check updates for" , "pyLoad + plugins"), @@ -95,10 +107,10 @@ class UpdateManager(Hook): id = (type, name) if type in self.core.pluginManager.plugins: f = m.__file__.replace(".pyc", ".py") - if not path.isfile(f): + if not os.path.isfile(f): continue - mtime = stat(f).st_mtime + mtime = os.stat(f).st_mtime if id not in self.mtimes: self.mtimes[id] = mtime @@ -114,9 +126,10 @@ class UpdateManager(Hook): self.updateThread() - def server_request(self): + def server_response(self): try: return getURL(self.SERVER_URL, get={'v': self.core.api.getServerVersion()}).splitlines() + except Exception: self.logWarning(_("Unable to contact server to get updates")) @@ -142,7 +155,7 @@ class UpdateManager(Hook): @Expose def update(self, onlyplugin=False): """ check for updates """ - data = self.server_request() + data = self.server_response() if not data: exitcode = 0 @@ -202,7 +215,7 @@ class UpdateManager(Hook): break for t, n in self.removePlugins(sorted(blacklisted)): - self.logInfo(_("Removed blacklisted plugin [%(type)s] %(name)s") % { + self.logInfo(_("Removed blacklisted plugin: [%(type)s] %(name)s") % { 'type': t, 'name': n, }) @@ -217,7 +230,7 @@ class UpdateManager(Hook): else: name = filename.replace(".py", "") - #@TODO: obsolete after 0.4.10 + #@TODO: Remove in 0.4.10 if prefix.endswith("s"): type = prefix[:-1] else: @@ -276,35 +289,36 @@ class UpdateManager(Hook): if not type_plugins: return - self.logDebug("Requested deletion of plugins: %s" % type_plugins) + removed = set() - removed = [] + self.logDebug("Requested deletion of plugins: %s" % type_plugins) for type, name in type_plugins: - err = False - file = name + ".py" + rootplugins = os.path.join(pypath, "module", "plugins") - for root in ("userplugins", path.join(pypath, "module", "plugins")): + for dir in ("userplugins", rootplugins): + py_filename = save_join(dir, type, name + ".py") + pyc_filename = py_filename + "c" - filename = save_join(root, type, file) - try: - remove(filename) - except Exception, e: - self.logDebug("Error removing: %s" % path.basename(filename), str(e)) - err = True - - filename += "c" - if path.isfile(filename): + if type == "hook": try: - if type == "hook": - self.manager.deactivateHook(name) - remove(filename) + self.manager.deactivateHook(name) + except Exception, e: - self.logDebug("Error removing: %s" % path.basename(filename), str(e)) - err = True + self.logDebug(e) + + for filename in (py_filename, pyc_filename): + if not exists(filename): + continue + + try: + os.remove(filename) + + except IOError, e: + self.logError(_("Error removing: %s") % filename, e) - if not err: - id = (type, name) - removed.append(id) + else: + id = (type, name) + removed.add(id) - return removed #: return a list of the plugins successfully removed + return list(removed) #: return a list of the plugins successfully removed -- cgit v1.2.3 From 3a9c167ceca27d57dbef927626fe853a3d0e30b2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 1 Mar 2015 22:41:08 +0100 Subject: [Extractor] Use self.target --- module/plugins/hooks/ExtractArchive.py | 37 +++++++++++++++++++--------------- module/plugins/internal/Extractor.py | 2 ++ module/plugins/internal/SevenZip.py | 14 +++++-------- module/plugins/internal/UnRar.py | 18 +++++++++-------- module/plugins/internal/UnZip.py | 7 +++---- 5 files changed, 41 insertions(+), 37 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index c9e43eaaf..6a25602e8 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -33,6 +33,7 @@ if sys.version_info < (2, 7) and os.name != "nt": if self.returncode is None: try: pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0) + except OSError, e: if e.errno != errno.ECHILD: raise @@ -93,10 +94,13 @@ class ArchiveQueue(object): queue = self.get() try: queue.remove(item) + except ValueError: pass + if queue == []: return self.delete() + return self.set(queue) @@ -106,22 +110,22 @@ class ExtractArchive(Hook): __type__ = "hook" __version__ = "1.32" - __config__ = [("activated" , "bool" , "Activated" , True ), - ("fullpath" , "bool" , "Extract with full paths" , True ), - ("overwrite" , "bool" , "Overwrite files" , False ), - ("keepbroken" , "bool" , "Try to extract broken archives" , False ), - ("repair" , "bool" , "Repair broken archives (rar required)" , False ), - ("test" , "bool" , "Test archive before extracting" , False ), - ("usepasswordfile" , "bool" , "Use password file" , True ), - ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), - ("delete" , "bool" , "Delete archive when successfully extracted", False ), - ("subfolder" , "bool" , "Create subfolder for each package" , False ), - ("destination" , "folder", "Extract files to folder" , "" ), - ("extensions" , "str" , "Extract the following extensions" , "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), - ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), - ("recursive" , "bool" , "Extract archives in archives" , True ), - ("waitall" , "bool" , "Wait for all downloads to be finished" , False ), - ("renice" , "int" , "CPU priority" , 0 )] + __config__ = [("activated" , "bool" , "Activated" , True ), + ("fullpath" , "bool" , "Extract with full paths" , True ), + ("overwrite" , "bool" , "Overwrite files" , False ), + ("keepbroken" , "bool" , "Try to extract broken archives" , False ), + ("repair" , "bool" , "Repair broken archives (rar required)" , False ), + ("test" , "bool" , "Test archive before extracting" , False ), + ("usepasswordfile", "bool" , "Use password file" , True ), + ("passwordfile" , "file" , "Password file" , "archive_password.txt" ), + ("delete" , "bool" , "Delete archive when successfully extracted", False ), + ("subfolder" , "bool" , "Create subfolder for each package" , False ), + ("destination" , "folder", "Extract files to folder" , "" ), + ("extensions" , "str" , "Extract the following extensions" , "7z,bz2,bzip2,gz,gzip,lha,lzh,lzma,rar,tar,taz,tbz,tbz2,tgz,xar,xz,z,zip"), + ("excludefiles" , "str" , "Don't extract the following files" , "*.nfo,*.DS_Store,index.dat,thumb.db" ), + ("recursive" , "bool" , "Extract archives in archives" , True ), + ("waitall" , "bool" , "Wait for all downloads to be finished" , False ), + ("renice" , "int" , "CPU priority" , 0 )] __description__ = """Extract different kind of archives""" __license__ = "GPLv3" @@ -175,6 +179,7 @@ class ExtractArchive(Hook): else: self.logInfo(_("No Extract plugins activated")) + @threaded def extractQueued(self,thread): packages = self.queue.get() diff --git a/module/plugins/internal/Extractor.py b/module/plugins/internal/Extractor.py index ee62ebcb7..bc8e67c6d 100644 --- a/module/plugins/internal/Extractor.py +++ b/module/plugins/internal/Extractor.py @@ -3,6 +3,7 @@ import os from module.PyFile import PyFile +from module.utils import fs_encode class ArchiveError(Exception): @@ -71,6 +72,7 @@ class Extractor: fid=None): """ Initialize extractor for specific file """ self.manager = manager + self.target = "'%s'" % fs_encode(filename) self.filename = filename self.out = out self.fullpath = fullpath diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index a3df52559..5280338dc 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -6,7 +6,7 @@ import re from subprocess import Popen, PIPE from module.plugins.internal.UnRar import ArchiveError, CRCError, PasswordError, UnRar, renice -from module.utils import fs_encode, save_join +from module.utils import save_join class SevenZip(UnRar): @@ -54,10 +54,8 @@ class SevenZip(UnRar): def test(self, password): - file = fs_encode(self.filename) - # 7z can't distinguish crc and pw error in test - p = self.call_cmd("l", "-slt", file) + p = self.call_cmd("l", "-slt", self.target) out, err = p.communicate() if self.re_wrongpwd.search(out): @@ -72,9 +70,7 @@ class SevenZip(UnRar): def check(self, password): - file = fs_encode(self.filename) - - p = self.call_cmd("l", "-slt", file) + p = self.call_cmd("l", "-slt", self.target) out, err = p.communicate() # check if output or error macthes the 'wrong password'-Regexp @@ -92,7 +88,7 @@ class SevenZip(UnRar): def extract(self, password=None): command = "x" if self.fullpath else "e" - p = self.call_cmd(command, '-o' + self.out, fs_encode(self.filename), password=password) + p = self.call_cmd(command, '-o' + self.out, self.target, password=password) renice(p.pid, self.renice) @@ -119,7 +115,7 @@ class SevenZip(UnRar): def list(self, password=None): command = "l" if self.fullpath else "l" - p = self.call_cmd(command, fs_encode(self.filename), password=password) + p = self.call_cmd(command, self.target, password=password) out, err = p.communicate() if "Can not open" in err: diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index eb969bb60..188fc88bb 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -8,7 +8,7 @@ from string import digits from subprocess import Popen, PIPE from module.plugins.internal.Extractor import Extractor, ArchiveError, CRCError, PasswordError -from module.utils import decode, fs_encode, save_join +from module.utils import fs_decode, save_join def renice(pid, value): @@ -56,6 +56,7 @@ class UnRar(Extractor): out, err = p.communicate() cls.__name__ = "RAR" cls.REPAIR = True + except OSError: cls.CMD = os.path.join(pypath, "UnRAR.exe") p = Popen([cls.CMD], stdout=PIPE, stderr=PIPE) @@ -66,6 +67,7 @@ class UnRar(Extractor): out, err = p.communicate() cls.__name__ = "RAR" cls.REPAIR = True + except OSError: #: fallback to unrar p = Popen([cls.CMD], stdout=PIPE, stderr=PIPE) out, err = p.communicate() @@ -87,7 +89,7 @@ class UnRar(Extractor): def test(self, password): - p = self.call_cmd("t", "-v", fs_encode(self.filename), password=password) + p = self.call_cmd("t", "-v", self.target, password=password) self._progress(p) err = p.stderr.read().strip() @@ -99,7 +101,7 @@ class UnRar(Extractor): def check(self, password): - p = self.call_cmd("l", "-v", fs_encode(self.filename), password=password) + p = self.call_cmd("l", "-v", self.target, password=password) out, err = p.communicate() if self.re_wrongpwd.search(err): @@ -115,7 +117,7 @@ class UnRar(Extractor): def repair(self): - p = self.call_cmd("rc", fs_encode(self.filename)) + p = self.call_cmd("rc", self.target) # communicate and retrieve stderr self._progress(p) @@ -147,7 +149,7 @@ class UnRar(Extractor): def extract(self, password=None): command = "x" if self.fullpath else "e" - p = self.call_cmd(command, fs_encode(self.filename), self.out, password=password) + p = self.call_cmd(command, self.target, self.out, password=password) renice(p.pid, self.renice) @@ -187,7 +189,7 @@ class UnRar(Extractor): def list(self, password=None): command = "vb" if self.fullpath else "lb" - p = self.call_cmd(command, "-v", fs_encode(self.filename), password=password) + p = self.call_cmd(command, "-v", self.target, password=password) out, err = p.communicate() if "Cannot open" in err: @@ -199,12 +201,12 @@ class UnRar(Extractor): result = set() if not self.fullpath and self.VERSION.startswith('5'): # NOTE: Unrar 5 always list full path - for f in decode(out).splitlines(): + for f in fs_decode(out).splitlines(): f = save_join(self.out, os.path.basename(f.strip())) if os.path.isfile(f): result.add(save_join(self.out, os.path.basename(f))) else: - for f in decode(out).splitlines(): + for f in fs_decode(out).splitlines(): f = f.strip() result.add(save_join(self.out, f)) diff --git a/module/plugins/internal/UnZip.py b/module/plugins/internal/UnZip.py index d95afbc70..dd57a54a7 100644 --- a/module/plugins/internal/UnZip.py +++ b/module/plugins/internal/UnZip.py @@ -7,7 +7,6 @@ import sys import zipfile from module.plugins.internal.Extractor import Extractor, ArchiveError, CRCError, PasswordError -from module.utils import fs_encode class UnZip(Extractor): @@ -29,7 +28,7 @@ class UnZip(Extractor): def list(self, password=None): - with zipfile.ZipFile(fs_encode(self.filename), 'r', allowZip64=True) as z: + with zipfile.ZipFile(self.target, 'r', allowZip64=True) as z: z.setpassword(password) return z.namelist() @@ -39,7 +38,7 @@ class UnZip(Extractor): def test(self): - with zipfile.ZipFile(fs_encode(self.filename), 'r', allowZip64=True) as z: + with zipfile.ZipFile(self.target, 'r', allowZip64=True) as z: badfile = z.testzip() if badfile: @@ -50,7 +49,7 @@ class UnZip(Extractor): def extract(self, password=None): try: - with zipfile.ZipFile(fs_encode(self.filename), 'r', allowZip64=True) as z: + with zipfile.ZipFile(self.target, 'r', allowZip64=True) as z: z.setpassword(password) badfile = z.testzip() -- cgit v1.2.3 From 5ea0fe898b435a5654e0a14172025779c82182d6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 2 Mar 2015 00:39:51 +0100 Subject: [ClickAndLoad] Revert and improve --- module/plugins/hooks/ClickAndLoad.py | 50 +++++++++++++++++------------------- 1 file changed, 24 insertions(+), 26 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 5b21aec96..1a7dec6ac 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -16,6 +16,7 @@ def forward(source, destination): destination.sendall(bufdata) bufdata = source.recv(bufsize) finally: + source.shutdown(socket.SHUT_RD) destination.shutdown(socket.SHUT_WR) @@ -23,13 +24,13 @@ def forward(source, destination): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.37" + __version__ = "0.38" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), ("extern" , "bool", "Listen on the public network interface", True)] - __description__ = """Click'N'Load hook plugin""" + __description__ = """Click'n'Load hook plugin""" __license__ = "GPLv3" __authors__ = [("RaNaN", "RaNaN@pyload.de"), ("Walter Purcaro", "vuolter@gmail.com")] @@ -45,7 +46,7 @@ class ClickAndLoad(Hook): return ip = "" if self.getConfig("extern") else "127.0.0.1" - webport = int(self.config['webinterface']['port']) + webport = self.config['webinterface']['port'] cnlport = self.getConfig('port') self.proxy(ip, webport, cnlport) @@ -54,39 +55,36 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): self.logInfo(_("Proxy listening on %s:%s") % (ip or "0.0.0.0", cnlport)) - self.manager.startThread(self._server, ip, webport, cnlport) + + self._server(ip, webport, cnlport) + lock = Lock() lock.acquire() lock.acquire() - def _server(self, ip, webport, cnlport, thread): + @threaded + def _server(self, ip, webport, cnlport): try: - try: - server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + dock_socket.bind((ip, cnlport)) + dock_socket.listen(1) - server_socket.bind((ip, cnlport)) - server_socket.listen(5) + while True: + client_socket, client_addr = dock_socket.accept() + self.logDebug("Connection from: %s" % client_addr) - while True: - client_socket = server_socket.accept()[0] - dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - - dock_socket.connect(("127.0.0.1", webport)) - - self.manager.startThread(forward, dock_socket, client_socket) - self.manager.startThread(forward, client_socket, dock_socket) + server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + server_socket.connect(("127.0.0.1", webport)) - except socket.timeout: - self.logDebug("Connection timed out, retrying...") - return self._server(ip, webport, cnlport, thread) + self.manager.startThread(forward, client_socket, server_socket) + self.manager.startThread(forward, server_socket, client_socket) - finally: - server_socket.close() - client_socket.close() - dock_socket.close() + except socket.timeout: + self.logDebug("Connection timed out, retrying...") + return self._server(ip, webport, cnlport) except socket.error, e: self.logError(e) - time.sleep(120) - self._server(ip, webport, cnlport, thread) + time.sleep(240) + return self._server(ip, webport, cnlport) -- cgit v1.2.3 From 8b432eb80715f84800febb88620d943211e28051 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 4 Mar 2015 02:21:50 +0100 Subject: Revert 3a9c167ceca27d57dbef927626fe853a3d0e30b2 --- module/plugins/internal/Extractor.py | 22 ++++++++++------------ module/plugins/internal/SevenZip.py | 10 +++++----- module/plugins/internal/UnRar.py | 12 ++++++------ module/plugins/internal/UnZip.py | 7 ++++--- 4 files changed, 25 insertions(+), 26 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/internal/Extractor.py b/module/plugins/internal/Extractor.py index bc8e67c6d..4b21cc49c 100644 --- a/module/plugins/internal/Extractor.py +++ b/module/plugins/internal/Extractor.py @@ -3,7 +3,6 @@ import os from module.PyFile import PyFile -from module.utils import fs_encode class ArchiveError(Exception): @@ -71,17 +70,16 @@ class Extractor: keepbroken=False, fid=None): """ Initialize extractor for specific file """ - self.manager = manager - self.target = "'%s'" % fs_encode(filename) - self.filename = filename - self.out = out - self.fullpath = fullpath - self.overwrite = overwrite - self.excludefiles = excludefiles - self.renice = renice - self.delete = delete - self.keepbroken = keepbroken - self.files = [] #: Store extracted files here + self.manager = manager + self.filename = filename + self.out = out + self.fullpath = fullpath + self.overwrite = overwrite + self.excludefiles = excludefiles + self.renice = renice + self.delete = delete + self.keepbroken = keepbroken + self.files = [] #: Store extracted files here pyfile = self.manager.core.files.getFile(fid) if fid else None self.notifyProgress = lambda x: pyfile.setProgress(x) if pyfile else lambda x: None diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index 5280338dc..b5b113566 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -6,7 +6,7 @@ import re from subprocess import Popen, PIPE from module.plugins.internal.UnRar import ArchiveError, CRCError, PasswordError, UnRar, renice -from module.utils import save_join +from module.utils import fs_encode, save_join class SevenZip(UnRar): @@ -55,7 +55,7 @@ class SevenZip(UnRar): def test(self, password): # 7z can't distinguish crc and pw error in test - p = self.call_cmd("l", "-slt", self.target) + p = self.call_cmd("l", "-slt", fs_encode(self.filename)) out, err = p.communicate() if self.re_wrongpwd.search(out): @@ -70,7 +70,7 @@ class SevenZip(UnRar): def check(self, password): - p = self.call_cmd("l", "-slt", self.target) + p = self.call_cmd("l", "-slt", fs_encode(self.filename)) out, err = p.communicate() # check if output or error macthes the 'wrong password'-Regexp @@ -88,7 +88,7 @@ class SevenZip(UnRar): def extract(self, password=None): command = "x" if self.fullpath else "e" - p = self.call_cmd(command, '-o' + self.out, self.target, password=password) + p = self.call_cmd(command, '-o' + self.out, fs_encode(self.filename), password=password) renice(p.pid, self.renice) @@ -115,7 +115,7 @@ class SevenZip(UnRar): def list(self, password=None): command = "l" if self.fullpath else "l" - p = self.call_cmd(command, self.target, password=password) + p = self.call_cmd(command, fs_encode(self.filename), password=password) out, err = p.communicate() if "Can not open" in err: diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index 188fc88bb..220dd6365 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -8,7 +8,7 @@ from string import digits from subprocess import Popen, PIPE from module.plugins.internal.Extractor import Extractor, ArchiveError, CRCError, PasswordError -from module.utils import fs_decode, save_join +from module.utils import fs_decode, fs_encode, save_join def renice(pid, value): @@ -89,7 +89,7 @@ class UnRar(Extractor): def test(self, password): - p = self.call_cmd("t", "-v", self.target, password=password) + p = self.call_cmd("t", "-v", fs_encode(self.filename), password=password) self._progress(p) err = p.stderr.read().strip() @@ -101,7 +101,7 @@ class UnRar(Extractor): def check(self, password): - p = self.call_cmd("l", "-v", self.target, password=password) + p = self.call_cmd("l", "-v", fs_encode(self.filename), password=password) out, err = p.communicate() if self.re_wrongpwd.search(err): @@ -117,7 +117,7 @@ class UnRar(Extractor): def repair(self): - p = self.call_cmd("rc", self.target) + p = self.call_cmd("rc", fs_encode(self.filename)) # communicate and retrieve stderr self._progress(p) @@ -149,7 +149,7 @@ class UnRar(Extractor): def extract(self, password=None): command = "x" if self.fullpath else "e" - p = self.call_cmd(command, self.target, self.out, password=password) + p = self.call_cmd(command, fs_encode(self.filename), self.out, password=password) renice(p.pid, self.renice) @@ -189,7 +189,7 @@ class UnRar(Extractor): def list(self, password=None): command = "vb" if self.fullpath else "lb" - p = self.call_cmd(command, "-v", self.target, password=password) + p = self.call_cmd(command, "-v", fs_encode(self.filename), password=password) out, err = p.communicate() if "Cannot open" in err: diff --git a/module/plugins/internal/UnZip.py b/module/plugins/internal/UnZip.py index dd57a54a7..d95afbc70 100644 --- a/module/plugins/internal/UnZip.py +++ b/module/plugins/internal/UnZip.py @@ -7,6 +7,7 @@ import sys import zipfile from module.plugins.internal.Extractor import Extractor, ArchiveError, CRCError, PasswordError +from module.utils import fs_encode class UnZip(Extractor): @@ -28,7 +29,7 @@ class UnZip(Extractor): def list(self, password=None): - with zipfile.ZipFile(self.target, 'r', allowZip64=True) as z: + with zipfile.ZipFile(fs_encode(self.filename), 'r', allowZip64=True) as z: z.setpassword(password) return z.namelist() @@ -38,7 +39,7 @@ class UnZip(Extractor): def test(self): - with zipfile.ZipFile(self.target, 'r', allowZip64=True) as z: + with zipfile.ZipFile(fs_encode(self.filename), 'r', allowZip64=True) as z: badfile = z.testzip() if badfile: @@ -49,7 +50,7 @@ class UnZip(Extractor): def extract(self, password=None): try: - with zipfile.ZipFile(self.target, 'r', allowZip64=True) as z: + with zipfile.ZipFile(fs_encode(self.filename), 'r', allowZip64=True) as z: z.setpassword(password) badfile = z.testzip() -- cgit v1.2.3 From 8d85fb7c11dfa83052d09402dbae21dde44392aa Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 4 Mar 2015 03:12:58 +0100 Subject: [ClickAndLoad] Fix https://github.com/pyload/pyload/issues/1220 --- module/plugins/hooks/ClickAndLoad.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 1a7dec6ac..f3396be77 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -16,15 +16,15 @@ def forward(source, destination): destination.sendall(bufdata) bufdata = source.recv(bufsize) finally: - source.shutdown(socket.SHUT_RD) destination.shutdown(socket.SHUT_WR) + destination.close() #@TODO: IPv6 support class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.38" + __version__ = "0.39" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), @@ -68,11 +68,11 @@ class ClickAndLoad(Hook): try: dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) dock_socket.bind((ip, cnlport)) - dock_socket.listen(1) + dock_socket.listen(5) while True: client_socket, client_addr = dock_socket.accept() - self.logDebug("Connection from: %s" % client_addr) + self.logDebug("Connection from %s:%s" % client_addr) server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.connect(("127.0.0.1", webport)) -- cgit v1.2.3 From db76c2b8358d598c3106dc39ec11debdfcd3d6b1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 5 Mar 2015 23:13:52 +0100 Subject: [SoundcloudCom] Fix https://github.com/pyload/pyload/issues/1196 --- module/plugins/hoster/SoundcloudCom.py | 88 +++++++++++++++++----------------- 1 file changed, 43 insertions(+), 45 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hoster/SoundcloudCom.py b/module/plugins/hoster/SoundcloudCom.py index c7c9c3880..c559b392b 100644 --- a/module/plugins/hoster/SoundcloudCom.py +++ b/module/plugins/hoster/SoundcloudCom.py @@ -1,57 +1,55 @@ # -*- coding: utf-8 -*- -import pycurl import re -from module.plugins.Hoster import Hoster +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.common.json_layer import json_loads -class SoundcloudCom(Hoster): +class SoundcloudCom(SimpleHoster): __name__ = "SoundcloudCom" __type__ = "hoster" - __version__ = "0.10" + __version__ = "0.11" - __pattern__ = r'https?://(?:www\.)?soundcloud\.com/(?P.+?)/(?P.+)' + __pattern__ = r'https?://(?:www\.)?soundcloud\.com/[\w-]+/[\w-]+' + __config__ = [("quality", "Lower;Higher", "Quality", "Higher")] __description__ = """SoundCloud.com hoster plugin""" __license__ = "GPLv3" - __authors__ = [("Peekayy", "peekayy.dev@gmail.com")] - - - def process(self, pyfile): - # default UserAgent of HTTPRequest fails for this hoster so we use this one - self.req.http.c.setopt(pycurl.USERAGENT, 'Mozilla/5.0') - self.html = self.load(pyfile.url) - m = re.search(r'
.*?)"', self.html) - if m: - clientId = m.group('CID') - - if len(clientId) <= 0: - clientId = "b45b1aa10f1ac2941910a7f0d10f8e28" - - m = re.search(r'\s(?P.*?)\s</em>', self.html) - if m: - pyfile.name = m.group('TITLE') + ".mp3" - else: - pyfile.name = re.match(self.__pattern__, pyfile.url).group('SID') + ".mp3" - - # url to retrieve the actual song url - self.html = self.load("https://api.sndcdn.com/i1/tracks/%s/streams" % songId, get={"client_id": clientId}) - # getting streams - # for now we choose the first stream found in all cases - # it could be improved if relevant for this hoster - streams = [ - (result.group('QUALITY'), result.group('URL')) - for result in re.finditer(r'"(?P<QUALITY>.*?)":"(?P<URL>.*?)"', self.html) - ] - self.logDebug("Found Streams", streams) - self.logDebug("Downloading", streams[0][0], streams[0][1]) - self.download(streams[0][1]) + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + NAME_PATTERN = r'title" content="(?P<N>.+?)"' + OFFLINE_PATTERN = r'<title>"SoundCloud - Hear the world’s sounds"' + + + def handleFree(self, pyfile): + try: + song_id = re.search(r'sounds:(\d+)"', self.html).group(1) + + except Exception: + self.error(_("Could not find song id")) + + try: + client_id = re.search(r'"clientID":"(.+?)"', self.html).group(1) + + except Exception: + client_id = "b45b1aa10f1ac2941910a7f0d10f8e28" + + # url to retrieve the actual song url + streams = json_loads(self.load("https://api.soundcloud.com/tracks/%s/streams" % song_id, + get={'client_id': client_id})) + + regex = re.compile(r'[^\d]') + http_streams = sorted([(key, value) for key, value in streams.iteritems() if key.startswith('http_')], + key=lambda t: regex.sub(t[0], ''), + reverse=True) + + self.logDebug("Streams found: %s" % (http_streams or "None")) + + if http_streams: + stream_name, self.link = http_streams[0 if self.getConfig('quality') == "Higher" else -1] + pyfile.name += '.' + stream_name.split('_')[1].lower() + + +getInfo = create_getInfo(SoundcloudCom) -- cgit v1.2.3 From 9854d2f81577dc3c5c7c97cefd61404f739f4a24 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 5 Mar 2015 23:15:19 +0100 Subject: [ClickAndLoad] Fixup --- module/plugins/hooks/ClickAndLoad.py | 4 ++-- module/plugins/hoster/MegaCoNz.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index f3396be77..938269795 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -17,14 +17,14 @@ def forward(source, destination): bufdata = source.recv(bufsize) finally: destination.shutdown(socket.SHUT_WR) - destination.close() + # destination.close() #@TODO: IPv6 support class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.39" + __version__ = "0.40" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), diff --git a/module/plugins/hoster/MegaCoNz.py b/module/plugins/hoster/MegaCoNz.py index 4ad20b265..37ac12b44 100644 --- a/module/plugins/hoster/MegaCoNz.py +++ b/module/plugins/hoster/MegaCoNz.py @@ -50,7 +50,7 @@ class MegaCoNz(Hoster): __type__ = "hoster" __version__ = "0.26" - __pattern__ = r'(?:https?://(?:www\.)?mega\.co\.nz/|mega:|chrome:.+?)#(?PN|)!(?P[\w^_]+)!(?P[\w,\\-]+)' + __pattern__ = r'(?:https?://(?:www\.)?mega\.co\.nz/|mega:|chrome:.+?)#(?PN|)!(?P[\w^_]+)!(?P[\w,-]+)' __description__ = """Mega.co.nz hoster plugin""" __license__ = "GPLv3" -- cgit v1.2.3 From 0685e1f1d55e8a1a3083ca147ad4087430fc2620 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 6 Mar 2015 03:32:08 +0100 Subject: [SkipRev] Fix https://github.com/pyload/pyload/issues/1217 --- module/plugins/hooks/SkipRev.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 0bbdec3b2..3ebfa378e 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -18,9 +18,10 @@ def _setup(self): class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.25" + __version__ = "0.26" - __config__ = [("tokeep", "int", "Number of rev files to keep for package (-1 to auto)", -1)] + __config__ = [("mode" , "Auto;Manual", "Choose rev files to keep for package", "Auto"), + ("tokeep", "int" , "Custom number of files to keep" , 0 )] __description__ = """Skip files ending with extension rev""" __license__ = "GPLv3" @@ -32,8 +33,8 @@ class SkipRev(Hook): pass - def _pyname(self, pyfile): - if hasattr(pyfile.pluginmodule, "getInfo"): + def _name(self, pyfile): + if hasattr(pyfile.pluginmodule, "getInfo"): #@NOTE: getInfo is deprecated in 0.4.10 return getattr(pyfile.pluginmodule, "getInfo")([pyfile.url]).next()[0] else: self.logWarning("Unable to grab file name") @@ -54,16 +55,19 @@ class SkipRev(Hook): def downloadPreparing(self, pyfile): - if pyfile.statusname is "unskipped" or not self._pyname(pyfile).endswith(".rev"): + name = self._name(pyfile) + + if pyfile.statusname is "unskipped" or not name.endswith(".rev") or not '.part' in name: return - tokeep = self.getConfig("tokeep") + tokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('tokeep') if tokeep: status_list = (1, 4, 8, 9, 14) if tokeep < 0 else (1, 3, 4, 8, 9, 14) + pyname = re.compile(r'%s\.part\d+\.rev$' % name.rsplit('.', 2)[0].replace('.', '\.')) queued = [True for link in self.core.api.getPackageData(pyfile.package().id).links \ - if link.name.endswith(".rev") and link.status not in status_list].count(True) + if link.status not in status_list and pyname.match(link.name)].count(True) if not queued or queued < tokeep: #: keep one rev at least in auto mode return @@ -76,16 +80,18 @@ class SkipRev(Hook): def downloadFailed(self, pyfile): #: Check if pyfile is still "failed", # maybe might has been restarted in meantime - if pyfile.status != 8: + if pyfile.status != 8 or pyfile.name.rsplit('.', 1)[-1].strip() not in ("rar", "rev"): return - tokeep = self.getConfig("tokeep") + tokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('tokeep') if not tokeep: return + pyname = re.compile(r'%s\.part\d+\.rev$' % pyfile.name.rsplit('.', 2)[0].replace('.', '\.')) + for link in self.core.api.getPackageData(pyfile.package().id).links: - if link.status is 4 and link.name.endswith(".rev"): + if link.status is 4 and pyname.match(link.name): pylink = self._pyfile(link) if tokeep > -1 or pyfile.name.endswith(".rev"): -- cgit v1.2.3 From cb52389931917fee9a6116b45922f502480350d6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 6 Mar 2015 03:45:46 +0100 Subject: [SkipRev] Fix setup loop on download preparing --- module/plugins/hooks/SkipRev.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 3ebfa378e..a543ef71c 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -18,7 +18,7 @@ def _setup(self): class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.26" + __version__ = "0.27" __config__ = [("mode" , "Auto;Manual", "Choose rev files to keep for package", "Auto"), ("tokeep", "int" , "Custom number of files to keep" , 0 )] @@ -57,7 +57,7 @@ class SkipRev(Hook): def downloadPreparing(self, pyfile): name = self._name(pyfile) - if pyfile.statusname is "unskipped" or not name.endswith(".rev") or not '.part' in name: + if pyfile.statusname is "unskipped" or not name.endswith(".rev") or not ".part" in name: return tokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('tokeep') @@ -73,8 +73,10 @@ class SkipRev(Hook): return pyfile.setCustomStatus("SkipRev", "skipped") - pyfile.plugin._setup = pyfile.plugin.setup - pyfile.plugin.setup = MethodType(_setup, pyfile.plugin) #: work-around: inject status checker inside the preprocessing routine of the plugin + + if not hasattr(pyfile.plugin, "_setup"): + pyfile.plugin._setup = pyfile.plugin.setup + pyfile.plugin.setup = MethodType(_setup, pyfile.plugin) #: work-around: inject status checker inside the preprocessing routine of the plugin def downloadFailed(self, pyfile): -- cgit v1.2.3 From 5f4b7afb0bf8f770032ee21ce67c76194d8d6cb0 Mon Sep 17 00:00:00 2001 From: jellysheep Date: Fri, 6 Mar 2015 14:24:22 +0100 Subject: [ExternalScripts] Encode unicode characters If a file with unicode characters in the filename is downloaded ExternalScripts.py fails with e.g. this error: ExternalScripts: Error in download_finished.sh: 'ascii' codec can't decode byte 0xc3 in position 29: ordinal not in range(128) This commit makes the plugin encode unicode characters to UTF-8. --- module/plugins/hooks/ExternalScripts.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index f49220c2a..76a9d9c52 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -74,7 +74,8 @@ class ExternalScripts(Hook): def callScript(self, script, *args): try: - cmd = [script] + [str(x) if not isinstance(x, basestring) else x for x in args] + cmd = [script] + [x.encode("UTF-8") if isinstance(x, unicode) else + str(x) if not isinstance(x, basestring) else x for x in args] self.logDebug("Executing", os.path.abspath(script), " ".join(cmd)) -- cgit v1.2.3 From 6aa9ab4f05a9fb5f5fc9cbe1758591cd239ba089 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 6 Mar 2015 18:30:56 +0100 Subject: [SkipRev] Fix https://github.com/pyload/pyload/issues/1217 (2) --- module/plugins/hooks/SkipRev.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index a543ef71c..034d2b803 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +import re + from types import MethodType from urllib import unquote from urlparse import urlparse @@ -18,7 +20,7 @@ def _setup(self): class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.27" + __version__ = "0.28" __config__ = [("mode" , "Auto;Manual", "Choose rev files to keep for package", "Auto"), ("tokeep", "int" , "Custom number of files to keep" , 0 )] @@ -35,7 +37,7 @@ class SkipRev(Hook): def _name(self, pyfile): if hasattr(pyfile.pluginmodule, "getInfo"): #@NOTE: getInfo is deprecated in 0.4.10 - return getattr(pyfile.pluginmodule, "getInfo")([pyfile.url]).next()[0] + return pyfile.pluginmodule.getInfo([pyfile.url]).next()[0] else: self.logWarning("Unable to grab file name") return urlparse(unquote(pyfile.url)).path.split('/')[-1] -- cgit v1.2.3 From 311e9a1d9ca6450ec84e4a54ef47dbf488e83107 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 6 Mar 2015 22:03:57 +0100 Subject: [MediafireCom] Update --- module/plugins/hoster/MediafireCom.py | 122 ++++++++-------------------------- 1 file changed, 29 insertions(+), 93 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hoster/MediafireCom.py b/module/plugins/hoster/MediafireCom.py index bc81c8202..54df531bd 100644 --- a/module/plugins/hoster/MediafireCom.py +++ b/module/plugins/hoster/MediafireCom.py @@ -3,126 +3,62 @@ import re from module.plugins.internal.CaptchaService import SolveMedia -from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo -from module.network.RequestFactory import getURL - - -def replace_eval(js_expr): - return js_expr.replace(r'eval("', '').replace(r"\'", r"'").replace(r'\"', r'"') - - -def checkHTMLHeader(url): - try: - for _i in xrange(3): - header = getURL(url, just_header=True) - - for line in header.splitlines(): - line = line.lower() - - if 'location' in line: - url = line.split(':', 1)[1].strip() - if 'error.php?errno=320' in url: - return url, 1 - - if not url.startswith('http://'): - url = 'http://www.mediafire.com' + url - - break - - elif 'content-disposition' in line: - return url, 2 - else: - break - except Exception: - return url, 3 - else: - return url, 0 - - -def getInfo(urls): - for url in urls: - location, status = checkHTMLHeader(url) - - if status: - file_info = (url, 0, status, url) - else: - file_info = parseFileInfo(MediafireCom, url, getURL(url, decode=True)) - - yield file_info +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class MediafireCom(SimpleHoster): __name__ = "MediafireCom" __type__ = "hoster" - __version__ = "0.84" + __version__ = "0.85" - __pattern__ = r'http://(?:www\.)?mediafire\.com/(file/|(view/?|download\.php)?\?)(\w{11}|\w{15})($|/)' + __pattern__ = r'https?://(?:www\.)?mediafire\.com/(file/|view/\??|download(\.php\?|/))\w+' __description__ = """Mediafire.com hoster plugin""" __license__ = "GPLv3" __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), - ("stickell", "l.stickell@yahoo.it")] + ("stickell", "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com")] + + NAME_PATTERN = r'' + SIZE_PATTERN = r'
  • File size: (?P[\d.,]+) (?P[\w^_]+)' + INFO_PATTERN = r'oFileSharePopup\.ald\(\'.*?\',\'(?P.+?)\',\'(?P[\d.,]+)\s*(?P[\w^_]+)\',\'\',\'(?P.+?)\'\)' + OFFLINE_PATTERN = r'class="error_msg_title"' - NAME_PATTERN = r'' - INFO_PATTERN = r'oFileSharePopup\.ald\(\'(?P[^\']*)\',\'(?P[^\']*)\',\'(?P[^\']*)\',\'\',\'(?P[^\']*)\'\)' - OFFLINE_PATTERN = r'class="error_msg_title"> Invalid or Deleted File.
  • ' + LINK_FREE_PATTERN = r'kNO = "(.+?)"' PASSWORD_PATTERN = r'
    Date: Fri, 6 Mar 2015 22:31:52 +0100 Subject: [ExternalScripts] Version up --- module/plugins/hooks/ExternalScripts.py | 5 ++--- module/plugins/hooks/SkipRev.py | 18 +++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 76a9d9c52..a09d5e92e 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -10,7 +10,7 @@ from module.utils import save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.29" + __version__ = "0.30" __config__ = [("activated", "bool", "Activated" , True ), ("wait" , "bool", "Wait script ending", False)] @@ -74,8 +74,7 @@ class ExternalScripts(Hook): def callScript(self, script, *args): try: - cmd = [script] + [x.encode("UTF-8") if isinstance(x, unicode) else - str(x) if not isinstance(x, basestring) else x for x in args] + cmd = [script] + [(str(x) if not isinstance(x, basestring) else x).encode('utf-8') for x in args] self.logDebug("Executing", os.path.abspath(script), " ".join(cmd)) diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 034d2b803..a4d46316e 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -22,8 +22,8 @@ class SkipRev(Hook): __type__ = "hook" __version__ = "0.28" - __config__ = [("mode" , "Auto;Manual", "Choose rev files to keep for package", "Auto"), - ("tokeep", "int" , "Custom number of files to keep" , 0 )] + __config__ = [("mode" , "Auto;Manual", "Choose rev files to keep for package", "Auto"), + ("revtokeep", "int" , "Custom number of files to keep" , 0 )] __description__ = """Skip files ending with extension rev""" __license__ = "GPLv3" @@ -62,16 +62,16 @@ class SkipRev(Hook): if pyfile.statusname is "unskipped" or not name.endswith(".rev") or not ".part" in name: return - tokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('tokeep') + revtokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('revtokeep') - if tokeep: - status_list = (1, 4, 8, 9, 14) if tokeep < 0 else (1, 3, 4, 8, 9, 14) + if revtokeep: + status_list = (1, 4, 8, 9, 14) if revtokeep < 0 else (1, 3, 4, 8, 9, 14) pyname = re.compile(r'%s\.part\d+\.rev$' % name.rsplit('.', 2)[0].replace('.', '\.')) queued = [True for link in self.core.api.getPackageData(pyfile.package().id).links \ if link.status not in status_list and pyname.match(link.name)].count(True) - if not queued or queued < tokeep: #: keep one rev at least in auto mode + if not queued or queued < revtokeep: #: keep one rev at least in auto mode return pyfile.setCustomStatus("SkipRev", "skipped") @@ -87,9 +87,9 @@ class SkipRev(Hook): if pyfile.status != 8 or pyfile.name.rsplit('.', 1)[-1].strip() not in ("rar", "rev"): return - tokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('tokeep') + revtokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('revtokeep') - if not tokeep: + if not revtokeep: return pyname = re.compile(r'%s\.part\d+\.rev$' % pyfile.name.rsplit('.', 2)[0].replace('.', '\.')) @@ -98,7 +98,7 @@ class SkipRev(Hook): if link.status is 4 and pyname.match(link.name): pylink = self._pyfile(link) - if tokeep > -1 or pyfile.name.endswith(".rev"): + if revtokeep > -1 or pyfile.name.endswith(".rev"): pylink.setStatus("queued") else: pylink.setCustomStatus("unskipped", "queued") -- cgit v1.2.3 From d04a0a9b436df0c048f6d7d06f71df0ee8d1ec6f Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 6 Mar 2015 22:54:04 +0100 Subject: [DailymotionBatch][YoutubeBatch] Renamed --- module/plugins/crypter/DailymotionBatch.py | 106 ------------------ module/plugins/crypter/DailymotionComFolder.py | 106 ++++++++++++++++++ module/plugins/crypter/YoutubeBatch.py | 148 ------------------------- module/plugins/crypter/YoutubeComFolder.py | 148 +++++++++++++++++++++++++ module/plugins/hoster/MediafireCom.py | 2 - 5 files changed, 254 insertions(+), 256 deletions(-) delete mode 100644 module/plugins/crypter/DailymotionBatch.py create mode 100644 module/plugins/crypter/DailymotionComFolder.py delete mode 100644 module/plugins/crypter/YoutubeBatch.py create mode 100644 module/plugins/crypter/YoutubeComFolder.py (limited to 'module/plugins') diff --git a/module/plugins/crypter/DailymotionBatch.py b/module/plugins/crypter/DailymotionBatch.py deleted file mode 100644 index 82b80ab2f..000000000 --- a/module/plugins/crypter/DailymotionBatch.py +++ /dev/null @@ -1,106 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from urlparse import urljoin - -from module.common.json_layer import json_loads -from module.plugins.Crypter import Crypter -from module.utils import save_join - - -class DailymotionBatch(Crypter): - __name__ = "DailymotionBatch" - __type__ = "crypter" - __version__ = "0.01" - - __pattern__ = r'https?://(?:www\.)?dailymotion\.com/((playlists/)?(?Pplaylist|user)/)?(?P[\w^_]+)(?(TYPE)|#)' - __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), - ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] - - __description__ = """Dailymotion.com channel & playlist decrypter""" - __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - - - def api_response(self, ref, req=None): - url = urljoin("https://api.dailymotion.com/", ref) - html = self.load(url, get=req) - return json_loads(html) - - - def getPlaylistInfo(self, id): - ref = "playlist/" + id - req = {"fields": "name,owner.screenname"} - playlist = self.api_response(ref, req) - - if "error" in playlist: - return - - name = playlist['name'] - owner = playlist['owner.screenname'] - return name, owner - - - def _getPlaylists(self, user_id, page=1): - ref = "user/%s/playlists" % user_id - req = {"fields": "id", "page": page, "limit": 100} - user = self.api_response(ref, req) - - if "error" in user: - return - - for playlist in user['list']: - yield playlist['id'] - - if user['has_more']: - for item in self._getPlaylists(user_id, page + 1): - yield item - - - def getPlaylists(self, user_id): - return [(id,) + self.getPlaylistInfo(id) for id in self._getPlaylists(user_id)] - - - def _getVideos(self, id, page=1): - ref = "playlist/%s/videos" % id - req = {"fields": "url", "page": page, "limit": 100} - playlist = self.api_response(ref, req) - - if "error" in playlist: - return - - for video in playlist['list']: - yield video['url'] - - if playlist['has_more']: - for item in self._getVideos(id, page + 1): - yield item - - - def getVideos(self, playlist_id): - return list(self._getVideos(playlist_id))[::-1] - - - def decrypt(self, pyfile): - m = re.match(self.__pattern__, pyfile.url) - m_id = m.group('ID') - m_type = m.group('TYPE') - - if m_type == "playlist": - self.logDebug("Url recognized as Playlist") - p_info = self.getPlaylistInfo(m_id) - playlists = [(m_id,) + p_info] if p_info else None - else: - self.logDebug("Url recognized as Channel") - playlists = self.getPlaylists(m_id) - self.logDebug("%s playlist\s found on channel \"%s\"" % (len(playlists), m_id)) - - if not playlists: - self.fail(_("No playlist available")) - - for p_id, p_name, p_owner in playlists: - p_videos = self.getVideos(p_id) - p_folder = save_join(self.config['general']['download_folder'], p_owner, p_name) - self.logDebug("%s video\s found on playlist \"%s\"" % (len(p_videos), p_name)) - self.packages.append((p_name, p_videos, p_folder)) #: folder is NOT recognized by pyload 0.4.9! diff --git a/module/plugins/crypter/DailymotionComFolder.py b/module/plugins/crypter/DailymotionComFolder.py new file mode 100644 index 000000000..e7cbbfb2c --- /dev/null +++ b/module/plugins/crypter/DailymotionComFolder.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- + +import re + +from urlparse import urljoin + +from module.common.json_layer import json_loads +from module.plugins.Crypter import Crypter +from module.utils import save_join + + +class DailymotionComFolder(Crypter): + __name__ = "DailymotionComFolder" + __type__ = "crypter" + __version__ = "0.01" + + __pattern__ = r'https?://(?:www\.)?dailymotion\.com/((playlists/)?(?Pplaylist|user)/)?(?P[\w^_]+)(?(TYPE)|#)' + __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] + + __description__ = """Dailymotion.com channel & playlist decrypter""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + def api_response(self, ref, req=None): + url = urljoin("https://api.dailymotion.com/", ref) + html = self.load(url, get=req) + return json_loads(html) + + + def getPlaylistInfo(self, id): + ref = "playlist/" + id + req = {"fields": "name,owner.screenname"} + playlist = self.api_response(ref, req) + + if "error" in playlist: + return + + name = playlist['name'] + owner = playlist['owner.screenname'] + return name, owner + + + def _getPlaylists(self, user_id, page=1): + ref = "user/%s/playlists" % user_id + req = {"fields": "id", "page": page, "limit": 100} + user = self.api_response(ref, req) + + if "error" in user: + return + + for playlist in user['list']: + yield playlist['id'] + + if user['has_more']: + for item in self._getPlaylists(user_id, page + 1): + yield item + + + def getPlaylists(self, user_id): + return [(id,) + self.getPlaylistInfo(id) for id in self._getPlaylists(user_id)] + + + def _getVideos(self, id, page=1): + ref = "playlist/%s/videos" % id + req = {"fields": "url", "page": page, "limit": 100} + playlist = self.api_response(ref, req) + + if "error" in playlist: + return + + for video in playlist['list']: + yield video['url'] + + if playlist['has_more']: + for item in self._getVideos(id, page + 1): + yield item + + + def getVideos(self, playlist_id): + return list(self._getVideos(playlist_id))[::-1] + + + def decrypt(self, pyfile): + m = re.match(self.__pattern__, pyfile.url) + m_id = m.group('ID') + m_type = m.group('TYPE') + + if m_type == "playlist": + self.logDebug("Url recognized as Playlist") + p_info = self.getPlaylistInfo(m_id) + playlists = [(m_id,) + p_info] if p_info else None + else: + self.logDebug("Url recognized as Channel") + playlists = self.getPlaylists(m_id) + self.logDebug("%s playlist\s found on channel \"%s\"" % (len(playlists), m_id)) + + if not playlists: + self.fail(_("No playlist available")) + + for p_id, p_name, p_owner in playlists: + p_videos = self.getVideos(p_id) + p_folder = save_join(self.config['general']['download_folder'], p_owner, p_name) + self.logDebug("%s video\s found on playlist \"%s\"" % (len(p_videos), p_name)) + self.packages.append((p_name, p_videos, p_folder)) #: folder is NOT recognized by pyload 0.4.9! diff --git a/module/plugins/crypter/YoutubeBatch.py b/module/plugins/crypter/YoutubeBatch.py deleted file mode 100644 index 40b4eedd2..000000000 --- a/module/plugins/crypter/YoutubeBatch.py +++ /dev/null @@ -1,148 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from urlparse import urljoin - -from module.common.json_layer import json_loads -from module.plugins.Crypter import Crypter -from module.utils import save_join - - -class YoutubeBatch(Crypter): - __name__ = "YoutubeBatch" - __type__ = "crypter" - __version__ = "1.01" - - __pattern__ = r'https?://(?:www\.|m\.)?youtube\.com/(?Puser|playlist|view_play_list)(/|.*?[?&](?:list|p)=)(?P[\w-]+)' - __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), - ("subfolder_per_package", "bool", "Create a subfolder for each package", True), - ("likes", "bool", "Grab user (channel) liked videos", False), - ("favorites", "bool", "Grab user (channel) favorite videos", False), - ("uploads", "bool", "Grab channel unplaylisted videos", True)] - - __description__ = """Youtube.com channel & playlist decrypter plugin""" - __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - - - API_KEY = "AIzaSyCKnWLNlkX-L4oD1aEzqqhRw1zczeD6_k0" - - - def api_response(self, ref, req): - req.update({"key": self.API_KEY}) - url = urljoin("https://www.googleapis.com/youtube/v3/", ref) - html = self.load(url, get=req) - return json_loads(html) - - - def getChannel(self, user): - channels = self.api_response("channels", {"part": "id,snippet,contentDetails", "forUsername": user, "maxResults": "50"}) - if channels['items']: - channel = channels['items'][0] - return {"id": channel['id'], - "title": channel['snippet']['title'], - "relatedPlaylists": channel['contentDetails']['relatedPlaylists'], - "user": user} # One lone channel for user? - - - def getPlaylist(self, p_id): - playlists = self.api_response("playlists", {"part": "snippet", "id": p_id}) - if playlists['items']: - playlist = playlists['items'][0] - return {"id": p_id, - "title": playlist['snippet']['title'], - "channelId": playlist['snippet']['channelId'], - "channelTitle": playlist['snippet']['channelTitle']} - - - def _getPlaylists(self, id, token=None): - req = {"part": "id", "maxResults": "50", "channelId": id} - if token: - req.update({"pageToken": token}) - - playlists = self.api_response("playlists", req) - - for playlist in playlists['items']: - yield playlist['id'] - - if "nextPageToken" in playlists: - for item in self._getPlaylists(id, playlists['nextPageToken']): - yield item - - - def getPlaylists(self, ch_id): - return map(self.getPlaylist, self._getPlaylists(ch_id)) - - - def _getVideosId(self, id, token=None): - req = {"part": "contentDetails", "maxResults": "50", "playlistId": id} - if token: - req.update({"pageToken": token}) - - playlist = self.api_response("playlistItems", req) - - for item in playlist['items']: - yield item['contentDetails']['videoId'] - - if "nextPageToken" in playlist: - for item in self._getVideosId(id, playlist['nextPageToken']): - yield item - - - def getVideosId(self, p_id): - return list(self._getVideosId(p_id)) - - - def decrypt(self, pyfile): - m = re.match(self.__pattern__, pyfile.url) - m_id = m.group('ID') - m_type = m.group('TYPE') - - if m_type == "user": - self.logDebug("Url recognized as Channel") - user = m_id - channel = self.getChannel(user) - - if channel: - playlists = self.getPlaylists(channel['id']) - self.logDebug("%s playlist\s found on channel \"%s\"" % (len(playlists), channel['title'])) - - relatedplaylist = {p_name: self.getPlaylist(p_id) for p_name, p_id in channel['relatedPlaylists'].iteritems()} - self.logDebug("Channel's related playlists found = %s" % relatedplaylist.keys()) - - relatedplaylist['uploads']['title'] = "Unplaylisted videos" - relatedplaylist['uploads']['checkDups'] = True #: checkDups flag - - for p_name, p_data in relatedplaylist.iteritems(): - if self.getConfig(p_name): - p_data['title'] += " of " + user - playlists.append(p_data) - else: - playlists = [] - else: - self.logDebug("Url recognized as Playlist") - playlists = [self.getPlaylist(m_id)] - - if not playlists: - self.fail(_("No playlist available")) - - addedvideos = [] - urlize = lambda x: "https://www.youtube.com/watch?v=" + x - for p in playlists: - p_name = p['title'] - p_videos = self.getVideosId(p['id']) - p_folder = save_join(self.config['general']['download_folder'], p['channelTitle'], p_name) - self.logDebug("%s video\s found on playlist \"%s\"" % (len(p_videos), p_name)) - - if not p_videos: - continue - elif "checkDups" in p: - p_urls = [urlize(v_id) for v_id in p_videos if v_id not in addedvideos] - self.logDebug("%s video\s available on playlist \"%s\" after duplicates cleanup" % (len(p_urls), p_name)) - else: - p_urls = map(urlize, p_videos) - - self.packages.append((p_name, p_urls, p_folder)) #: folder is NOT recognized by pyload 0.4.9! - - addedvideos.extend(p_videos) diff --git a/module/plugins/crypter/YoutubeComFolder.py b/module/plugins/crypter/YoutubeComFolder.py new file mode 100644 index 000000000..628cf9428 --- /dev/null +++ b/module/plugins/crypter/YoutubeComFolder.py @@ -0,0 +1,148 @@ +# -*- coding: utf-8 -*- + +import re + +from urlparse import urljoin + +from module.common.json_layer import json_loads +from module.plugins.Crypter import Crypter +from module.utils import save_join + + +class YoutubeComFolder(Crypter): + __name__ = "YoutubeComFolder" + __type__ = "crypter" + __version__ = "1.01" + + __pattern__ = r'https?://(?:www\.|m\.)?youtube\.com/(?Puser|playlist|view_play_list)(/|.*?[?&](?:list|p)=)(?P[\w-]+)' + __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True), + ("likes", "bool", "Grab user (channel) liked videos", False), + ("favorites", "bool", "Grab user (channel) favorite videos", False), + ("uploads", "bool", "Grab channel unplaylisted videos", True)] + + __description__ = """Youtube.com channel & playlist decrypter plugin""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + API_KEY = "AIzaSyCKnWLNlkX-L4oD1aEzqqhRw1zczeD6_k0" + + + def api_response(self, ref, req): + req.update({"key": self.API_KEY}) + url = urljoin("https://www.googleapis.com/youtube/v3/", ref) + html = self.load(url, get=req) + return json_loads(html) + + + def getChannel(self, user): + channels = self.api_response("channels", {"part": "id,snippet,contentDetails", "forUsername": user, "maxResults": "50"}) + if channels['items']: + channel = channels['items'][0] + return {"id": channel['id'], + "title": channel['snippet']['title'], + "relatedPlaylists": channel['contentDetails']['relatedPlaylists'], + "user": user} # One lone channel for user? + + + def getPlaylist(self, p_id): + playlists = self.api_response("playlists", {"part": "snippet", "id": p_id}) + if playlists['items']: + playlist = playlists['items'][0] + return {"id": p_id, + "title": playlist['snippet']['title'], + "channelId": playlist['snippet']['channelId'], + "channelTitle": playlist['snippet']['channelTitle']} + + + def _getPlaylists(self, id, token=None): + req = {"part": "id", "maxResults": "50", "channelId": id} + if token: + req.update({"pageToken": token}) + + playlists = self.api_response("playlists", req) + + for playlist in playlists['items']: + yield playlist['id'] + + if "nextPageToken" in playlists: + for item in self._getPlaylists(id, playlists['nextPageToken']): + yield item + + + def getPlaylists(self, ch_id): + return map(self.getPlaylist, self._getPlaylists(ch_id)) + + + def _getVideosId(self, id, token=None): + req = {"part": "contentDetails", "maxResults": "50", "playlistId": id} + if token: + req.update({"pageToken": token}) + + playlist = self.api_response("playlistItems", req) + + for item in playlist['items']: + yield item['contentDetails']['videoId'] + + if "nextPageToken" in playlist: + for item in self._getVideosId(id, playlist['nextPageToken']): + yield item + + + def getVideosId(self, p_id): + return list(self._getVideosId(p_id)) + + + def decrypt(self, pyfile): + m = re.match(self.__pattern__, pyfile.url) + m_id = m.group('ID') + m_type = m.group('TYPE') + + if m_type == "user": + self.logDebug("Url recognized as Channel") + user = m_id + channel = self.getChannel(user) + + if channel: + playlists = self.getPlaylists(channel['id']) + self.logDebug("%s playlist\s found on channel \"%s\"" % (len(playlists), channel['title'])) + + relatedplaylist = {p_name: self.getPlaylist(p_id) for p_name, p_id in channel['relatedPlaylists'].iteritems()} + self.logDebug("Channel's related playlists found = %s" % relatedplaylist.keys()) + + relatedplaylist['uploads']['title'] = "Unplaylisted videos" + relatedplaylist['uploads']['checkDups'] = True #: checkDups flag + + for p_name, p_data in relatedplaylist.iteritems(): + if self.getConfig(p_name): + p_data['title'] += " of " + user + playlists.append(p_data) + else: + playlists = [] + else: + self.logDebug("Url recognized as Playlist") + playlists = [self.getPlaylist(m_id)] + + if not playlists: + self.fail(_("No playlist available")) + + addedvideos = [] + urlize = lambda x: "https://www.youtube.com/watch?v=" + x + for p in playlists: + p_name = p['title'] + p_videos = self.getVideosId(p['id']) + p_folder = save_join(self.config['general']['download_folder'], p['channelTitle'], p_name) + self.logDebug("%s video\s found on playlist \"%s\"" % (len(p_videos), p_name)) + + if not p_videos: + continue + elif "checkDups" in p: + p_urls = [urlize(v_id) for v_id in p_videos if v_id not in addedvideos] + self.logDebug("%s video\s available on playlist \"%s\" after duplicates cleanup" % (len(p_urls), p_name)) + else: + p_urls = map(urlize, p_videos) + + self.packages.append((p_name, p_urls, p_folder)) #: folder is NOT recognized by pyload 0.4.9! + + addedvideos.extend(p_videos) diff --git a/module/plugins/hoster/MediafireCom.py b/module/plugins/hoster/MediafireCom.py index 54df531bd..f9ad2502d 100644 --- a/module/plugins/hoster/MediafireCom.py +++ b/module/plugins/hoster/MediafireCom.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -import re - from module.plugins.internal.CaptchaService import SolveMedia from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -- cgit v1.2.3 From 9b8bd41059d87e120d2d64bc0e01e0a521ec1082 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 7 Mar 2015 03:32:50 +0100 Subject: New addon: AntiVirus --- module/plugins/hooks/AntiVirus.py | 85 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 module/plugins/hooks/AntiVirus.py (limited to 'module/plugins') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py new file mode 100644 index 000000000..4bb2396d9 --- /dev/null +++ b/module/plugins/hooks/AntiVirus.py @@ -0,0 +1,85 @@ +# -*- coding: utf-8 -*- + +import os +import subprocess + +from module.plugins.Hook import Hook, Expose, threaded +from module.utils import fs_encode, save_join + + +class AntiVirus(Hook): + __name__ = "AntiVirus" + __type__ = "hook" + __version__ = "0.01" + + __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), + ("quarpath" , "folder" , "Quarantine folder" , "" ), + ("scanfailed", "bool" , "Scan incompleted files (failed downloads)", False ), + ("cmdpath" , "file" , "Antivirus executable" , "" ), + ("cmdargs" , "str" , "Scan options" , "" )] + + __description__ = """Scan downloaded files with antivirus program""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + #@TODO: Remove in 0.4.10 + def initPeriodical(self): + pass + + + @Expose + @threaded + def scan(self, pyfile, thread): + name = os.path.basename(pyfile.plugin.lastDownload) + filename = fs_encode(pyfile.plugin.lastDownload) + cmdpath = fs_encode(self.getConfig('cmdpath')) + cmdargs = fs_encode(self.getConfig('cmdargs').strip()) + + if not os.path.isfile(filename) or not os.path.isfile(cmdpath): + return + + pyfile.setCustomStatus(_("virus scanning")) + thread.addActive(pyfile) + + try: + p = subprocess.Popen([cmdpath, cmdargs], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + out, err = map(str.strip, p.communicate()) + + if out: + self.logInfo(name, out) + + if err: + self.logWarning(name, err) + return + + if p.returncode: + action = self.getConfig('action') + try: + if action == "Delete": + os.remove(filename) + + elif action == "Quarantine": + new_filename = save_join(self.getConfig('quarpath'), name) + os.rename(filename, new_filename) + + except IOError, e: + self.logError(name, action + " action failed!", e) + + elif not out: + self.logDebug(name, "No virus found") + + finally: + thread.finishFile(pyfile) + + + def downloadFinished(self, pyfile): + return self.scan(pyfile) + + + def downloadFailed(self, pyfile): + #: Check if pyfile is still "failed", + # maybe might has been restarted in meantime + if pyfile.status == 8 and self.getConfig('scanfailed'): + return self.scan(pyfile) -- cgit v1.2.3 From c4f3a79f8ce19eab13ea7e53ff7a58fad43c6698 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 7 Mar 2015 03:39:08 +0100 Subject: [AntiVirus] Fix quarantine file moving --- module/plugins/hooks/AntiVirus.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index 4bb2396d9..c5d6b8321 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import os +import shutil import subprocess from module.plugins.Hook import Hook, Expose, threaded @@ -10,7 +11,7 @@ from module.utils import fs_encode, save_join class AntiVirus(Hook): __name__ = "AntiVirus" __type__ = "hook" - __version__ = "0.01" + __version__ = "0.02" __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), ("quarpath" , "folder" , "Quarantine folder" , "" ), @@ -62,9 +63,9 @@ class AntiVirus(Hook): elif action == "Quarantine": new_filename = save_join(self.getConfig('quarpath'), name) - os.rename(filename, new_filename) + shutil.move(filename, new_filename) - except IOError, e: + except (IOError, shutil.Error), e: self.logError(name, action + " action failed!", e) elif not out: -- cgit v1.2.3 From 3551cd44c7fad9cf5159d5920b6e8ec7aa3d1b9b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 7 Mar 2015 18:33:23 +0100 Subject: Spare code cosmetics --- module/plugins/hooks/AntiVirus.py | 45 +++++++++++++++++++++---------------- module/plugins/hooks/SkipRev.py | 4 ++-- module/plugins/internal/SevenZip.py | 9 ++++---- module/plugins/internal/UnRar.py | 14 ++++++------ 4 files changed, 39 insertions(+), 33 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index c5d6b8321..5dbc640ee 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -11,13 +11,14 @@ from module.utils import fs_encode, save_join class AntiVirus(Hook): __name__ = "AntiVirus" __type__ = "hook" - __version__ = "0.02" + __version__ = "0.03" __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), - ("quarpath" , "folder" , "Quarantine folder" , "" ), + ("quardir" , "folder" , "Quarantine folder" , "" ), ("scanfailed", "bool" , "Scan incompleted files (failed downloads)", False ), - ("cmdpath" , "file" , "Antivirus executable" , "" ), - ("cmdargs" , "str" , "Scan options" , "" )] + ("cmdfile" , "file" , "Antivirus executable" , "" ), + ("cmdargs" , "str" , "Scan options" , "" ), + ("ignore-err", "bool" , "Ignore scan errors" , False )] __description__ = """Scan downloaded files with antivirus program""" __license__ = "GPLv3" @@ -32,46 +33,52 @@ class AntiVirus(Hook): @Expose @threaded def scan(self, pyfile, thread): - name = os.path.basename(pyfile.plugin.lastDownload) - filename = fs_encode(pyfile.plugin.lastDownload) - cmdpath = fs_encode(self.getConfig('cmdpath')) + file = fs_encode(pyfile.plugin.lastDownload) + filename = os.path.basename(pyfile.plugin.lastDownload) + cmdfile = fs_encode(self.getConfig('cmdfile')) cmdargs = fs_encode(self.getConfig('cmdargs').strip()) - if not os.path.isfile(filename) or not os.path.isfile(cmdpath): + if not os.path.isfile(file) or not os.path.isfile(cmdfile): return - pyfile.setCustomStatus(_("virus scanning")) thread.addActive(pyfile) + pyfile.setCustomStatus(_("virus scanning")) try: - p = subprocess.Popen([cmdpath, cmdargs], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen([cmdfile, cmdargs], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = map(str.strip, p.communicate()) if out: - self.logInfo(name, out) + self.logInfo(filename, out) if err: - self.logWarning(name, err) - return + self.logWarning(filename, err) + if not self.getConfig('ignore-err') + self.logDebug("Delete/Quarantine action aborted") + return if p.returncode: + pyfile.error = _("infected file") action = self.getConfig('action') try: if action == "Delete": - os.remove(filename) + os.remove(file) elif action == "Quarantine": - new_filename = save_join(self.getConfig('quarpath'), name) - shutil.move(filename, new_filename) + pyfile.setCustomStatus(_("file moving")) + pyfile.setProgress(0) + new_filename = save_join(self.getConfig('quardir'), filename) + shutil.move(file, new_filename) except (IOError, shutil.Error), e: - self.logError(name, action + " action failed!", e) + self.logError(filename, action + " action failed!", e) - elif not out: - self.logDebug(name, "No virus found") + elif not out and not err: + self.logDebug(filename, "No infected file found") finally: + pyfile.setProgress(100) thread.finishFile(pyfile) diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index a4d46316e..521c2c39e 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -22,8 +22,8 @@ class SkipRev(Hook): __type__ = "hook" __version__ = "0.28" - __config__ = [("mode" , "Auto;Manual", "Choose rev files to keep for package", "Auto"), - ("revtokeep", "int" , "Custom number of files to keep" , 0 )] + __config__ = [("mode" , "Auto;Manual", "Choose rev files to skip for package", "Auto"), + ("revtokeep", "int" , "Number of rev files to keep" , 0 )] __description__ = """Skip files ending with extension rev""" __license__ = "GPLv3" diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index b5b113566..82901f8cc 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -2,8 +2,7 @@ import os import re - -from subprocess import Popen, PIPE +import subprocess from module.plugins.internal.UnRar import ArchiveError, CRCError, PasswordError, UnRar, renice from module.utils import fs_encode, save_join @@ -41,10 +40,10 @@ class SevenZip(UnRar): def isUsable(cls): if os.name == "nt": cls.CMD = os.path.join(pypath, "7z.exe") - p = Popen([cls.CMD], stdout=PIPE, stderr=PIPE) + p = subprocess.Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out,err = p.communicate() else: - p = Popen([cls.CMD], stdout=PIPE, stderr=PIPE) + p = subprocess.Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() m = cls.re_version.search(out) @@ -150,5 +149,5 @@ class SevenZip(UnRar): self.manager.logDebug(" ".join(call)) - p = Popen(call, stdout=PIPE, stderr=PIPE) + p = subprocess.Popen(call, stdout=subprocess.PIPE, stderr=subprocess.PIPE) return p diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index 220dd6365..baa5d3115 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -2,10 +2,10 @@ import os import re +import subprocess from glob import glob from string import digits -from subprocess import Popen, PIPE from module.plugins.internal.Extractor import Extractor, ArchiveError, CRCError, PasswordError from module.utils import fs_decode, fs_encode, save_join @@ -14,7 +14,7 @@ from module.utils import fs_decode, fs_encode, save_join def renice(pid, value): if value and os.name != "nt": try: - Popen(["renice", str(value), str(pid)], stdout=PIPE, stderr=PIPE, bufsize=-1) + subprocess.Popen(["renice", str(value), str(pid)], stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=-1) except Exception: pass @@ -52,24 +52,24 @@ class UnRar(Extractor): if os.name == "nt": try: cls.CMD = os.path.join(pypath, "RAR.exe") - p = Popen([cls.CMD], stdout=PIPE, stderr=PIPE) + p = subprocess.Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() cls.__name__ = "RAR" cls.REPAIR = True except OSError: cls.CMD = os.path.join(pypath, "UnRAR.exe") - p = Popen([cls.CMD], stdout=PIPE, stderr=PIPE) + p = Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() else: try: - p = Popen(["rar"], stdout=PIPE, stderr=PIPE) + p = Popen(["rar"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() cls.__name__ = "RAR" cls.REPAIR = True except OSError: #: fallback to unrar - p = Popen([cls.CMD], stdout=PIPE, stderr=PIPE) + p = Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() m = cls.re_version.search(out) @@ -244,5 +244,5 @@ class UnRar(Extractor): self.manager.logDebug(" ".join(call)) - p = Popen(call, stdout=PIPE, stderr=PIPE) + p = Popen(call, stdout=subprocess.PIPE, stderr=subprocess.PIPE) return p -- cgit v1.2.3 From 696ae23db1192f919961685f4026bb917b15868d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 7 Mar 2015 21:06:53 +0100 Subject: [AntiVirus] Missed something big! :P --- module/plugins/hooks/AntiVirus.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index 5dbc640ee..695852683 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -11,7 +11,7 @@ from module.utils import fs_encode, save_join class AntiVirus(Hook): __name__ = "AntiVirus" __type__ = "hook" - __version__ = "0.03" + __version__ = "0.04" __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), ("quardir" , "folder" , "Quarantine folder" , "" ), @@ -45,7 +45,7 @@ class AntiVirus(Hook): pyfile.setCustomStatus(_("virus scanning")) try: - p = subprocess.Popen([cmdfile, cmdargs], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen([cmdfile, cmdargs, file], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = map(str.strip, p.communicate()) -- cgit v1.2.3 From af353df35ef05b699f464ad2dca1b7b2bfe732e4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 8 Mar 2015 01:14:57 +0100 Subject: [ExternalScripts] Improve --- module/plugins/hooks/ExternalScripts.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index a09d5e92e..76444d4b3 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -4,16 +4,16 @@ import os import subprocess from module.plugins.Hook import Hook -from module.utils import save_join +from module.utils import fs_encode, save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.30" + __version__ = "0.31" __config__ = [("activated", "bool", "Activated" , True ), - ("wait" , "bool", "Wait script ending", False)] + ("waitend" , "bool", "Wait script ending", False)] __description__ = """Run external scripts""" __license__ = "GPLv3" @@ -50,7 +50,7 @@ class ExternalScripts(Hook): for script_type, names in self.scripts.iteritems(): if names: - self.logInfo(_("Installed scripts for"), script_type, ", ".join(map(os.path.basename, names))) + self.logInfo(_("Installed scripts for ") + script_type, ", ".join(map(os.path.basename, names))) def initPluginType(self, folder, path): @@ -58,28 +58,33 @@ class ExternalScripts(Hook): try: os.makedirs(path) - except Exception: - self.logDebug("Script folder %s not created" % folder) + except IOError, e: + self.logDebug(e) return - for f in os.listdir(path): - if f.startswith("#") or f.startswith(".") or f.startswith("_") or f.endswith("~") or f.endswith(".swp"): + for filename in os.listdir(path): + file = os.path.join(path, filename) + + if not os.path.isfile(file): + continue + + if filename[0] in ("#", "_") or filename.endswith("~") or filename.endswith(".swp"): continue - if not os.access(os.path.join(path, f), os.X_OK): - self.logWarning(_("Script not executable:") + " %s/%s" % (folder, f)) + if not os.access(file, os.X_OK): + self.logWarning(_("Script not executable:") + " %s/%s" % (folder, filename)) - self.scripts[folder].append(os.path.join(path, f)) + self.scripts[folder].append(file) def callScript(self, script, *args): try: - cmd = [script] + [(str(x) if not isinstance(x, basestring) else x).encode('utf-8') for x in args] + cmd = [(str(x) if not isinstance(x, basestring) else x).encode('utf-8') for x in args] self.logDebug("Executing", os.path.abspath(script), " ".join(cmd)) - p = subprocess.Popen(cmd, bufsize=-1) #@NOTE: output goes to pyload - if self.getConfig('wait'): + p = subprocess.Popen([script, fs_encode(cmd)], bufsize=-1) #@NOTE: output goes to pyload + if self.getConfig('waitend'): p.communicate() except Exception, e: -- cgit v1.2.3 From 6f77d9c783d1a51f4c320b15fad8a4edd3bda414 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 8 Mar 2015 20:38:07 +0100 Subject: [FileSharkPl] Fix https://github.com/pyload/pyload/issues/1040 (thx https://github.com/valdi74) --- module/plugins/hoster/FileSharkPl.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'module/plugins') diff --git a/module/plugins/hoster/FileSharkPl.py b/module/plugins/hoster/FileSharkPl.py index e4ce711bd..7e6130739 100644 --- a/module/plugins/hoster/FileSharkPl.py +++ b/module/plugins/hoster/FileSharkPl.py @@ -10,7 +10,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class FileSharkPl(SimpleHoster): __name__ = "FileSharkPl" __type__ = "hoster" - __version__ = "0.07" + __version__ = "0.08" __pattern__ = r'http://(?:www\.)?fileshark\.pl/pobierz/\d+/\w+' @@ -80,6 +80,8 @@ class FileSharkPl(SimpleHoster): link = urljoin("http://fileshark.pl", m.group(1)) + self.html = self.load(link, decode=True) + m = re.search(self.WAIT_PATTERN, self.html) if m: seconds = int(m.group(1)) -- cgit v1.2.3 From 6cf515ec73eefe0859a31f6b254de9ae54fc17ae Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 8 Mar 2015 20:39:55 +0100 Subject: [ZippyshareCom] Better lib import --- module/plugins/hoster/ZippyshareCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index c7a568e79..9d7c6949f 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -2,7 +2,7 @@ import re -from module.lib.BeautifulSoup import BeautifulSoup +from BeautifulSoup import BeautifulSoup from module.plugins.internal.CaptchaService import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -- cgit v1.2.3 From db330ae85f9de5a9a19c7141c1a2d6877e02e7da Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 8 Mar 2015 23:32:11 +0100 Subject: Update notify addon --- module/plugins/hooks/AndroidPhoneNotify.py | 53 +++++++++++++++++++----------- module/plugins/hooks/WindowsPhoneNotify.py | 52 ++++++++++++++++++----------- 2 files changed, 65 insertions(+), 40 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/AndroidPhoneNotify.py b/module/plugins/hooks/AndroidPhoneNotify.py index a3b24a255..7a9e6d6f8 100644 --- a/module/plugins/hooks/AndroidPhoneNotify.py +++ b/module/plugins/hooks/AndroidPhoneNotify.py @@ -1,27 +1,28 @@ # -*- coding: utf-8 -*- -from time import time +import time from module.network.RequestFactory import getURL -from module.plugins.Hook import Hook +from module.plugins.Hook import Hook, Expose class AndroidPhoneNotify(Hook): __name__ = "AndroidPhoneNotify" __type__ = "hook" - __version__ = "0.05" + __version__ = "0.06" __config__ = [("apikey" , "str" , "API key" , "" ), ("notifycaptcha" , "bool", "Notify captcha request" , True ), ("notifypackage" , "bool", "Notify package finished" , True ), - ("notifyprocessed", "bool", "Notify processed packages status" , True ), - ("timeout" , "int" , "Timeout between captchas in seconds" , 5 ), - ("force" , "bool", "Send notifications if client is connected", False)] + ("notifyprocessed", "bool", "Notify status of processed packages" , True ), + ("sendtimewait" , "int" , "Timewait in seconds between notifications", 5 ), + ("sendpermin" , "int" , "Max notifications per minute" , 12 ), + ("ignoreclient" , "bool", "Send notifications if client is connected", False)] - __description__ = """Send push notifications to your Android Phone using notifymyandroid.com""" + __description__ = """Send push notifications to your Android Phone (using notifymyandroid.com)""" __license__ = "GPLv3" - __authors__ = [("Steven Kosyra", "steven.kosyra@gmail.com"), - ("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("Steven Kosyra" , "steven.kosyra@gmail.com"), + ("Walter Purcaro", "vuolter@gmail.com" )] event_list = ["allDownloadsProcessed"] @@ -33,16 +34,14 @@ class AndroidPhoneNotify(Hook): def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - self.last_notify = 0 + self.info = {} #@TODO: Remove in 0.4.10 + self.last_notify = 0 + self.notifications = 0 def newCaptchaTask(self, task): if not self.getConfig("notifycaptcha"): - return False - - if time() - self.last_notify < self.getConf("timeout"): - return False + return self.notify(_("Captcha"), _("New request waiting user input")) @@ -54,7 +53,7 @@ class AndroidPhoneNotify(Hook): def allDownloadsProcessed(self): if not self.getConfig("notifyprocessed"): - return False + return if any(True for pdata in self.core.api.getQueue() if pdata.linksdone < pdata.linkstotal): self.notify(_("Package failed"), _("One or more packages was not completed successfully")) @@ -62,14 +61,27 @@ class AndroidPhoneNotify(Hook): self.notify(_("All packages finished")) + @Expose def notify(self, event, msg=""): apikey = self.getConfig("apikey") if not apikey: - return False + return + + if self.core.isClientConnected() and not self.getConfig("ignoreclient"): + return + + elapsed_time = time.time() - self.last_notify + + if elapsed_time < self.getConf("sendtimewait"): + return + + if elapsed_time > 60: + self.notifications = 0 + + elif self.notifications >= self.getConf("sendpermin"): + return - if self.core.isClientConnected() and not self.getConfig("force"): - return False getURL("http://www.notifymyandroid.com/publicapi/notify", get={'apikey' : apikey, @@ -77,4 +89,5 @@ class AndroidPhoneNotify(Hook): 'event' : event, 'description': msg}) - self.last_notify = time() + self.last_notify = time.time() + self.notifications += 1 diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index e0dd75f92..010198bf1 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -1,29 +1,29 @@ # -*- coding: utf-8 -*- import httplib +import time -from time import time - -from module.plugins.Hook import Hook +from module.plugins.Hook import Hook, Expose class WindowsPhoneNotify(Hook): __name__ = "WindowsPhoneNotify" __type__ = "hook" - __version__ = "0.07" + __version__ = "0.08" __config__ = [("id" , "str" , "Push ID" , "" ), ("url" , "str" , "Push url" , "" ), ("notifycaptcha" , "bool", "Notify captcha request" , True ), ("notifypackage" , "bool", "Notify package finished" , True ), - ("notifyprocessed", "bool", "Notify processed packages status" , True ), - ("timeout" , "int" , "Timeout between captchas in seconds" , 5 ), - ("force" , "bool", "Send notifications if client is connected", False)] + ("notifyprocessed", "bool", "Notify status of processed packages" , True ), + ("sendtimewait" , "int" , "Timewait in seconds between notifications", 5 ), + ("sendpermin" , "int" , "Max notifications per minute" , 12 ), + ("ignoreclient" , "bool", "Send notifications if client is connected", False)] __description__ = """Send push notifications to Windows Phone""" __license__ = "GPLv3" - __authors__ = [("Andy Voigt", "phone-support@hotmail.de"), - ("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("Andy Voigt" , "phone-support@hotmail.de"), + ("Walter Purcaro", "vuolter@gmail.com" )] event_list = ["allDownloadsProcessed"] @@ -35,16 +35,14 @@ class WindowsPhoneNotify(Hook): def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - self.last_notify = 0 + self.info = {} #@TODO: Remove in 0.4.10 + self.last_notify = 0 + self.notifications = 0 def newCaptchaTask(self, task): if not self.getConfig("notifycaptcha"): - return False - - if time() - self.last_notify < self.getConf("timeout"): - return False + return self.notify(_("Captcha"), _("New request waiting user input")) @@ -56,7 +54,7 @@ class WindowsPhoneNotify(Hook): def allDownloadsProcessed(self): if not self.getConfig("notifyprocessed"): - return False + return if any(True for pdata in self.core.api.getQueue() if pdata.linksdone < pdata.linkstotal): self.notify(_("Package failed"), _("One or more packages was not completed successfully")) @@ -70,15 +68,28 @@ class WindowsPhoneNotify(Hook): " " % msg) + @Expose def notify(self, event, msg=""): id = self.getConfig("id") url = self.getConfig("url") if not id or not url: - return False + return + + if self.core.isClientConnected() and not self.getConfig("ignoreclient"): + return + + elapsed_time = time.time() - self.last_notify + + if elapsed_time < self.getConf("sendtimewait"): + return + + if elapsed_time > 60: + self.notifications = 0 + + elif self.notifications >= self.getConf("sendpermin"): + return - if self.core.isClientConnected() and not self.getConfig("force"): - return False request = self.getXmlData("%s: %s" % (event, msg) if msg else event) webservice = httplib.HTTP(url) @@ -93,4 +104,5 @@ class WindowsPhoneNotify(Hook): webservice.send(request) webservice.close() - self.last_notify = time() + self.last_notify = time.time() + self.notifications += 1 -- cgit v1.2.3 From 6f7002bcc3520c47fafe5122b0e0cbada313887d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 8 Mar 2015 23:39:59 +0100 Subject: Whitespace cosmetics --- module/plugins/hooks/BypassCaptcha.py | 4 ++-- module/plugins/hooks/Captcha9Kw.py | 2 +- module/plugins/hooks/CaptchaBrotherhood.py | 2 +- module/plugins/hooks/Checksum.py | 6 +++--- module/plugins/hooks/ClickAndLoad.py | 2 +- module/plugins/hooks/DeathByCaptcha.py | 2 +- module/plugins/hooks/DebridItaliaCom.py | 4 ++-- module/plugins/hooks/ExpertDecoders.py | 2 +- module/plugins/hooks/ExternalScripts.py | 8 ++++---- module/plugins/hooks/ImageTyperz.py | 2 +- module/plugins/hooks/JustPremium.py | 6 +++--- module/plugins/hooks/PremiumTo.py | 2 +- module/plugins/hooks/ZeveraCom.py | 4 ++-- 13 files changed, 23 insertions(+), 23 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index cf8754dae..777564554 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -35,9 +35,9 @@ class BypassCaptcha(Hook): __description__ = """Send captchas to BypassCaptcha.com""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("Godofdream", "soilfcition@gmail.com"), - ("zoidberg", "zoidberg@mujmail.cz")] + ("zoidberg" , "zoidberg@mujmail.cz" )] PYLOAD_KEY = "4f771155b640970d5607f919a615bdefc67e7d32" diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py index 544965b0f..2b4f405ed 100644 --- a/module/plugins/hooks/Captcha9Kw.py +++ b/module/plugins/hooks/Captcha9Kw.py @@ -32,7 +32,7 @@ class Captcha9Kw(Hook): __description__ = """Send captchas to 9kw.eu""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("Walter Purcaro", "vuolter@gmail.com")] diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index 3c08f5e36..478138c3b 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -46,7 +46,7 @@ class CaptchaBrotherhood(Hook): __description__ = """Send captchas to CaptchaBrotherhood.com""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("zoidberg", "zoidberg@mujmail.cz")] diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 064375a41..7d08e6552 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -50,9 +50,9 @@ class Checksum(Hook): __description__ = """Verify downloaded file size and checksum""" __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), - ("Walter Purcaro", "vuolter@gmail.com"), - ("stickell", "l.stickell@yahoo.it")] + __authors__ = [("zoidberg" , "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com" ), + ("stickell" , "l.stickell@yahoo.it")] methods = {'sfv' : 'crc32', diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 938269795..2f5938101 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -32,7 +32,7 @@ class ClickAndLoad(Hook): __description__ = """Click'n'Load hook plugin""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.de"), + __authors__ = [("RaNaN" , "RaNaN@pyload.de" ), ("Walter Purcaro", "vuolter@gmail.com")] diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index d513c446d..a67e70c7e 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -59,7 +59,7 @@ class DeathByCaptcha(Hook): __description__ = """Send captchas to DeathByCaptcha.com""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("zoidberg", "zoidberg@mujmail.cz")] diff --git a/module/plugins/hooks/DebridItaliaCom.py b/module/plugins/hooks/DebridItaliaCom.py index 719f3dd3a..399f6462f 100644 --- a/module/plugins/hooks/DebridItaliaCom.py +++ b/module/plugins/hooks/DebridItaliaCom.py @@ -20,8 +20,8 @@ class DebridItaliaCom(MultiHook): __description__ = """Debriditalia.com hook plugin""" __license__ = "GPLv3" - __authors__ = [("stickell", "l.stickell@yahoo.it"), - ("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("stickell" , "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com" )] def getHosters(self): diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py index c9f8204c4..d6ecca680 100644 --- a/module/plugins/hooks/ExpertDecoders.py +++ b/module/plugins/hooks/ExpertDecoders.py @@ -21,7 +21,7 @@ class ExpertDecoders(Hook): __description__ = """Send captchas to expertdecoders.com""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("zoidberg", "zoidberg@mujmail.cz")] diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 76444d4b3..14387e234 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -17,9 +17,9 @@ class ExternalScripts(Hook): __description__ = """Run external scripts""" __license__ = "GPLv3" - __authors__ = [("mkaay", "mkaay@mkaay.de"), - ("RaNaN", "ranan@pyload.org"), - ("spoob", "spoob@pyload.org"), + __authors__ = [("mkaay" , "mkaay@mkaay.de" ), + ("RaNaN" , "ranan@pyload.org" ), + ("spoob" , "spoob@pyload.org" ), ("Walter Purcaro", "vuolter@gmail.com")] @@ -67,7 +67,7 @@ class ExternalScripts(Hook): if not os.path.isfile(file): continue - + if filename[0] in ("#", "_") or filename.endswith("~") or filename.endswith(".swp"): continue diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index d62fed385..b9dbfcdbe 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -40,7 +40,7 @@ class ImageTyperz(Hook): __description__ = """Send captchas to ImageTyperz.com""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("zoidberg", "zoidberg@mujmail.cz")] diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index daefbc30f..3064743e2 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -15,9 +15,9 @@ class JustPremium(Hook): __description__ = """Remove not-premium links from added urls""" __license__ = "GPLv3" - __authors__ = [("mazleu", "mazleica@gmail.com"), - ("Walter Purcaro", "vuolter@gmail.com"), - ("immenz", "immenz@gmx.net")] + __authors__ = [("mazleu" , "mazleica@gmail.com"), + ("Walter Purcaro", "vuolter@gmail.com" ), + ("immenz" , "immenz@gmx.net" )] event_list = ["linksAdded"] diff --git a/module/plugins/hooks/PremiumTo.py b/module/plugins/hooks/PremiumTo.py index b629b111e..250125016 100644 --- a/module/plugins/hooks/PremiumTo.py +++ b/module/plugins/hooks/PremiumTo.py @@ -18,7 +18,7 @@ class PremiumTo(MultiHook): __description__ = """Premium.to hook plugin""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("zoidberg", "zoidberg@mujmail.cz"), ("stickell", "l.stickell@yahoo.it")] diff --git a/module/plugins/hooks/ZeveraCom.py b/module/plugins/hooks/ZeveraCom.py index 215ec3673..33c49d8be 100644 --- a/module/plugins/hooks/ZeveraCom.py +++ b/module/plugins/hooks/ZeveraCom.py @@ -18,8 +18,8 @@ class ZeveraCom(MultiHook): __description__ = """Zevera.com hook plugin""" __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), - ("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("zoidberg" , "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com" )] def getHosters(self): -- cgit v1.2.3 From 04f2d0f9a377fcbabebd99c98ffc0638459acd6d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 9 Mar 2015 04:06:15 +0100 Subject: [ExternalScripts] Fixup --- module/plugins/hooks/ExternalScripts.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 14387e234..5f2790656 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -10,7 +10,7 @@ from module.utils import fs_encode, save_join class ExternalScripts(Hook): __name__ = "ExternalScripts" __type__ = "hook" - __version__ = "0.31" + __version__ = "0.32" __config__ = [("activated", "bool", "Activated" , True ), ("waitend" , "bool", "Wait script ending", False)] @@ -79,11 +79,11 @@ class ExternalScripts(Hook): def callScript(self, script, *args): try: - cmd = [(str(x) if not isinstance(x, basestring) else x).encode('utf-8') for x in args] + cmd = [script] + [(str(x) if not isinstance(x, basestring) else x).encode('utf-8') for x in args] self.logDebug("Executing", os.path.abspath(script), " ".join(cmd)) - p = subprocess.Popen([script, fs_encode(cmd)], bufsize=-1) #@NOTE: output goes to pyload + p = subprocess.Popen(cmd, bufsize=-1) #@NOTE: output goes to pyload if self.getConfig('waitend'): p.communicate() @@ -99,8 +99,8 @@ class ExternalScripts(Hook): def downloadFinished(self, pyfile): download_folder = self.config['general']['download_folder'] for script in self.scripts['download_finished']: - filename = save_join(download_folder, pyfile.package().folder, pyfile.name) - self.callScript(script, pyfile.pluginname, pyfile.url, pyfile.name, filename, pyfile.id) + file = save_join(download_folder, pyfile.package().folder, pyfile.name) + self.callScript(script, pyfile.pluginname, pyfile.url, pyfile.name, file, pyfile.id) def packageFinished(self, pypack): -- cgit v1.2.3 From 89b5cafa4e435d1b42b6bbfadd6c5c38dc9ab970 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 9 Mar 2015 17:28:34 +0100 Subject: [UnRar] Fix https://github.com/pyload/pyload/issues/1234 --- module/plugins/internal/UnRar.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index baa5d3115..45e1640bf 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -22,7 +22,7 @@ def renice(pid, value): class UnRar(Extractor): __name__ = "UnRar" - __version__ = "1.15" + __version__ = "1.16" __description__ = """Rar extractor plugin""" __license__ = "GPLv3" @@ -59,17 +59,17 @@ class UnRar(Extractor): except OSError: cls.CMD = os.path.join(pypath, "UnRAR.exe") - p = Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() else: try: - p = Popen(["rar"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen(["rar"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() cls.__name__ = "RAR" cls.REPAIR = True except OSError: #: fallback to unrar - p = Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() m = cls.re_version.search(out) @@ -244,5 +244,5 @@ class UnRar(Extractor): self.manager.logDebug(" ".join(call)) - p = Popen(call, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen(call, stdout=subprocess.PIPE, stderr=subprocess.PIPE) return p -- cgit v1.2.3 From 2d302677064dd5996add552ee214093c6d73acea Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 9 Mar 2015 18:20:24 +0100 Subject: Rename fileUrl to getFileURL --- module/plugins/hoster/BasePlugin.py | 6 +++--- module/plugins/internal/SimpleDereferer.py | 6 +++--- module/plugins/internal/SimpleHoster.py | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py index f9eb695ca..42bfed91e 100644 --- a/module/plugins/hoster/BasePlugin.py +++ b/module/plugins/hoster/BasePlugin.py @@ -6,14 +6,14 @@ from urllib import unquote from urlparse import urljoin, urlparse from module.network.HTTPRequest import BadHeader -from module.plugins.internal.SimpleHoster import create_getInfo, fileUrl +from module.plugins.internal.SimpleHoster import create_getInfo, getFileURL from module.plugins.Hoster import Hoster class BasePlugin(Hoster): __name__ = "BasePlugin" __type__ = "hoster" - __version__ = "0.34" + __version__ = "0.35" __pattern__ = r'^unmatchable$' @@ -51,7 +51,7 @@ class BasePlugin(Hoster): for _i in xrange(5): try: - link = fileUrl(self, unquote(pyfile.url)) + link = getFileURL(self, unquote(pyfile.url)) if link: self.download(link, ref=False, disposition=True) diff --git a/module/plugins/internal/SimpleDereferer.py b/module/plugins/internal/SimpleDereferer.py index bd00f5d25..577d56f75 100644 --- a/module/plugins/internal/SimpleDereferer.py +++ b/module/plugins/internal/SimpleDereferer.py @@ -5,13 +5,13 @@ import re from urllib import unquote from module.plugins.Crypter import Crypter -from module.plugins.internal.SimpleHoster import fileUrl, set_cookies +from module.plugins.internal.SimpleHoster import getFileURL, set_cookies class SimpleDereferer(Crypter): __name__ = "SimpleDereferer" __type__ = "crypter" - __version__ = "0.07" + __version__ = "0.08" __pattern__ = r'^unmatchable$' __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), @@ -45,7 +45,7 @@ class SimpleDereferer(Crypter): def decrypt(self, pyfile): - link = fileUrl(self, pyfile.url) + link = getFileURL(self, pyfile.url) if not link: try: diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index e4ff1a2d8..0adfc64b3 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -141,7 +141,7 @@ def timestamp(): #@TODO: Move to hoster class in 0.4.10 -def fileUrl(self, url, follow_location=None): +def getFileURL(self, url, follow_location=None): link = "" redirect = 1 @@ -246,7 +246,7 @@ def secondsToMidnight(gmt=0): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "1.15" + __version__ = "1.16" __pattern__ = r'^unmatchable$' @@ -311,7 +311,7 @@ class SimpleHoster(Hoster): LOGIN_ACCOUNT = False #: Set to True to require account login DISPOSITION = True #: Work-around to `filename*=UTF-8` bug; remove in 0.4.10 - directLink = fileUrl #@TODO: Remove in 0.4.10 + directLink = getFileURL #@TODO: Remove in 0.4.10 @classmethod @@ -349,7 +349,7 @@ class SimpleHoster(Hoster): info['error'] = "missing url" info['status'] = 1 - elif info['status'] is 3 and not fileUrl(None, url): + elif info['status'] is 3 and not getFileURL(None, url): try: html = getURL(url, cookies=cls.COOKIES, decode=not cls.TEXT_ENCODING) -- cgit v1.2.3 From 678f488777a94522ce8ba68f106428eefa037f50 Mon Sep 17 00:00:00 2001 From: sebdelsol Date: Mon, 9 Mar 2015 21:42:19 +0100 Subject: [ZippyShare] Bug #1238 correction * remove non ascii character from the id part in the js variable name. * change the RE so that it works for any character in the id name --- module/plugins/hoster/ZippyshareCom.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index 9d7c6949f..f2c99de7b 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -11,7 +11,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.74" + __version__ = "0.75" __pattern__ = r'http://www\d{0,2}\.zippyshare\.com/v(/|iew\.jsp.*key=)(?P[\w^_]+)' @@ -64,7 +64,7 @@ class ZippyshareCom(SimpleHoster): id = element.group(1) attr = element.group(4) #: attr might be None - varName = '%s_%s' % (id, attr) + varName = '%s_%s' % (re.sub(r'\W', '', id), attr) initValues = filter(None, [elt.get(attr, None) for elt in soup.findAll(id=id)]) initValue = '"%s"' % initValues[-1] if initValues else 'null' @@ -72,7 +72,7 @@ class ZippyshareCom(SimpleHoster): return varName # handle all getElementById - reVar = r'document.getElementById\([\'"](\w+)[\'"]\)(\.)?(getAttribute\([\'"])?(\w+)?([\'"]\))?' + reVar = r'document.getElementById\([\'"](.+)[\'"]\)(\.)?(getAttribute\([\'"])?(\w+)?([\'"]\))?' scripts = [re.sub(reVar, replElementById, script) for script in scripts] # add try/catch in JS to handle deliberate errors -- cgit v1.2.3 From 29dec4b608c8d2df3a4b963d17e652d20381b1b0 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 9 Mar 2015 22:45:21 +0100 Subject: [MultiHook] No freezes + better list error handling --- module/plugins/internal/MultiHook.py | 40 ++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 13 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/internal/MultiHook.py b/module/plugins/internal/MultiHook.py index 652443098..7e6462d9d 100644 --- a/module/plugins/internal/MultiHook.py +++ b/module/plugins/internal/MultiHook.py @@ -11,7 +11,7 @@ from module.utils import decode, remove_chars class MultiHook(Hook): __name__ = "MultiHook" __type__ = "hook" - __version__ = "0.37" + __version__ = "0.38" __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), @@ -27,7 +27,7 @@ class MultiHook(Hook): ("Walter Purcaro", "vuolter@gmail.com")] - MIN_INTERVAL = 1 * 60 * 60 + MIN_INTERVAL = 1 * 60 * 60 #: 1 hour DOMAIN_REPLACEMENTS = [(r'180upload\.com' , "hundredeightyupload.com"), (r'1fichier\.com' , "onefichier.com" ), @@ -119,17 +119,17 @@ class MultiHook(Hook): if self.plugins: return self.plugins - for _i in xrange(3): + for _i in xrange(2): try: pluginset = self._pluginSet(self.getHosters() if self.plugintype == "hoster" else self.getCrypters()) + break except Exception, e: - self.logError(e, "Waiting 1 minute and retry") + self.logDebug(e, "Waiting 1 minute and retry") sleep(60) - - else: - break else: + self.logWarning(_("Fallback to default reload interval due plugin")) + self.interval = self.MIN_INTERVAL return list() try: @@ -181,8 +181,28 @@ class MultiHook(Hook): raise NotImplementedError + #: Threaded _periodical, remove in 0.4.10 and use built-in flag for that + def _periodical(self): + try: + if self.isActivated(): + self.periodical() + + except Exception, e: + self.core.log.error(_("Error executing hooks: %s") % str(e)) + if self.core.debug: + print_exc() + + self.cb = self.core.scheduler.addJob(self.interval, self._periodical) + + def periodical(self): """reload plugin list periodically""" + if self.getConfig("reload", True): + self.interval = max(self.getConfig("reloadinterval", 12) * 60 * 60, self.MIN_INTERVAL) + else: + self.core.scheduler.removeJob(self.cb) + self.cb = None + self.logInfo(_("Reloading supported %s list") % self.plugintype) old_supported = self.supported @@ -200,12 +220,6 @@ class MultiHook(Hook): for plugin in old_supported: self.unloadPlugin(plugin) - if self.getConfig("reload", True): - self.interval = max(self.getConfig("reloadinterval", 12) * 60 * 60, self.MIN_INTERVAL) - else: - self.core.scheduler.removeJob(self.cb) - self.cb = None - def overridePlugins(self): excludedList = [] -- cgit v1.2.3 From 164ff94bd87b8b0de3c872b0b60153ac5abfad4b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 9 Mar 2015 23:26:18 +0100 Subject: [ExtractArchive] Fix https://github.com/pyload/pyload/issues/1241 --- module/plugins/hooks/ExtractArchive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 6a25602e8..edf25b8c7 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -108,7 +108,7 @@ class ArchiveQueue(object): class ExtractArchive(Hook): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.32" + __version__ = "1.33" __config__ = [("activated" , "bool" , "Activated" , True ), ("fullpath" , "bool" , "Extract with full paths" , True ), @@ -474,7 +474,7 @@ class ExtractArchive(Hook): print_exc() finally: - pyfile.finishIfDone() + thread.finishFile(pyfile) self.manager.dispatchEvent("archive_extract_failed", pyfile) -- cgit v1.2.3 From f85e28e565a1e0a76e6271d0b0853d6d48b4a043 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 10 Mar 2015 01:16:29 +0100 Subject: [MultiHook] Fix _pluginSet (fix LinkdecrypterCom issue) --- module/plugins/crypter/XFileSharingProFolder.py | 5 +-- module/plugins/hooks/LinkdecrypterCom.py | 4 +-- module/plugins/hoster/XFileSharingPro.py | 5 +-- module/plugins/internal/MultiHook.py | 48 +++++++++++++------------ 4 files changed, 30 insertions(+), 32 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/crypter/XFileSharingProFolder.py b/module/plugins/crypter/XFileSharingProFolder.py index 1d001772d..7d5cc9c6d 100644 --- a/module/plugins/crypter/XFileSharingProFolder.py +++ b/module/plugins/crypter/XFileSharingProFolder.py @@ -8,7 +8,7 @@ from module.plugins.internal.XFSCrypter import XFSCrypter, create_getInfo class XFileSharingProFolder(XFSCrypter): __name__ = "XFileSharingProFolder" __type__ = "crypter" - __version__ = "0.04" + __version__ = "0.05" __pattern__ = r'^unmatchable$' __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), @@ -33,9 +33,6 @@ class XFileSharingProFolder(XFSCrypter): self.HOSTER_DOMAIN = re.match(self.__pattern__, self.pyfile.url).group("DOMAIN").lower() self.HOSTER_NAME = "".join(part.capitalize() for part in re.split(r'(\.|\d+)', self.HOSTER_DOMAIN) if part != '.') - if self.HOSTER_NAME[0].isdigit(): - self.HOSTER_NAME = 'X' + self.HOSTER_NAME - account = self.core.accountManager.getAccountPlugin(self.HOSTER_NAME) if account and account.canUse(): diff --git a/module/plugins/hooks/LinkdecrypterCom.py b/module/plugins/hooks/LinkdecrypterCom.py index f85a598bc..769e63e81 100644 --- a/module/plugins/hooks/LinkdecrypterCom.py +++ b/module/plugins/hooks/LinkdecrypterCom.py @@ -8,7 +8,7 @@ from module.plugins.internal.MultiHook import MultiHook class LinkdecrypterCom(MultiHook): __name__ = "LinkdecrypterCom" __type__ = "hook" - __version__ = "1.02" + __version__ = "1.03" __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), @@ -22,4 +22,4 @@ class LinkdecrypterCom(MultiHook): def getCrypters(self): return re.search(r'>Supported\(\d+\): (.[\w.\-, ]+)', - self.getURL("http://linkdecrypter.com/").replace("(g)", "")).group(1).split(', ') + self.getURL("http://linkdecrypter.com/", decode=True).replace("(g)", "")).group(1).split(', ') diff --git a/module/plugins/hoster/XFileSharingPro.py b/module/plugins/hoster/XFileSharingPro.py index c66f25ad4..1bfb504b7 100644 --- a/module/plugins/hoster/XFileSharingPro.py +++ b/module/plugins/hoster/XFileSharingPro.py @@ -8,7 +8,7 @@ from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo class XFileSharingPro(XFSHoster): __name__ = "XFileSharingPro" __type__ = "hoster" - __version__ = "0.44" + __version__ = "0.45" __pattern__ = r'^unmatchable$' @@ -34,9 +34,6 @@ class XFileSharingPro(XFSHoster): self.HOSTER_DOMAIN = re.match(self.__pattern__, self.pyfile.url).group("DOMAIN").lower() self.HOSTER_NAME = "".join(part.capitalize() for part in re.split(r'(\.|\d+)', self.HOSTER_DOMAIN) if part != '.') - if self.HOSTER_NAME[0].isdigit(): - self.HOSTER_NAME = 'X' + self.HOSTER_NAME - account = self.core.accountManager.getAccountPlugin(self.HOSTER_NAME) if account and account.canUse(): diff --git a/module/plugins/internal/MultiHook.py b/module/plugins/internal/MultiHook.py index 7e6462d9d..e69f56c32 100644 --- a/module/plugins/internal/MultiHook.py +++ b/module/plugins/internal/MultiHook.py @@ -11,7 +11,7 @@ from module.utils import decode, remove_chars class MultiHook(Hook): __name__ = "MultiHook" __type__ = "hook" - __version__ = "0.38" + __version__ = "0.39" __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)" , "" ), @@ -23,16 +23,13 @@ class MultiHook(Hook): __description__ = """Hook plugin for multi hoster/crypter""" __license__ = "GPLv3" - __authors__ = [("pyLoad Team", "admin@pyload.org"), + __authors__ = [("pyLoad Team" , "admin@pyload.org" ), ("Walter Purcaro", "vuolter@gmail.com")] - MIN_INTERVAL = 1 * 60 * 60 #: 1 hour + MIN_RELOAD_INTERVAL = 1 * 60 * 60 #: 1 hour DOMAIN_REPLACEMENTS = [(r'180upload\.com' , "hundredeightyupload.com"), - (r'1fichier\.com' , "onefichier.com" ), - (r'2shared\.com' , "twoshared.com" ), - (r'4shared\.com' , "fourshared.com" ), (r'bayfiles\.net' , "bayfiles.com" ), (r'cloudnator\.com' , "shragle.com" ), (r'dfiles\.eu' , "depositfiles.com" ), @@ -48,7 +45,16 @@ class MultiHook(Hook): (r'uploaded\.net' , "uploaded.to" ), (r'uploadhero\.co' , "uploadhero.com" ), (r'zshares\.net' , "zshare.net" ), - (r'(\d+.+)' , "X\1" )] + (r'^1' , "one" ), + (r'^2' , "two" ), + (r'^3' , "three" ), + (r'^4' , "four" ), + (r'^5' , "five" ), + (r'^6' , "six" ), + (r'^7' , "seven" ), + (r'^8' , "eight" ), + (r'^9' , "nine" ), + (r'^0' , "zero" )] def setup(self): @@ -129,7 +135,7 @@ class MultiHook(Hook): sleep(60) else: self.logWarning(_("Fallback to default reload interval due plugin")) - self.interval = self.MIN_INTERVAL + self.interval = self.MIN_RELOAD_INTERVAL return list() try: @@ -152,17 +158,15 @@ class MultiHook(Hook): def _pluginSet(self, plugins): - plugins = set((decode(x).strip().lower() for x in plugins if '.' in x)) + regexp = re.compile(r'^[\w\-.^_]{3,63}\.[a-zA-Z]{2,}$', re.U) + plugins = [decode(p.strip()).lower() for p in plugins if regexp.match(p.strip())] - for rf, rt in self.DOMAIN_REPLACEMENTS: - regex = re.compile(rf) - for p in filter(lambda x: regex.match(x), plugins): - plugins.remove(p) - plugins.add(re.sub(rf, rt, p)) + for r in self.DOMAIN_REPLACEMENTS: + rf, rt = r + repr = re.compile(rf, re.I|re.U) + plugins = [re.sub(rf, rt, p) if repr.match(p) else p for p in plugins] - plugins.discard('') - - return plugins + return set(plugins) def getHosters(self): @@ -198,7 +202,7 @@ class MultiHook(Hook): def periodical(self): """reload plugin list periodically""" if self.getConfig("reload", True): - self.interval = max(self.getConfig("reloadinterval", 12) * 60 * 60, self.MIN_INTERVAL) + self.interval = max(self.getConfig("reloadinterval", 12) * 60 * 60, self.MIN_RELOAD_INTERVAL) else: self.core.scheduler.removeJob(self.cb) self.cb = None @@ -263,7 +267,7 @@ class MultiHook(Hook): self.logDebug("New %ss: %s" % (self.plugintype, ", ".join(plugins))) # create new regexp - regexp = r'.*(?P%s).*' % "|".join([x.replace(".", "\.") for x in plugins]) + regexp = r'.*(?P%s).*' % "|".join(x.replace('.', '\.') for x in plugins) if hasattr(self.pluginclass, "__pattern__") and isinstance(self.pluginclass.__pattern__, basestring) and '://' in self.pluginclass.__pattern__: regexp = r'%s|%s' % (self.pluginclass.__pattern__, regexp) @@ -277,11 +281,11 @@ class MultiHook(Hook): def unloadPlugin(self, plugin): hdict = self.core.pluginManager.plugins[self.plugintype][plugin] if "module" in hdict: - del hdict['module'] + hdict.pop('module', None) if "new_module" in hdict: - del hdict['new_module'] - del hdict['new_name'] + hdict.pop('new_module', None) + hdict.pop('new_name', None) def unload(self): -- cgit v1.2.3 From 415d543fe8ab9082b48cf0836565efbca65a9aa2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 10 Mar 2015 01:27:50 +0100 Subject: [DDLMusicOrg] Removed --- module/plugins/crypter/DDLMusicOrg.py | 51 ----------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 module/plugins/crypter/DDLMusicOrg.py (limited to 'module/plugins') diff --git a/module/plugins/crypter/DDLMusicOrg.py b/module/plugins/crypter/DDLMusicOrg.py deleted file mode 100644 index 55181e9ad..000000000 --- a/module/plugins/crypter/DDLMusicOrg.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from time import sleep - -from module.plugins.Crypter import Crypter - - -class DDLMusicOrg(Crypter): - __name__ = "DDLMusicOrg" - __type__ = "crypter" - __version__ = "0.30" - - __pattern__ = r'http://(?:www\.)?ddl-music\.org/captcha/ddlm_cr\d\.php\?\d+\?\d+' - __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), - ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] - - __description__ = """Ddl-music.org decrypter plugin""" - __license__ = "GPLv3" - __authors__ = [("mkaay", "mkaay@mkaay.de")] - - - def setup(self): - self.multiDL = False - - - def decrypt(self, pyfile): - html = self.load(pyfile.url, cookies=True) - - if re.search(r"Wer dies nicht rechnen kann", html) is not None: - self.offline() - - math = re.search(r"(\d+) ([+-]) (\d+) =\s+", htmlwithlink) - if m: - self.urls = [m.group(1)] - else: - self.retry() -- cgit v1.2.3 From 7beb65e991bc6d1913c3b5bb2ef69e659d5b8342 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 10 Mar 2015 01:55:52 +0100 Subject: Spare code cosmetics --- module/plugins/accounts/BitshareCom.py | 1 - module/plugins/accounts/FilesMailRu.py | 1 - module/plugins/accounts/FreakshareCom.py | 1 - module/plugins/accounts/NetloadIn.py | 2 +- module/plugins/accounts/OverLoadMe.py | 4 ++-- module/plugins/captcha/LinksaveIn.py | 12 +++++----- module/plugins/container/TXT.py | 4 ++-- module/plugins/crypter/EmbeduploadCom.py | 4 ++-- module/plugins/crypter/FilecryptCc.py | 12 +++++----- module/plugins/crypter/LinkdecrypterCom.py | 4 ++-- module/plugins/crypter/MultiloadCz.py | 4 ++-- module/plugins/hooks/AlldebridCom.py | 2 +- module/plugins/hooks/AndroidPhoneNotify.py | 18 ++++++++------- module/plugins/hooks/AntiVirus.py | 7 +++--- module/plugins/hooks/BypassCaptcha.py | 10 ++++----- module/plugins/hooks/Captcha9Kw.py | 36 +++++++++++++++--------------- module/plugins/hooks/CaptchaBrotherhood.py | 14 ++++++------ module/plugins/hooks/Checksum.py | 12 +++++----- module/plugins/hooks/ClickAndLoad.py | 2 +- module/plugins/hooks/DeathByCaptcha.py | 10 ++++----- module/plugins/hooks/DownloadScheduler.py | 4 ++-- module/plugins/hooks/ExpertDecoders.py | 10 ++++----- module/plugins/hooks/ExternalScripts.py | 19 ++++++++-------- module/plugins/hooks/HotFolder.py | 8 +++---- module/plugins/hooks/IRCInterface.py | 22 +++++++++--------- module/plugins/hooks/ImageTyperz.py | 18 +++++++-------- module/plugins/hooks/MultiHome.py | 2 +- module/plugins/hooks/OverLoadMe.py | 2 +- module/plugins/hooks/RealdebridCom.py | 2 +- module/plugins/hooks/RestartFailed.py | 8 +++---- module/plugins/hooks/RestartSlow.py | 4 ++-- module/plugins/hooks/SkipRev.py | 22 +++++++++--------- module/plugins/hooks/UnSkipOnFail.py | 2 +- module/plugins/hooks/UpdateManager.py | 16 ++++++------- module/plugins/hooks/WindowsPhoneNotify.py | 17 ++++++++------ module/plugins/hooks/XFileSharingPro.py | 14 ++++++------ module/plugins/hooks/XMPPInterface.py | 14 ++++++------ module/plugins/hoster/AlldebridCom.py | 2 +- module/plugins/hoster/BitshareCom.py | 2 +- module/plugins/hoster/CzshareCom.py | 6 ++--- module/plugins/hoster/DailymotionCom.py | 2 +- module/plugins/hoster/FileSharkPl.py | 2 +- module/plugins/hoster/FlyFilesNet.py | 2 +- module/plugins/hoster/GooIm.py | 2 +- module/plugins/hoster/IfolderRu.py | 12 +++++----- module/plugins/hoster/KingfilesNet.py | 4 ++-- module/plugins/hoster/LetitbitNet.py | 6 ++--- module/plugins/hoster/MegaDebridEu.py | 2 +- module/plugins/hoster/NetloadIn.py | 2 +- module/plugins/hoster/NosuploadCom.py | 4 ++-- module/plugins/hoster/OverLoadMe.py | 4 ++-- module/plugins/hoster/RealdebridCom.py | 2 +- module/plugins/hoster/UlozTo.py | 8 +++---- module/plugins/hoster/UnrestrictLi.py | 2 +- module/plugins/hoster/UploadableCh.py | 9 ++++---- module/plugins/hoster/VeohCom.py | 2 +- module/plugins/hoster/VimeoCom.py | 4 ++-- module/plugins/hoster/XHamsterCom.py | 4 ++-- module/plugins/hoster/YoutubeCom.py | 6 ++--- module/plugins/internal/Extractor.py | 6 ++--- module/plugins/internal/SevenZip.py | 4 ++-- module/plugins/internal/SimpleCrypter.py | 6 ++--- module/plugins/internal/SimpleHoster.py | 10 ++++----- module/plugins/internal/UnRar.py | 6 ++--- module/plugins/internal/XFSAccount.py | 4 ++-- module/plugins/internal/XFSHoster.py | 8 +++---- 66 files changed, 238 insertions(+), 239 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/accounts/BitshareCom.py b/module/plugins/accounts/BitshareCom.py index 412aae534..00e546f6d 100644 --- a/module/plugins/accounts/BitshareCom.py +++ b/module/plugins/accounts/BitshareCom.py @@ -28,7 +28,6 @@ class BitshareCom(Account): def login(self, user, data, req): html = req.load("http://bitshare.com/login.html", post={"user": user, "password": data['password'], "submit": "Login"}, - cookies=True, decode=True) if "login" in req.lastEffectiveURL: diff --git a/module/plugins/accounts/FilesMailRu.py b/module/plugins/accounts/FilesMailRu.py index 15926589e..ee309c425 100644 --- a/module/plugins/accounts/FilesMailRu.py +++ b/module/plugins/accounts/FilesMailRu.py @@ -25,7 +25,6 @@ class FilesMailRu(Account): "Login": user, "Password": data['password'], "Page": "http://files.mail.ru/"}, - cookies=True, decode=True) if "Неверное имя пользователя или пароль" in html: diff --git a/module/plugins/accounts/FreakshareCom.py b/module/plugins/accounts/FreakshareCom.py index 83f4a9a84..a1c7b5662 100644 --- a/module/plugins/accounts/FreakshareCom.py +++ b/module/plugins/accounts/FreakshareCom.py @@ -46,7 +46,6 @@ class FreakshareCom(Account): html = req.load("http://freakshare.com/login.html", post={"submit": "Login", "user": user, "pass": data['password']}, - cookies=True, decode=True) if ">Wrong Username or Password" in html: diff --git a/module/plugins/accounts/NetloadIn.py b/module/plugins/accounts/NetloadIn.py index 1abd7fa84..b86ace93b 100644 --- a/module/plugins/accounts/NetloadIn.py +++ b/module/plugins/accounts/NetloadIn.py @@ -38,7 +38,7 @@ class NetloadIn(Account): "txtpass" : data['password'], "txtcheck": "login", "txtlogin": "Login"}, - cookies=True, decode=True) + if "password or it might be invalid!" in html: self.wrongPassword() diff --git a/module/plugins/accounts/OverLoadMe.py b/module/plugins/accounts/OverLoadMe.py index d59944e63..64d04aded 100644 --- a/module/plugins/accounts/OverLoadMe.py +++ b/module/plugins/accounts/OverLoadMe.py @@ -15,7 +15,7 @@ class OverLoadMe(Account): def loadAccountInfo(self, user, req): - https = "https" if self.getConfig("ssl") else "http" + https = "https" if self.getConfig('ssl') else "http" data = self.getAccountData(user) html = req.load(https + "://api.over-load.me/account.php", get={'user': user, @@ -32,7 +32,7 @@ class OverLoadMe(Account): def login(self, user, data, req): - https = "https" if self.getConfig("ssl") else "http" + https = "https" if self.getConfig('ssl') else "http" jsondata = req.load(https + "://api.over-load.me/account.php", get={'user': user, 'auth': data['password']}).strip() diff --git a/module/plugins/captcha/LinksaveIn.py b/module/plugins/captcha/LinksaveIn.py index b5cb0f608..a7ae715fe 100644 --- a/module/plugins/captcha/LinksaveIn.py +++ b/module/plugins/captcha/LinksaveIn.py @@ -46,7 +46,7 @@ class LinksaveIn(OCR): pix = frame.load() for x in xrange(frame.size[0]): for y in xrange(frame.size[1]): - if lut[pix[x, y]] != (0,0,0): + if lut[pix[x, y]] != (0, 0, 0): npix[x, y] = lut[pix[x, y]] frame_nr += 1 new.save(self.data_dir+"unblacked.png") @@ -112,7 +112,7 @@ class LinksaveIn(OCR): rgb_bg = bglut[bgpix[x, y]] rgb_c = lut[pix[x, y]] if rgb_c == rgb_bg: - orgpix[x, y] = (255,255,255) + orgpix[x, y] = (255, 255, 255) def eval_black_white(self): @@ -126,13 +126,13 @@ class LinksaveIn(OCR): r, g, b = rgb pix[x, y] = (255,255,255) if r > max(b, g)+thresh: - pix[x, y] = (0,0,0) + pix[x, y] = (0, 0, 0) if g < min(r, b): - pix[x, y] = (0,0,0) + pix[x, y] = (0, 0, 0) if g > max(r, b)+thresh: - pix[x, y] = (0,0,0) + pix[x, y] = (0, 0, 0) if b > max(r, g)+thresh: - pix[x, y] = (0,0,0) + pix[x, y] = (0, 0, 0) self.image = new self.pixels = self.image.load() diff --git a/module/plugins/container/TXT.py b/module/plugins/container/TXT.py index 98ca426d7..d419ee060 100644 --- a/module/plugins/container/TXT.py +++ b/module/plugins/container/TXT.py @@ -23,7 +23,7 @@ class TXT(Container): def decrypt(self, pyfile): try: - encoding = codecs.lookup(self.getConfig("encoding")).name + encoding = codecs.lookup(self.getConfig('encoding')).name except Exception: encoding = "utf-8" @@ -57,7 +57,7 @@ class TXT(Container): if not value: packages.pop(key, None) - if self.getConfig("flush"): + if self.getConfig('flush'): try: txt = open(fs_filename, 'wb') txt.close() diff --git a/module/plugins/crypter/EmbeduploadCom.py b/module/plugins/crypter/EmbeduploadCom.py index 456e48a32..5336a0d03 100644 --- a/module/plugins/crypter/EmbeduploadCom.py +++ b/module/plugins/crypter/EmbeduploadCom.py @@ -30,7 +30,7 @@ class EmbeduploadCom(Crypter): m = re.findall(self.LINK_PATTERN, self.html) if m: - prefered_set = set(self.getConfig("preferedHoster").split('|')) + prefered_set = set(self.getConfig('preferedHoster').split('|')) prefered_set = map(lambda s: s.lower().split('.')[0], prefered_set) self.logDebug("PF: %s" % prefered_set) @@ -39,7 +39,7 @@ class EmbeduploadCom(Crypter): self.urls = self.getLocation(tmp_links) if not self.urls: - ignored_set = set(self.getConfig("ignoredHoster").split('|')) + ignored_set = set(self.getConfig('ignoredHoster').split('|')) ignored_set = map(lambda s: s.lower().split('.')[0], ignored_set) self.logDebug("IG: %s" % ignored_set) diff --git a/module/plugins/crypter/FilecryptCc.py b/module/plugins/crypter/FilecryptCc.py index d15d2ae4b..baea8886b 100644 --- a/module/plugins/crypter/FilecryptCc.py +++ b/module/plugins/crypter/FilecryptCc.py @@ -39,7 +39,7 @@ class FilecryptCc(Crypter): def decrypt(self, pyfile): - self.html = self.load(pyfile.url, cookies=True) + self.html = self.load(pyfile.url) if "content notfound" in self.html: #@NOTE: "content notfound" is NOT a typo self.offline() @@ -64,7 +64,7 @@ class FilecryptCc(Crypter): self.logInfo(_("Found %d mirrors") % len(mirror)) for i in mirror[1:]: - self.siteWithLinks = self.siteWithLinks + self.load(i, cookies=True).decode("utf-8", "replace") + self.siteWithLinks = self.siteWithLinks + self.load(i).decode("utf-8", "replace") def handlePasswordProtection(self): @@ -78,7 +78,7 @@ class FilecryptCc(Crypter): if not password: self.fail(_("Please enter the password in package section and try again")) - self.html = self.load(self.pyfile.url, post={"password": password}, cookies=True) + self.html = self.load(self.pyfile.url, post={"password": password}) def handleCaptcha(self): @@ -94,7 +94,6 @@ class FilecryptCc(Crypter): self.siteWithLinks = self.load(self.pyfile.url, post={'recaptcha_response_field': captcha_code}, - cookies=True, decode=True) elif m2: #: circle captcha self.logDebug("Captcha-URL: %s" % m2.group(1)) @@ -106,7 +105,6 @@ class FilecryptCc(Crypter): self.siteWithLinks = self.load(self.pyfile.url, post={'button.x': captcha_code[0], 'button.y': captcha_code[1]}, - cookies=True, decode=True) else: @@ -142,9 +140,9 @@ class FilecryptCc(Crypter): weblinks = re.findall(self.WEBLINK_PATTERN, self.siteWithLinks) for link in weblinks: - res = self.load("http://filecrypt.cc/Link/%s.html" % link, cookies=True) + res = self.load("http://filecrypt.cc/Link/%s.html" % link) link2 = re.search('', res) - res2 = self.load(link2.group(1), just_header=True, cookies=True) + res2 = self.load(link2.group(1), just_header=True) self.links.append(res2['location']) except Exception, e: diff --git a/module/plugins/crypter/LinkdecrypterCom.py b/module/plugins/crypter/LinkdecrypterCom.py index 7f24784c7..7dc174d66 100644 --- a/module/plugins/crypter/LinkdecrypterCom.py +++ b/module/plugins/crypter/LinkdecrypterCom.py @@ -34,7 +34,7 @@ class LinkdecrypterCom(Crypter): retries = 5 post_dict = {"link_cache": "on", "pro_links": pyfile.url, "modo_links": "text"} - self.html = self.load('http://linkdecrypter.com/', post=post_dict, cookies=True, decode=True) + self.html = self.load('http://linkdecrypter.com/', post=post_dict, decode=True) while retries: m = re.search(self.TEXTAREA_PATTERN, self.html, flags=re.S) @@ -65,4 +65,4 @@ class LinkdecrypterCom(Crypter): else: retries -= 1 - self.html = self.load('http://linkdecrypter.com/', cookies=True, decode=True) + self.html = self.load('http://linkdecrypter.com/', decode=True) diff --git a/module/plugins/crypter/MultiloadCz.py b/module/plugins/crypter/MultiloadCz.py index 55f424f36..006408c4b 100644 --- a/module/plugins/crypter/MultiloadCz.py +++ b/module/plugins/crypter/MultiloadCz.py @@ -34,9 +34,9 @@ class MultiloadCz(Crypter): else: m = re.findall(self.LINK_PATTERN, self.html) if m: - prefered_set = set(self.getConfig("usedHoster").split('|')) + prefered_set = set(self.getConfig('usedHoster').split('|')) self.urls.extend(x[1] for x in m if x[0] in prefered_set) if not self.urls: - ignored_set = set(self.getConfig("ignoredHoster").split('|')) + ignored_set = set(self.getConfig('ignoredHoster').split('|')) self.urls.extend(x[1] for x in m if x[0] not in ignored_set) diff --git a/module/plugins/hooks/AlldebridCom.py b/module/plugins/hooks/AlldebridCom.py index fd89571eb..517adcb68 100644 --- a/module/plugins/hooks/AlldebridCom.py +++ b/module/plugins/hooks/AlldebridCom.py @@ -23,7 +23,7 @@ class AlldebridCom(MultiHook): def getHosters(self): - https = "https" if self.getConfig("ssl") else "http" + https = "https" if self.getConfig('ssl') else "http" html = self.getURL(https + "://www.alldebrid.com/api.php", get={'action': "get_host"}).replace("\"", "").strip() return [x.strip() for x in html.split(",") if x.strip()] diff --git a/module/plugins/hooks/AndroidPhoneNotify.py b/module/plugins/hooks/AndroidPhoneNotify.py index 7a9e6d6f8..180ad0d78 100644 --- a/module/plugins/hooks/AndroidPhoneNotify.py +++ b/module/plugins/hooks/AndroidPhoneNotify.py @@ -40,19 +40,19 @@ class AndroidPhoneNotify(Hook): def newCaptchaTask(self, task): - if not self.getConfig("notifycaptcha"): + if not self.getConfig('notifycaptcha'): return self.notify(_("Captcha"), _("New request waiting user input")) def packageFinished(self, pypack): - if self.getConfig("notifypackage"): + if self.getConfig('notifypackage'): self.notify(_("Package finished"), pypack.name) def allDownloadsProcessed(self): - if not self.getConfig("notifyprocessed"): + if not self.getConfig('notifyprocessed'): return if any(True for pdata in self.core.api.getQueue() if pdata.linksdone < pdata.linkstotal): @@ -62,13 +62,15 @@ class AndroidPhoneNotify(Hook): @Expose - def notify(self, event, msg=""): - apikey = self.getConfig("apikey") + def notify(self, + event, + msg="", + key=self.getConfig('apikey')): - if not apikey: + if not key: return - if self.core.isClientConnected() and not self.getConfig("ignoreclient"): + if self.core.isClientConnected() and not self.getConfig('ignoreclient'): return elapsed_time = time.time() - self.last_notify @@ -84,7 +86,7 @@ class AndroidPhoneNotify(Hook): getURL("http://www.notifymyandroid.com/publicapi/notify", - get={'apikey' : apikey, + get={'apikey' : key, 'application': "pyLoad", 'event' : event, 'description': msg}) diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index 695852683..b8a659f99 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -13,7 +13,7 @@ class AntiVirus(Hook): __type__ = "hook" __version__ = "0.04" - __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), + __config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), #@TODO: add trash option (use Send2Trash lib) ("quardir" , "folder" , "Quarantine folder" , "" ), ("scanfailed", "bool" , "Scan incompleted files (failed downloads)", False ), ("cmdfile" , "file" , "Antivirus executable" , "" ), @@ -55,7 +55,7 @@ class AntiVirus(Hook): if err: self.logWarning(filename, err) if not self.getConfig('ignore-err') - self.logDebug("Delete/Quarantine action aborted") + self.logDebug("Delete/Quarantine task is aborted") return if p.returncode: @@ -68,8 +68,7 @@ class AntiVirus(Hook): elif action == "Quarantine": pyfile.setCustomStatus(_("file moving")) pyfile.setProgress(0) - new_filename = save_join(self.getConfig('quardir'), filename) - shutil.move(file, new_filename) + shutil.move(file, self.getConfig('quardir')) except (IOError, shutil.Error), e: self.logError(filename, action + " action failed!", e) diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index 777564554..d7995650b 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -57,7 +57,7 @@ class BypassCaptcha(Hook): def getCredits(self): - res = getURL(self.GETCREDITS_URL, post={"key": self.getConfig("passkey")}) + res = getURL(self.GETCREDITS_URL, post={"key": self.getConfig('passkey')}) data = dict(x.split(' ', 1) for x in res.splitlines()) return int(data['Left']) @@ -72,7 +72,7 @@ class BypassCaptcha(Hook): try: res = req.load(self.SUBMIT_URL, post={'vendor_key': self.PYLOAD_KEY, - 'key': self.getConfig("passkey"), + 'key': self.getConfig('passkey'), 'gen_task_id': "1", 'file': (FORM_FILE, captcha)}, multipart=True) @@ -92,7 +92,7 @@ class BypassCaptcha(Hook): def respond(self, ticket, success): try: - res = getURL(self.RESPOND_URL, post={"task_id": ticket, "key": self.getConfig("passkey"), + res = getURL(self.RESPOND_URL, post={"task_id": ticket, "key": self.getConfig('passkey'), "cv": 1 if success else 0}) except BadHeader, e: self.logError(_("Could not send response"), e) @@ -105,10 +105,10 @@ class BypassCaptcha(Hook): if not task.isTextual(): return False - if not self.getConfig("passkey"): + if not self.getConfig('passkey'): return False - if self.core.isClientConnected() and not self.getConfig("force"): + if self.core.isClientConnected() and not self.getConfig('force'): return False if self.getCredits() > 0: diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py index 2b4f405ed..6d42416ff 100644 --- a/module/plugins/hooks/Captcha9Kw.py +++ b/module/plugins/hooks/Captcha9Kw.py @@ -46,13 +46,13 @@ class Captcha9Kw(Hook): def setup(self): self.info = {} #@TODO: Remove in 0.4.10 - if self.getConfig("ssl"): + if self.getConfig('ssl'): self.API_URL = self.API_URL.replace("http://", "https://") def getCredits(self): res = getURL(self.API_URL, - get={'apikey': self.getConfig("passkey"), + get={'apikey': self.getConfig('passkey'), 'pyload': "1", 'source': "pyload", 'action': "usercaptchaguthaben"}) @@ -83,14 +83,14 @@ class Captcha9Kw(Hook): 'numeric' : 0, 'case_sensitive': 0, 'math' : 0, - 'prio' : min(max(self.getConfig("prio"), 0), 10), - 'confirm' : self.getConfig("confirm"), - 'timeout' : min(max(self.getConfig("timeout"), 300), 3999), - 'selfsolve' : self.getConfig("selfsolve"), - 'cph' : self.getConfig("captchaperhour"), - 'cpm' : self.getConfig("captchapermin")} + 'prio' : min(max(self.getConfig('prio'), 0), 10), + 'confirm' : self.getConfig('confirm'), + 'timeout' : min(max(self.getConfig('timeout'), 300), 3999), + 'selfsolve' : self.getConfig('selfsolve'), + 'cph' : self.getConfig('captchaperhour'), + 'cpm' : self.getConfig('captchapermin')} - for opt in str(self.getConfig("hoster_options").split('|')): + for opt in str(self.getConfig('hoster_options').split('|')): details = map(str.strip, opt.split(':')) @@ -109,7 +109,7 @@ class Captcha9Kw(Hook): break - post_data = {'apikey' : self.getConfig("passkey"), + post_data = {'apikey' : self.getConfig('passkey'), 'prio' : option['prio'], 'confirm' : option['confirm'], 'maxtimeout' : option['timeout'], @@ -146,9 +146,9 @@ class Captcha9Kw(Hook): task.data["ticket"] = res - for _i in xrange(int(self.getConfig("timeout") / 5)): + for _i in xrange(int(self.getConfig('timeout') / 5)): result = getURL(self.API_URL, - get={'apikey': self.getConfig("passkey"), + get={'apikey': self.getConfig('passkey'), 'id' : res, 'pyload': "1", 'info' : "1", @@ -172,10 +172,10 @@ class Captcha9Kw(Hook): if not task.isTextual() and not task.isPositional(): return - if not self.getConfig("passkey"): + if not self.getConfig('passkey'): return - if self.core.isClientConnected() and not self.getConfig("force"): + if self.core.isClientConnected() and not self.getConfig('force'): return credits = self.getCredits() @@ -184,8 +184,8 @@ class Captcha9Kw(Hook): self.logError(_("Your captcha 9kw.eu account has not enough credits")) return - queue = min(self.getConfig("queue"), 999) - timeout = min(max(self.getConfig("timeout"), 300), 3999) + queue = min(self.getConfig('queue'), 999) + timeout = min(max(self.getConfig('timeout'), 300), 3999) pluginname = re.search(r'_([^_]*)_\d+.\w+', task.captchaFile).group(1) for _i in xrange(5): @@ -197,7 +197,7 @@ class Captcha9Kw(Hook): else: self.fail(_("Too many captchas in queue")) - for opt in str(self.getConfig("hoster_options").split('|')): + for opt in str(self.getConfig('hoster_options').split('|')): details = map(str.strip, opt.split(':')) if not details or details[0].lower() != pluginname.lower(): @@ -227,7 +227,7 @@ class Captcha9Kw(Hook): self.logDebug("No CaptchaID for %s request (task: %s)" % (type, task)) return - passkey = self.getConfig("passkey") + passkey = self.getConfig('passkey') for _i in xrange(3): res = getURL(self.API_URL, diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index 478138c3b..5350b4f7d 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -64,7 +64,7 @@ class CaptchaBrotherhood(Hook): def getCredits(self): res = getURL(self.API_URL + "askCredits.aspx", - get={"username": self.getConfig("username"), "password": self.getConfig("passkey")}) + get={"username": self.getConfig('username'), "password": self.getConfig('passkey')}) if not res.startswith("OK"): raise CaptchaBrotherhoodException(res) else: @@ -93,8 +93,8 @@ class CaptchaBrotherhood(Hook): req = getRequest() url = "%ssendNewCaptcha.aspx?%s" % (self.API_URL, - urlencode({'username' : self.getConfig("username"), - 'password' : self.getConfig("passkey"), + urlencode({'username' : self.getConfig('username'), + 'password' : self.getConfig('passkey'), 'captchaSource': "pyLoad", 'timeout' : "80"})) @@ -127,8 +127,8 @@ class CaptchaBrotherhood(Hook): def api_response(self, api, ticket): res = getURL("%s%s.aspx" % (self.API_URL, api), - get={"username": self.getConfig("username"), - "password": self.getConfig("passkey"), + get={"username": self.getConfig('username'), + "password": self.getConfig('passkey'), "captchaID": ticket}) if not res.startswith("OK"): raise CaptchaBrotherhoodException("Unknown response: %s" % res) @@ -143,10 +143,10 @@ class CaptchaBrotherhood(Hook): if not task.isTextual(): return False - if not self.getConfig("username") or not self.getConfig("passkey"): + if not self.getConfig('username') or not self.getConfig('passkey'): return False - if self.core.isClientConnected() and not self.getConfig("force"): + if self.core.isClientConnected() and not self.getConfig('force'): return False if self.getCredits() > 10: diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 7d08e6552..9474f6968 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -70,7 +70,7 @@ class Checksum(Hook): def coreReady(self): - if not self.getConfig("check_checksum"): + if not self.getConfig('check_checksum'): self.logInfo(_("Checksum validation is disabled in plugin configuration")) @@ -125,7 +125,7 @@ class Checksum(Hook): data.pop('size', None) # validate checksum - if data and self.getConfig("check_checksum"): + if data and self.getConfig('check_checksum'): if not 'md5' in data: for type in ("checksum", "hashsum", "hash"): @@ -152,14 +152,14 @@ class Checksum(Hook): def checkFailed(self, pyfile, local_file, msg): - check_action = self.getConfig("check_action") + check_action = self.getConfig('check_action') if check_action == "retry": - max_tries = self.getConfig("max_tries") - retry_action = self.getConfig("retry_action") + max_tries = self.getConfig('max_tries') + retry_action = self.getConfig('retry_action') if pyfile.plugin.retries < max_tries: if local_file: remove(local_file) - pyfile.plugin.retry(max_tries, self.getConfig("wait_time"), msg) + pyfile.plugin.retry(max_tries, self.getConfig('wait_time'), msg) elif retry_action == "nothing": return elif check_action == "nothing": diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 2f5938101..731c8bd7e 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -45,7 +45,7 @@ class ClickAndLoad(Hook): if not self.config['webinterface']['activated']: return - ip = "" if self.getConfig("extern") else "127.0.0.1" + ip = "" if self.getConfig('extern') else "127.0.0.1" webport = self.config['webinterface']['port'] cnlport = self.getConfig('port') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index a67e70c7e..4eefb2bff 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -82,8 +82,8 @@ class DeathByCaptcha(Hook): if post: if not isinstance(post, dict): post = {} - post.update({"username": self.getConfig("username"), - "password": self.getConfig("passkey")}) + post.update({"username": self.getConfig('username'), + "password": self.getConfig('passkey')}) res = None try: @@ -136,7 +136,7 @@ class DeathByCaptcha(Hook): def submit(self, captcha, captchaType="file", match=None): #@NOTE: Workaround multipart-post bug in HTTPRequest.py - if re.match("^\w*$", self.getConfig("passkey")): + if re.match("^\w*$", self.getConfig('passkey')): multipart = True data = (FORM_FILE, captcha) else: @@ -172,10 +172,10 @@ class DeathByCaptcha(Hook): if not task.isTextual(): return False - if not self.getConfig("username") or not self.getConfig("passkey"): + if not self.getConfig('username') or not self.getConfig('passkey'): return False - if self.core.isClientConnected() and not self.getConfig("force"): + if self.core.isClientConnected() and not self.getConfig('force'): return False try: diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index 4996e212d..3b7ae524c 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -37,7 +37,7 @@ class DownloadScheduler(Hook): def updateSchedule(self, schedule=None): if schedule is None: - schedule = self.getConfig("timetable") + schedule = self.getConfig('timetable') schedule = re.findall("(\d{1,2}):(\d{2})[\s]*(-?\d+)", schedule.lower().replace("full", "-1").replace("none", "0")) @@ -65,7 +65,7 @@ class DownloadScheduler(Hook): def setDownloadSpeed(self, speed): if speed == 0: - abort = self.getConfig("abort") + abort = self.getConfig('abort') self.logInfo(_("Stopping download server. (Running downloads will %sbe aborted.)") % '' if abort else _('not ')) self.core.api.pauseServer() if abort: diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py index d6ecca680..fa1c7a14b 100644 --- a/module/plugins/hooks/ExpertDecoders.py +++ b/module/plugins/hooks/ExpertDecoders.py @@ -38,7 +38,7 @@ class ExpertDecoders(Hook): def getCredits(self): - res = getURL(self.API_URL, post={"key": self.getConfig("passkey"), "action": "balance"}) + res = getURL(self.API_URL, post={"key": self.getConfig('passkey'), "action": "balance"}) if res.isdigit(): self.logInfo(_("%s credits left") % res) @@ -64,7 +64,7 @@ class ExpertDecoders(Hook): try: result = req.load(self.API_URL, post={'action' : "upload", - 'key' : self.getConfig("passkey"), + 'key' : self.getConfig('passkey'), 'file' : b64encode(data), 'gen_task_id': ticket}) finally: @@ -78,10 +78,10 @@ class ExpertDecoders(Hook): if not task.isTextual(): return False - if not self.getConfig("passkey"): + if not self.getConfig('passkey'): return False - if self.core.isClientConnected() and not self.getConfig("force"): + if self.core.isClientConnected() and not self.getConfig('force'): return False if self.getCredits() > 0: @@ -98,7 +98,7 @@ class ExpertDecoders(Hook): try: res = getURL(self.API_URL, - post={'action': "refund", 'key': self.getConfig("passkey"), 'gen_task_id': task.data['ticket']}) + post={'action': "refund", 'key': self.getConfig('passkey'), 'gen_task_id': task.data['ticket']}) self.logInfo(_("Request refund"), res) except BadHeader, e: diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 5f2790656..d17e4740c 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -44,26 +44,25 @@ class ExternalScripts(Hook): for folder in folders: self.scripts[folder] = [] - - self.initPluginType(folder, os.path.join(pypath, 'scripts', folder)) - self.initPluginType(folder, os.path.join('scripts', folder)) + for dir in (pypath, ''): + self.initPluginType(folder, os.path.join(dir, 'scripts', folder)) for script_type, names in self.scripts.iteritems(): if names: self.logInfo(_("Installed scripts for ") + script_type, ", ".join(map(os.path.basename, names))) - def initPluginType(self, folder, path): - if not os.path.exists(path): + def initPluginType(self, name, dir): + if not os.path.isdir(dir): try: - os.makedirs(path) + os.makedirs(dir) except IOError, e: self.logDebug(e) return - for filename in os.listdir(path): - file = os.path.join(path, filename) + for filename in os.listdir(dir): + file = os.path.join(dir, filename) if not os.path.isfile(file): continue @@ -72,9 +71,9 @@ class ExternalScripts(Hook): continue if not os.access(file, os.X_OK): - self.logWarning(_("Script not executable:") + " %s/%s" % (folder, filename)) + self.logWarning(_("Script not executable:") + " %s/%s" % (name, filename)) - self.scripts[folder].append(file) + self.scripts[name].append(file) def callScript(self, script, *args): diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py index 302bc909f..a046e55e7 100644 --- a/module/plugins/hooks/HotFolder.py +++ b/module/plugins/hooks/HotFolder.py @@ -31,14 +31,14 @@ class HotFolder(Hook): def periodical(self): - folder = fs_encode(self.getConfig("folder")) - file = fs_encode(self.getConfig("file")) + folder = fs_encode(self.getConfig('folder')) + file = fs_encode(self.getConfig('file')) try: if not os.path.isdir(os.path.join(folder, "finished")): os.makedirs(os.path.join(folder, "finished")) - if self.getConfig("watch_file"): + if self.getConfig('watch_file'): with open(file, "a+") as f: f.seek(0) content = f.read().strip() @@ -60,7 +60,7 @@ class HotFolder(Hook): if not os.path.isfile(path) or f.endswith("~") or f.startswith("#") or f.startswith("."): continue - newpath = os.path.join(folder, "finished", f if self.getConfig("keep") else "tmp_" + f) + newpath = os.path.join(folder, "finished", f if self.getConfig('keep') else "tmp_" + f) move(path, newpath) self.logInfo(_("Added %s from HotFolder") % f) diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 623f2d1bf..1c90c0e2f 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -59,7 +59,7 @@ class IRCInterface(Thread, Hook): def packageFinished(self, pypack): try: - if self.getConfig("info_pack"): + if self.getConfig('info_pack'): self.response(_("Package finished: %s") % pypack.name) except Exception: pass @@ -67,7 +67,7 @@ class IRCInterface(Thread, Hook): def downloadFinished(self, pyfile): try: - if self.getConfig("info_file"): + if self.getConfig('info_file'): self.response( _("Download finished: %(name)s @ %(plugin)s ") % {"name": pyfile.name, "plugin": pyfile.pluginname}) except Exception: @@ -75,7 +75,7 @@ class IRCInterface(Thread, Hook): def newCaptchaTask(self, task): - if self.getConfig("captcha") and task.isTextual(): + if self.getConfig('captcha') and task.isTextual(): task.handler.append(self) task.setWaiting(60) @@ -90,16 +90,16 @@ class IRCInterface(Thread, Hook): def run(self): # connect to IRC etc. self.sock = socket.socket() - host = self.getConfig("host") - self.sock.connect((host, self.getConfig("port"))) + host = self.getConfig('host') + self.sock.connect((host, self.getConfig('port'))) - if self.getConfig("ssl"): + if self.getConfig('ssl'): self.sock = ssl.wrap_socket(self.sock, cert_reqs=ssl.CERT_NONE) #@TODO: support certificate - nick = self.getConfig("nick") + nick = self.getConfig('nick') self.sock.send("NICK %s\r\n" % nick) self.sock.send("USER %s %s bla :%s\r\n" % (nick, host, nick)) - for t in self.getConfig("owner").split(): + for t in self.getConfig('owner').split(): if t.strip().startswith("#"): self.sock.send("JOIN %s\r\n" % t.strip()) self.logInfo(_("Connected to"), host) @@ -153,10 +153,10 @@ class IRCInterface(Thread, Hook): def handle_events(self, msg): - if not msg['origin'].split("!", 1)[0] in self.getConfig("owner").split(): + if not msg['origin'].split("!", 1)[0] in self.getConfig('owner').split(): return - if msg['target'].split("!", 1)[0] != self.getConfig("nick"): + if msg['target'].split("!", 1)[0] != self.getConfig('nick'): return if msg['action'] != "PRIVMSG": @@ -197,7 +197,7 @@ class IRCInterface(Thread, Hook): def response(self, msg, origin=""): if origin == "": - for t in self.getConfig("owner").split(): + for t in self.getConfig('owner').split(): self.sock.send("PRIVMSG %s :%s\r\n" % (t.strip(), msg)) else: self.sock.send("PRIVMSG %s :%s\r\n" % (origin.split("!", 1)[0], msg)) diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index b9dbfcdbe..2cf611b9f 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -61,8 +61,8 @@ class ImageTyperz(Hook): def getCredits(self): res = getURL(self.GETCREDITS_URL, post={'action': "REQUESTBALANCE", - 'username': self.getConfig("username"), - 'password': self.getConfig("passkey")}) + 'username': self.getConfig('username'), + 'password': self.getConfig('passkey')}) if res.startswith('ERROR'): raise ImageTyperzException(res) @@ -83,7 +83,7 @@ class ImageTyperz(Hook): try: #@NOTE: Workaround multipart-post bug in HTTPRequest.py - if re.match("^\w*$", self.getConfig("passkey")): + if re.match("^\w*$", self.getConfig('passkey')): multipart = True data = (FORM_FILE, captcha) else: @@ -94,8 +94,8 @@ class ImageTyperz(Hook): res = req.load(self.SUBMIT_URL, post={'action': "UPLOADCAPTCHA", - 'username': self.getConfig("username"), - 'password': self.getConfig("passkey"), "file": data}, + 'username': self.getConfig('username'), + 'password': self.getConfig('passkey'), "file": data}, multipart=multipart) finally: req.close() @@ -119,10 +119,10 @@ class ImageTyperz(Hook): if not task.isTextual(): return False - if not self.getConfig("username") or not self.getConfig("passkey"): + if not self.getConfig('username') or not self.getConfig('passkey'): return False - if self.core.isClientConnected() and not self.getConfig("force"): + if self.core.isClientConnected() and not self.getConfig('force'): return False if self.getCredits() > 0: @@ -139,8 +139,8 @@ class ImageTyperz(Hook): if task.data['service'] == self.__name__ and "ticket" in task.data: res = getURL(self.RESPOND_URL, post={'action': "SETBADIMAGE", - 'username': self.getConfig("username"), - 'password': self.getConfig("passkey"), + 'username': self.getConfig('username'), + 'password': self.getConfig('passkey'), 'imageid': task.data['ticket']}) if res == "SUCCESS": diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index c9f6fc30c..9093c8459 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -25,7 +25,7 @@ class MultiHome(Hook): def setup(self): self.register = {} self.interfaces = [] - self.parseInterfaces(self.getConfig("interfaces").split(";")) + self.parseInterfaces(self.getConfig('interfaces').split(";")) if not self.interfaces: self.parseInterfaces([self.config['download']['interface']]) self.setConfig("interfaces", self.toConfig()) diff --git a/module/plugins/hooks/OverLoadMe.py b/module/plugins/hooks/OverLoadMe.py index b15ce2766..5e1040da7 100644 --- a/module/plugins/hooks/OverLoadMe.py +++ b/module/plugins/hooks/OverLoadMe.py @@ -23,7 +23,7 @@ class OverLoadMe(MultiHook): def getHosters(self): - https = "https" if self.getConfig("ssl") else "http" + https = "https" if self.getConfig('ssl') else "http" html = self.getURL(https + "://api.over-load.me/hoster.php", get={'auth': "0001-cb1f24dadb3aa487bda5afd3b76298935329be7700cd7-5329be77-00cf-1ca0135f"}).replace("\"", "").strip() self.logDebug("Hosterlist", html) diff --git a/module/plugins/hooks/RealdebridCom.py b/module/plugins/hooks/RealdebridCom.py index d9c9407dd..c97bc257c 100644 --- a/module/plugins/hooks/RealdebridCom.py +++ b/module/plugins/hooks/RealdebridCom.py @@ -23,7 +23,7 @@ class RealdebridCom(MultiHook): def getHosters(self): - https = "https" if self.getConfig("ssl") else "http" + https = "https" if self.getConfig('ssl') else "http" html = self.getURL(https + "://real-debrid.com/api/hosters.php").replace("\"", "").strip() return [x.strip() for x in html.split(",") if x.strip()] diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 07fb80967..7752b6a61 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -17,13 +17,13 @@ class RestartFailed(Hook): # event_list = ["pluginConfigChanged"] - MIN_INTERVAL = 15 * 60 #: 15m minimum check interval (value is in seconds) + MIN_CHECK_INTERVAL = 15 * 60 #: 15 minutes def pluginConfigChanged(self, plugin, name, value): if name == "interval": interval = value * 60 - if self.MIN_INTERVAL <= interval != self.interval: + if self.MIN_CHECK_INTERVAL <= interval != self.interval: self.core.scheduler.removeJob(self.cb) self.interval = interval self.initPeriodical() @@ -37,8 +37,8 @@ class RestartFailed(Hook): def setup(self): - self.interval = self.MIN_INTERVAL + self.interval = self.MIN_CHECK_INTERVAL def coreReady(self): - self.pluginConfigChanged(self.__name__, "interval", self.getConfig("interval")) + self.pluginConfigChanged(self.__name__, "interval", self.getConfig('interval')) diff --git a/module/plugins/hooks/RestartSlow.py b/module/plugins/hooks/RestartSlow.py index c3e1e5468..834128489 100644 --- a/module/plugins/hooks/RestartSlow.py +++ b/module/plugins/hooks/RestartSlow.py @@ -36,7 +36,7 @@ class RestartSlow(Hook): if not self.pyfile.plugin.req.dl: return - if self.getConfig("safe_mode") and not self.pyfile.plugin.resumeDownload: + if self.getConfig('safe_mode') and not self.pyfile.plugin.resumeDownload: time = 30 limit = 5 else: @@ -55,7 +55,7 @@ class RestartSlow(Hook): def downloadStarts(self, pyfile, url, filename): - if self.cb or (self.getConfig("safe_mode") and not pyfile.plugin.resumeDownload): + if self.cb or (self.getConfig('safe_mode') and not pyfile.plugin.resumeDownload): return self.pyfile = pyfile super(RestartSlow, self).initPeriodical() diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 521c2c39e..88ffb0103 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -11,16 +11,10 @@ from module.plugins.Hook import Hook from module.plugins.Plugin import SkipDownload -def _setup(self): - self.pyfile.plugin._setup() - if self.pyfile.hasStatus("skipped"): - raise SkipDownload(self.pyfile.statusname or self.pyfile.pluginname) - - class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.28" + __version__ = "0.29" __config__ = [("mode" , "Auto;Manual", "Choose rev files to skip for package", "Auto"), ("revtokeep", "int" , "Number of rev files to keep" , 0 )] @@ -35,6 +29,13 @@ class SkipRev(Hook): pass + @staticmethod + def _setup(self): + self.pyfile.plugin._setup() + if self.pyfile.hasStatus("skipped"): + raise SkipDownload(self.pyfile.statusname or self.pyfile.pluginname) + + def _name(self, pyfile): if hasattr(pyfile.pluginmodule, "getInfo"): #@NOTE: getInfo is deprecated in 0.4.10 return pyfile.pluginmodule.getInfo([pyfile.url]).next()[0] @@ -59,7 +60,7 @@ class SkipRev(Hook): def downloadPreparing(self, pyfile): name = self._name(pyfile) - if pyfile.statusname is "unskipped" or not name.endswith(".rev") or not ".part" in name: + if pyfile.statusname is _("unskipped") or not name.endswith(".rev") or not ".part" in name: return revtokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('revtokeep') @@ -77,8 +78,9 @@ class SkipRev(Hook): pyfile.setCustomStatus("SkipRev", "skipped") if not hasattr(pyfile.plugin, "_setup"): + # Work-around: inject status checker inside the preprocessing routine of the plugin pyfile.plugin._setup = pyfile.plugin.setup - pyfile.plugin.setup = MethodType(_setup, pyfile.plugin) #: work-around: inject status checker inside the preprocessing routine of the plugin + pyfile.plugin.setup = MethodType(self._setup, pyfile.plugin) def downloadFailed(self, pyfile): @@ -101,7 +103,7 @@ class SkipRev(Hook): if revtokeep > -1 or pyfile.name.endswith(".rev"): pylink.setStatus("queued") else: - pylink.setCustomStatus("unskipped", "queued") + pylink.setCustomStatus(_("unskipped"), "queued") self.core.files.save() pylink.release() diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index 1becb937a..7a5ae8e09 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -43,7 +43,7 @@ class UnSkipOnFail(Hook): # the core.files-manager to save its data. pylink = _pyfile(link) - pylink.setCustomStatus("UnSkipOnFail", "queued") + pylink.setCustomStatus(_("unskipped"), "queued") self.core.files.save() pylink.release() diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index a0b044edb..45d666f45 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -46,13 +46,13 @@ class UpdateManager(Hook): SERVER_URL = "http://updatemanager.pyload.org" VERSION = re.compile(r'__version__.*=.*("|\')([\d.]+)') - MIN_INTERVAL = 3 * 60 * 60 #: 3h minimum check interval (value is in seconds) + MIN_CHECK_INTERVAL = 3 * 60 * 60 #: 3 hours def pluginConfigChanged(self, plugin, name, value): if name == "interval": interval = value * 60 * 60 - if self.MIN_INTERVAL <= interval != self.interval: + if self.MIN_CHECK_INTERVAL <= interval != self.interval: self.core.scheduler.removeJob(self.cb) self.interval = interval self.initPeriodical() @@ -67,8 +67,8 @@ class UpdateManager(Hook): def coreReady(self): - self.pluginConfigChanged(self.__name__, "interval", self.getConfig("interval")) - x = lambda: self.pluginConfigChanged(self.__name__, "reloadplugins", self.getConfig("reloadplugins")) + self.pluginConfigChanged(self.__name__, "interval", self.getConfig('interval')) + x = lambda: self.pluginConfigChanged(self.__name__, "reloadplugins", self.getConfig('reloadplugins')) self.core.scheduler.addJob(10, x, threaded=False) @@ -78,7 +78,7 @@ class UpdateManager(Hook): def setup(self): self.cb2 = None - self.interval = self.MIN_INTERVAL + self.interval = self.MIN_CHECK_INTERVAL self.updating = False self.info = {'pyload': False, 'version': None, 'plugins': False} self.mtimes = {} #: store modification time for each plugin @@ -122,7 +122,7 @@ class UpdateManager(Hook): def periodical(self): - if not self.info['pyload'] and not (self.getConfig("nodebugupdate") and self.core.debug): + if not self.info['pyload'] and not (self.getConfig('nodebugupdate') and self.core.debug): self.updateThread() @@ -138,9 +138,9 @@ class UpdateManager(Hook): def updateThread(self): self.updating = True - status = self.update(onlyplugin=self.getConfig("mode") == "plugins only") + status = self.update(onlyplugin=self.getConfig('mode') == "plugins only") - if status is 2 and self.getConfig("autorestart"): + if status is 2 and self.getConfig('autorestart'): self.core.api.restart() else: self.updating = False diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index 010198bf1..a1068ead5 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -41,19 +41,19 @@ class WindowsPhoneNotify(Hook): def newCaptchaTask(self, task): - if not self.getConfig("notifycaptcha"): + if not self.getConfig('notifycaptcha'): return self.notify(_("Captcha"), _("New request waiting user input")) def packageFinished(self, pypack): - if self.getConfig("notifypackage"): + if self.getConfig('notifypackage'): self.notify(_("Package finished"), pypack.name) def allDownloadsProcessed(self): - if not self.getConfig("notifyprocessed"): + if not self.getConfig('notifyprocessed'): return if any(True for pdata in self.core.api.getQueue() if pdata.linksdone < pdata.linkstotal): @@ -69,14 +69,17 @@ class WindowsPhoneNotify(Hook): @Expose - def notify(self, event, msg=""): - id = self.getConfig("id") - url = self.getConfig("url") + def notify(self, + event, + msg="", + key=(self.getConfig('id'), self.getConfig('url'))): + + id, url = key if not id or not url: return - if self.core.isClientConnected() and not self.getConfig("ignoreclient"): + if self.core.isClientConnected() and not self.getConfig('ignoreclient'): return elapsed_time = time.time() - self.last_notify diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 495140652..d9552051e 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -8,7 +8,7 @@ from module.plugins.Hook import Hook class XFileSharingPro(Hook): __name__ = "XFileSharingPro" __type__ = "hook" - __version__ = "0.32" + __version__ = "0.33" __config__ = [("activated" , "bool", "Activated" , True ), ("use_hoster_list" , "bool", "Load listed hosters only" , False), @@ -23,15 +23,15 @@ class XFileSharingPro(Hook): # event_list = ["pluginConfigChanged"] - regexp = {'hoster' : (r'https?://(?:www\.)?(?P[\w.^_]+(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', + regexp = {'hoster' : (r'https?://(?:www\.)?(?P[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', r'https?://(?:[^/]+\.)?(?P%s)/(?:embed-)?\w+'), - 'crypter': (r'https?://(?:www\.)?(?P[\w.^_]+(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:user|folder)s?/\w+', + 'crypter': (r'https?://(?:www\.)?(?P[\w\-.^_]{3,63}(?:\.[a-zA-Z]{2,})(?:\:\d+)?)/(?:user|folder)s?/\w+', r'https?://(?:[^/]+\.)?(?P%s)/(?:user|folder)s?/\w+')} HOSTER_BUILTIN = [#WORKING HOSTERS: - "backin.net", "eyesfile.ca", "file4safe.com", "fileband.com", "filedwon.com", - "fileparadox.in", "filevice.com", "hostingbulk.com", "junkyvideo.com", "linestorage.com", "ravishare.com", - "ryushare.com", "salefiles.com", "sendmyway.com", "sharesix.com", "thefile.me", "verzend.be", "xvidstage.com", + "backin.net", "eyesfile.ca", "file4safe.com", "fileband.com", "filedwon.com", "fileparadox.in", + "filevice.com", "hostingbulk.com", "junkyvideo.com", "linestorage.com", "ravishare.com", "ryushare.com", + "salefiles.com", "sendmyway.com", "sharesix.com", "thefile.me", "verzend.be", "xvidstage.com", #NOT TESTED: "101shared.com", "4upfiles.com", "filemaze.ws", "filenuke.com", "linkzhost.com", "mightyupload.com", "rockdizfile.com", "sharebeast.com", "sharerepo.com", "shareswift.com", "uploadbaz.com", "uploadc.com", @@ -126,7 +126,7 @@ class XFileSharingPro(Hook): # def downloadFailed(self, pyfile): # if pyfile.pluginname == "BasePlugin" \ # and pyfile.hasStatus("failed") \ - # and not self.getConfig("use_hoster_list") \ + # and not self.getConfig('use_hoster_list') \ # and self.unloadHoster("BasePlugin"): # self.logDebug("Unloaded XFileSharingPro from BasePlugin") # pyfile.setStatus("queued") diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index b8e9fc1ad..b61428392 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -33,14 +33,14 @@ class XMPPInterface(IRCInterface, JabberClient): def __init__(self, core, manager): IRCInterface.__init__(self, core, manager) - self.jid = JID(self.getConfig("jid")) - password = self.getConfig("pw") + self.jid = JID(self.getConfig('jid')) + password = self.getConfig('pw') # if bare JID is provided add a resource -- it is required if not self.jid.resource: self.jid = JID(self.jid.node, self.jid.domain, "pyLoad") - if self.getConfig("tls"): + if self.getConfig('tls'): tls_settings = streamtls.TLSSettings(require=True, verify_peer=False) auth = ("sasl:PLAIN", "sasl:DIGEST-MD5") else: @@ -67,7 +67,7 @@ class XMPPInterface(IRCInterface, JabberClient): def packageFinished(self, pypack): try: - if self.getConfig("info_pack"): + if self.getConfig('info_pack'): self.announce(_("Package finished: %s") % pypack.name) except Exception: pass @@ -75,7 +75,7 @@ class XMPPInterface(IRCInterface, JabberClient): def downloadFinished(self, pyfile): try: - if self.getConfig("info_file"): + if self.getConfig('info_file'): self.announce( _("Download finished: %(name)s @ %(plugin)s") % {"name": pyfile.name, "plugin": pyfile.pluginname}) except Exception: @@ -139,7 +139,7 @@ class XMPPInterface(IRCInterface, JabberClient): to_name = to_jid.as_utf8() from_name = from_jid.as_utf8() - names = self.getConfig("owners").split(";") + names = self.getConfig('owners').split(";") if to_name in names or to_jid.node + "@" + to_jid.domain in names: messages = [] @@ -182,7 +182,7 @@ class XMPPInterface(IRCInterface, JabberClient): def announce(self, message): """ send message to all owners""" - for user in self.getConfig("owners").split(";"): + for user in self.getConfig('owners').split(";"): self.logDebug("Send message to", user) to_jid = JID(user) diff --git a/module/plugins/hoster/AlldebridCom.py b/module/plugins/hoster/AlldebridCom.py index 427eb42f0..90590adac 100644 --- a/module/plugins/hoster/AlldebridCom.py +++ b/module/plugins/hoster/AlldebridCom.py @@ -58,7 +58,7 @@ class AlldebridCom(MultiHoster): pyfile.size = parseFileSize(data['filesize']) self.link = data['link'] - if self.getConfig("ssl"): + if self.getConfig('ssl'): self.link = self.link.replace("http://", "https://") else: self.link = self.link.replace("https://", "http://") diff --git a/module/plugins/hoster/BitshareCom.py b/module/plugins/hoster/BitshareCom.py index 657e70e56..3bcc76146 100644 --- a/module/plugins/hoster/BitshareCom.py +++ b/module/plugins/hoster/BitshareCom.py @@ -80,7 +80,7 @@ class BitshareCom(SimpleHoster): def getDownloadUrl(self): # Return location if direct download is active if self.premium: - header = self.load(self.pyfile.url, cookies=True, just_header=True) + header = self.load(self.pyfile.url, just_header=True) if 'location' in header: return header['location'] diff --git a/module/plugins/hoster/CzshareCom.py b/module/plugins/hoster/CzshareCom.py index 49c7a6648..d055f49ba 100644 --- a/module/plugins/hoster/CzshareCom.py +++ b/module/plugins/hoster/CzshareCom.py @@ -43,7 +43,7 @@ class CzshareCom(SimpleHoster): m = re.search(self.USER_CREDIT_PATTERN, self.html) if m is None: self.account.relogin(self.user) - self.html = self.load(self.pyfile.url, cookies=True, decode=True) + self.html = self.load(self.pyfile.url, decode=True) m = re.search(self.USER_CREDIT_PATTERN, self.html) if m is None: return False @@ -87,7 +87,7 @@ class CzshareCom(SimpleHoster): self.logDebug("PARSED_URL:" + parsed_url) # get download ticket and parse html - self.html = self.load(parsed_url, cookies=True, decode=True) + self.html = self.load(parsed_url, decode=True) if re.search(self.MULTIDL_PATTERN, self.html): self.longWait(5 * 60, 12) @@ -104,7 +104,7 @@ class CzshareCom(SimpleHoster): captcha_url = 'http://sdilej.cz/captcha.php' for _i in xrange(5): inputs['captchastring2'] = self.decryptCaptcha(captcha_url) - self.html = self.load(parsed_url, cookies=True, post=inputs, decode=True) + self.html = self.load(parsed_url, post=inputs, decode=True) if u"
  • Zadaný ověřovací kód nesouhlasí!
  • " in self.html: self.invalidCaptcha() diff --git a/module/plugins/hoster/DailymotionCom.py b/module/plugins/hoster/DailymotionCom.py index 02df9dde7..c6939e5e5 100644 --- a/module/plugins/hoster/DailymotionCom.py +++ b/module/plugins/hoster/DailymotionCom.py @@ -72,7 +72,7 @@ class DailymotionCom(Hoster): def getQuality(self): - q = self.getConfig("quality") + q = self.getConfig('quality') if q == "Lowest": quality = 0 diff --git a/module/plugins/hoster/FileSharkPl.py b/module/plugins/hoster/FileSharkPl.py index 7e6130739..ac669ab1b 100644 --- a/module/plugins/hoster/FileSharkPl.py +++ b/module/plugins/hoster/FileSharkPl.py @@ -108,7 +108,7 @@ class FileSharkPl(SimpleHoster): self.load = tmp_load - self.download(link, post=inputs, cookies=True, disposition=True) + self.download(link, post=inputs, disposition=True) def checkFile(self): diff --git a/module/plugins/hoster/FlyFilesNet.py b/module/plugins/hoster/FlyFilesNet.py index 49705958d..636e02acf 100644 --- a/module/plugins/hoster/FlyFilesNet.py +++ b/module/plugins/hoster/FlyFilesNet.py @@ -32,7 +32,7 @@ class FlyFilesNet(SimpleHoster): url = "http://flyfiles.net" # get download URL - parsed_url = getURL(url, post={"getDownLink": session}, cookies=True) + parsed_url = getURL(url, post={"getDownLink": session}) self.logDebug("Parsed URL: %s" % parsed_url) if parsed_url == '#downlink|' or parsed_url == "#downlink|#": diff --git a/module/plugins/hoster/GooIm.py b/module/plugins/hoster/GooIm.py index 2cb012e50..1e1ffbc08 100644 --- a/module/plugins/hoster/GooIm.py +++ b/module/plugins/hoster/GooIm.py @@ -31,7 +31,7 @@ class GooIm(SimpleHoster): def handleFree(self, pyfile): self.wait(10) - self.download(pyfile.url, cookies=True) + self.download(pyfile.url) getInfo = create_getInfo(GooIm) diff --git a/module/plugins/hoster/IfolderRu.py b/module/plugins/hoster/IfolderRu.py index 249c2feb1..04c08ef0a 100644 --- a/module/plugins/hoster/IfolderRu.py +++ b/module/plugins/hoster/IfolderRu.py @@ -38,23 +38,23 @@ class IfolderRu(SimpleHoster): def handleFree(self, pyfile): - self.html = self.load("http://rusfolder.com/%s" % self.info['pattern']['ID'], cookies=True, decode=True) + self.html = self.load("http://rusfolder.com/%s" % self.info['pattern']['ID'], decode=True) self.getFileInfo() url = re.search(r"location\.href = '(http://ints\..*?=)'", self.html).group(1) - self.html = self.load(url, cookies=True, decode=True) + self.html = self.load(url, decode=True) url, session_id = re.search(self.SESSION_ID_PATTERN, self.html).groups() - self.html = self.load(url, cookies=True, decode=True) + self.html = self.load(url, decode=True) url = "http://ints.rusfolder.com/ints/frame/?session=%s" % session_id - self.html = self.load(url, cookies=True) + self.html = self.load(url) self.wait(31, False) captcha_url = "http://ints.rusfolder.com/random/images/?session=%s" % session_id for _i in xrange(5): - self.html = self.load(url, cookies=True) + self.html = self.load(url) action, inputs = self.parseHtmlForm('ID="Form1"') inputs['ints_session'] = re.search(self.INTS_SESSION_PATTERN, self.html).group(1) inputs[re.search(self.HIDDEN_INPUT_PATTERN, self.html).group(1)] = '1' @@ -62,7 +62,7 @@ class IfolderRu(SimpleHoster): inputs['action'] = '1' self.logDebug(inputs) - self.html = self.load(url, decode=True, cookies=True, post=inputs) + self.html = self.load(url, decode=True, post=inputs) if self.WRONG_CAPTCHA_PATTERN in self.html: self.invalidCaptcha() else: diff --git a/module/plugins/hoster/KingfilesNet.py b/module/plugins/hoster/KingfilesNet.py index 2d1c3b096..0030513cf 100644 --- a/module/plugins/hoster/KingfilesNet.py +++ b/module/plugins/hoster/KingfilesNet.py @@ -43,7 +43,7 @@ class KingfilesNet(SimpleHoster): 'referer' : "", 'method_free': "+"} - self.html = self.load(pyfile.url, post=post_data, cookies=True, decode=True) + self.html = self.load(pyfile.url, post=post_data, decode=True) solvemedia = SolveMedia(self) response, challenge = solvemedia.challenge() @@ -66,7 +66,7 @@ class KingfilesNet(SimpleHoster): 'adcopy_challenge': challenge, 'down_direct' : "1"} - self.html = self.load(pyfile.url, post=post_data, cookies=True, decode=True) + self.html = self.load(pyfile.url, post=post_data, decode=True) m = re.search(self.LINK_FREE_PATTERN, self.html) if m is None: diff --git a/module/plugins/hoster/LetitbitNet.py b/module/plugins/hoster/LetitbitNet.py index 2c725427d..273cea871 100644 --- a/module/plugins/hoster/LetitbitNet.py +++ b/module/plugins/hoster/LetitbitNet.py @@ -75,7 +75,7 @@ class LetitbitNet(SimpleHoster): self.logDebug(action, inputs) inputs['desc'] = "" - self.html = self.load(urljoin("http://letitbit.net/", action), post=inputs, cookies=True) + self.html = self.load(urljoin("http://letitbit.net/", action), post=inputs) m = re.search(self.SECONDS_PATTERN, self.html) seconds = int(m.group(1)) if m else 60 @@ -89,7 +89,7 @@ class LetitbitNet(SimpleHoster): self.wait(seconds) - res = self.load("http://letitbit.net/ajax/download3.php", post=" ", cookies=True) + res = self.load("http://letitbit.net/ajax/download3.php", post=" ") if res != '1': self.error(_("Unknown response - ajax_check_url")) @@ -104,7 +104,7 @@ class LetitbitNet(SimpleHoster): self.logDebug("Post data to send", post_data) - res = self.load("http://letitbit.net/ajax/check_recaptcha.php", post=post_data, cookies=True) + res = self.load("http://letitbit.net/ajax/check_recaptcha.php", post=post_data) self.logDebug(res) diff --git a/module/plugins/hoster/MegaDebridEu.py b/module/plugins/hoster/MegaDebridEu.py index b42362800..fa66e74e6 100644 --- a/module/plugins/hoster/MegaDebridEu.py +++ b/module/plugins/hoster/MegaDebridEu.py @@ -79,7 +79,7 @@ class MegaDebridEu(MultiHoster): exit the plugin on fail case And display the reason of this failure """ - if self.getConfig("unloadFailing"): + if self.getConfig('unloadFailing'): self.logError(_(msg)) self.resetAccount() else: diff --git a/module/plugins/hoster/NetloadIn.py b/module/plugins/hoster/NetloadIn.py index 3efbdce23..16728ad43 100644 --- a/module/plugins/hoster/NetloadIn.py +++ b/module/plugins/hoster/NetloadIn.py @@ -172,7 +172,7 @@ class NetloadIn(Hoster): self.url = self.get_file_url(page) - def check_free_wait(self,page): + def check_free_wait(self, page): if ">An access request has been made from IP address <" in page: self.wantReconnect = True self.setWait(self.get_wait_time(page) or 30) diff --git a/module/plugins/hoster/NosuploadCom.py b/module/plugins/hoster/NosuploadCom.py index aeedd54f6..241ee3a29 100644 --- a/module/plugins/hoster/NosuploadCom.py +++ b/module/plugins/hoster/NosuploadCom.py @@ -26,14 +26,14 @@ class NosuploadCom(XFSHoster): def getDownloadLink(self): # stage1: press the "Free Download" button data = self.getPostParameters() - self.html = self.load(self.pyfile.url, post=data, ref=True, decode=True) + self.html = self.load(self.pyfile.url, post=data, decode=True) # stage2: wait some time and press the "Download File" button data = self.getPostParameters() wait_time = re.search(self.WAIT_PATTERN, self.html, re.M | re.S).group(1) self.logDebug("Hoster told us to wait %s seconds" % wait_time) self.wait(wait_time) - self.html = self.load(self.pyfile.url, post=data, ref=True, decode=True) + self.html = self.load(self.pyfile.url, post=data, decode=True) # stage3: get the download link return re.search(self.LINK_PATTERN, self.html, re.S).group(1) diff --git a/module/plugins/hoster/OverLoadMe.py b/module/plugins/hoster/OverLoadMe.py index 67563ca3d..e92d927f3 100644 --- a/module/plugins/hoster/OverLoadMe.py +++ b/module/plugins/hoster/OverLoadMe.py @@ -39,7 +39,7 @@ class OverLoadMe(MultiHoster): def handlePremium(self, pyfile): - https = "https" if self.getConfig("ssl") else "http" + https = "https" if self.getConfig('ssl') else "http" data = self.account.getAccountData(self.user) page = self.load(https + "://api.over-load.me/getdownload.php", get={'auth': data['password'], @@ -58,7 +58,7 @@ class OverLoadMe(MultiHoster): pyfile.size = parseFileSize(data['filesize']) http_repl = ["http://", "https://"] - self.link = data['downloadlink'].replace(*http_repl if self.getConfig("ssl") else *http_repl[::-1]) + self.link = data['downloadlink'].replace(*http_repl if self.getConfig('ssl') else *http_repl[::-1]) if pyfile.name.startswith("http") or pyfile.name.startswith("Unknown") or pyfile.name.endswith('..'): # only use when name wasn't already set diff --git a/module/plugins/hoster/RealdebridCom.py b/module/plugins/hoster/RealdebridCom.py index d0010b3bd..14c46f522 100644 --- a/module/plugins/hoster/RealdebridCom.py +++ b/module/plugins/hoster/RealdebridCom.py @@ -58,7 +58,7 @@ class RealdebridCom(MultiHoster): pyfile.size = parseFileSize(data['file_size']) self.link = data['generated_links'][0][-1] - if self.getConfig("ssl"): + if self.getConfig('ssl'): self.link = self.link.replace("http://", "https://") else: self.link = self.link.replace("https://", "http://") diff --git a/module/plugins/hoster/UlozTo.py b/module/plugins/hoster/UlozTo.py index 3552942ff..035562962 100644 --- a/module/plugins/hoster/UlozTo.py +++ b/module/plugins/hoster/UlozTo.py @@ -46,7 +46,7 @@ class UlozTo(SimpleHoster): def process(self, pyfile): pyfile.url = re.sub(r"(?<=http://)([^/]+)", "www.ulozto.net", pyfile.url) - self.html = self.load(pyfile.url, decode=True, cookies=True) + self.html = self.load(pyfile.url, decode=True) if re.search(self.ADULT_PATTERN, self.html): self.logInfo(_("Adult content confirmation needed")) @@ -57,7 +57,7 @@ class UlozTo(SimpleHoster): token = m.group(1) self.html = self.load(pyfile.url, get={'do': "askAgeForm-submit"}, - post={"agree": "Confirm", "_token_": token}, cookies=True) + post={"agree": "Confirm", "_token_": token}) if self.PASSWD_PATTERN in self.html: password = self.getPassword() @@ -65,7 +65,7 @@ class UlozTo(SimpleHoster): if password: self.logInfo(_("Password protected link, trying ") + password) self.html = self.load(pyfile.url, get={'do': "passwordProtectedForm-submit"}, - post={"password": password, "password_send": 'Send'}, cookies=True) + post={"password": password, "password_send": 'Send'}) if self.PASSWD_PATTERN in self.html: self.fail(_("Incorrect password")) @@ -117,7 +117,7 @@ class UlozTo(SimpleHoster): self.error(_("CAPTCHA form changed")) self.multiDL = True - self.download("http://www.ulozto.net" + action, post=inputs, cookies=True, disposition=True) + self.download("http://www.ulozto.net" + action, post=inputs, disposition=True) def handlePremium(self, pyfile): diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py index 99fe01257..0a5c2081f 100644 --- a/module/plugins/hoster/UnrestrictLi.py +++ b/module/plugins/hoster/UnrestrictLi.py @@ -70,7 +70,7 @@ class UnrestrictLi(MultiHoster): def checkFile(self): super(UnrestrictLi, self).checkFile() - if self.getConfig("history"): + if self.getConfig('history'): self.load("https://unrestrict.li/history/", get={'delete': "all"}) self.logInfo(_("Download history deleted")) diff --git a/module/plugins/hoster/UploadableCh.py b/module/plugins/hoster/UploadableCh.py index 11cf3d321..d09b99d92 100644 --- a/module/plugins/hoster/UploadableCh.py +++ b/module/plugins/hoster/UploadableCh.py @@ -35,13 +35,13 @@ class UploadableCh(SimpleHoster): def handleFree(self, pyfile): # Click the "free user" button and wait - a = self.load(pyfile.url, cookies=True, post={'downloadLink': "wait"}, decode=True) + a = self.load(pyfile.url, post={'downloadLink': "wait"}, decode=True) self.logDebug(a) self.wait(30) # Make the recaptcha appear and show it the pyload interface - b = self.load(pyfile.url, cookies=True, post={'checkDownload': "check"}, decode=True) + b = self.load(pyfile.url, post={'checkDownload': "check"}, decode=True) self.logDebug(b) #: Expected output: {"success":"showCaptcha"} recaptcha = ReCaptcha(self) @@ -50,7 +50,6 @@ class UploadableCh(SimpleHoster): # Submit the captcha solution self.load("http://www.uploadable.ch/checkReCaptcha.php", - cookies=True, post={'recaptcha_challenge_field' : challenge, 'recaptcha_response_field' : response, 'recaptcha_shortencode_field': self.info['pattern']['ID']}, @@ -59,12 +58,12 @@ class UploadableCh(SimpleHoster): self.wait(3) # Get ready for downloading - self.load(pyfile.url, cookies=True, post={'downloadLink': "show"}, decode=True) + self.load(pyfile.url, post={'downloadLink': "show"}, decode=True) self.wait(3) # Download the file - self.download(pyfile.url, cookies=True, post={'download': "normal"}, disposition=True) + self.download(pyfile.url, post={'download': "normal"}, disposition=True) def checkFile(self): diff --git a/module/plugins/hoster/VeohCom.py b/module/plugins/hoster/VeohCom.py index 219efa8e1..567f8e867 100644 --- a/module/plugins/hoster/VeohCom.py +++ b/module/plugins/hoster/VeohCom.py @@ -33,7 +33,7 @@ class VeohCom(SimpleHoster): def handleFree(self, pyfile): - quality = self.getConfig("quality") + quality = self.getConfig('quality') if quality == "Auto": quality = ("High", "Low") diff --git a/module/plugins/hoster/VimeoCom.py b/module/plugins/hoster/VimeoCom.py index d427c1511..e47751c65 100644 --- a/module/plugins/hoster/VimeoCom.py +++ b/module/plugins/hoster/VimeoCom.py @@ -46,14 +46,14 @@ class VimeoCom(SimpleHoster): link = dict((l.group('QL').lower(), l.group('URL')) for l in re.finditer(pattern, html)) - if self.getConfig("original"): + if self.getConfig('original'): if "original" in link: self.download(link[q]) return else: self.logInfo(_("Original file not downloadable")) - quality = self.getConfig("quality") + quality = self.getConfig('quality') if quality == "Highest": qlevel = ("hd", "sd", "mobile") elif quality == "Lowest": diff --git a/module/plugins/hoster/XHamsterCom.py b/module/plugins/hoster/XHamsterCom.py index c6e789fa8..d68f46283 100644 --- a/module/plugins/hoster/XHamsterCom.py +++ b/module/plugins/hoster/XHamsterCom.py @@ -35,8 +35,8 @@ class XHamsterCom(Hoster): if not self.file_exists(): self.offline() - if self.getConfig("type"): - self.desired_fmt = self.getConfig("type") + if self.getConfig('type'): + self.desired_fmt = self.getConfig('type') pyfile.name = self.get_file_name() + self.desired_fmt self.download(self.get_file_url()) diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index d00bf2a0e..4fccbba65 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -95,7 +95,7 @@ class YoutubeCom(Hoster): self.tempOffline() #get config - use3d = self.getConfig("3d") + use3d = self.getConfig('3d') if use3d: quality = {"sd": 82, "hd": 84, "fullhd": 85, "240p": 83, "360p": 82, @@ -104,10 +104,10 @@ class YoutubeCom(Hoster): quality = {"sd": 18, "hd": 22, "fullhd": 37, "240p": 5, "360p": 18, "480p": 35, "720p": 22, "1080p": 37, "3072p": 38} - desired_fmt = self.getConfig("fmt") + desired_fmt = self.getConfig('fmt') if not desired_fmt: - desired_fmt = quality.get(self.getConfig("quality"), 18) + desired_fmt = quality.get(self.getConfig('quality'), 18) elif desired_fmt not in self.formats: self.logWarning(_("FMT %d unknown, using default") % desired_fmt) diff --git a/module/plugins/internal/Extractor.py b/module/plugins/internal/Extractor.py index 4b21cc49c..79864818e 100644 --- a/module/plugins/internal/Extractor.py +++ b/module/plugins/internal/Extractor.py @@ -23,9 +23,9 @@ class Extractor: __description__ = """Base extractor plugin""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "ranan@pyload.org"), + __authors__ = [("RaNaN" , "ranan@pyload.org" ), ("Walter Purcaro", "vuolter@gmail.com"), - ("Immenz", "immenz@gmx.net")] + ("Immenz" , "immenz@gmx.net" )] EXTENSIONS = [] @@ -40,7 +40,7 @@ class Extractor: @classmethod - def isMultipart(cls,filename): + def isMultipart(cls, filename): return False diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index 82901f8cc..482b1802c 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -14,7 +14,7 @@ class SevenZip(UnRar): __description__ = """7-Zip extractor plugin""" __license__ = "GPLv3" - __authors__ = [("Michael Nowak", ""), + __authors__ = [("Michael Nowak" , "" ), ("Walter Purcaro", "vuolter@gmail.com")] @@ -41,7 +41,7 @@ class SevenZip(UnRar): if os.name == "nt": cls.CMD = os.path.join(pypath, "7z.exe") p = subprocess.Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out,err = p.communicate() + out, err = p.communicate() else: p = subprocess.Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 856b548f0..696cc0848 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -20,9 +20,9 @@ class SimpleCrypter(Crypter, SimpleHoster): __description__ = """Simple decrypter plugin""" __license__ = "GPLv3" - __authors__ = [("stickell", "l.stickell@yahoo.it"), - ("zoidberg", "zoidberg@mujmail.cz"), - ("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("stickell" , "l.stickell@yahoo.it"), + ("zoidberg" , "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com" )] """ diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 0adfc64b3..df6e78485 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -153,11 +153,11 @@ def getFileURL(self, url, follow_location=None): for i in xrange(redirect): try: self.logDebug("Redirect #%d to: %s" % (i, url)) - header = self.load(url, ref=True, cookies=True, just_header=True, decode=True) + header = self.load(url, just_header=True, decode=True) except Exception: #: Bad bad bad... req = pyreq.getHTTPRequest() - res = req.load(url, cookies=True, just_header=True, decode=True) + res = req.load(url, just_header=True, decode=True) req.close() @@ -252,9 +252,9 @@ class SimpleHoster(Hoster): __description__ = """Simple hoster plugin""" __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), - ("stickell", "l.stickell@yahoo.it"), - ("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("zoidberg" , "zoidberg@mujmail.cz"), + ("stickell" , "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com" )] """ diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index 45e1640bf..2ba6ff90d 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -26,9 +26,9 @@ class UnRar(Extractor): __description__ = """Rar extractor plugin""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("Walter Purcaro", "vuolter@gmail.com"), - ("Immenz", "immenz@gmx.net"),] + ("Immenz" , "immenz@gmx.net" )] CMD = "unrar" @@ -79,7 +79,7 @@ class UnRar(Extractor): @classmethod - def isMultipart(cls,filename): + def isMultipart(cls, filename): multipart = cls.re_multipart.search(filename) if multipart: # First Multipart file (part1.rar for *.part1-9.rar format or *.rar for .r1-9 format) handled as normal Archive diff --git a/module/plugins/internal/XFSAccount.py b/module/plugins/internal/XFSAccount.py index 845ea3230..9315fb68f 100644 --- a/module/plugins/internal/XFSAccount.py +++ b/module/plugins/internal/XFSAccount.py @@ -16,8 +16,8 @@ class XFSAccount(Account): __description__ = """XFileSharing account plugin""" __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), - ("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("zoidberg" , "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com" )] HOSTER_DOMAIN = None diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py index c4fc969ba..e0c6d8824 100644 --- a/module/plugins/internal/XFSHoster.py +++ b/module/plugins/internal/XFSHoster.py @@ -22,9 +22,9 @@ class XFSHoster(SimpleHoster): __description__ = """XFileSharing hoster plugin""" __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), - ("stickell", "l.stickell@yahoo.it"), - ("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("zoidberg" , "zoidberg@mujmail.cz"), + ("stickell" , "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com" )] HOSTER_DOMAIN = None @@ -103,7 +103,7 @@ class XFSHoster(SimpleHoster): self.req.http.c.setopt(FOLLOWLOCATION, 0) - self.html = self.load(pyfile.url, post=data, ref=True, decode=True) + self.html = self.load(pyfile.url, post=data, decode=True) self.req.http.c.setopt(FOLLOWLOCATION, 1) -- cgit v1.2.3 From cfd5dcb231d55478442c7b80517064b377eda43d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 10 Mar 2015 03:01:47 +0100 Subject: [RapidgatorNet] Fix https://github.com/pyload/pyload/issues/1237 --- module/plugins/hoster/RapidgatorNet.py | 36 ++++++++++++--------------------- module/plugins/internal/SimpleHoster.py | 23 ++++++++++++++++----- 2 files changed, 31 insertions(+), 28 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hoster/RapidgatorNet.py b/module/plugins/hoster/RapidgatorNet.py index 7ec843646..761d7ff99 100644 --- a/module/plugins/hoster/RapidgatorNet.py +++ b/module/plugins/hoster/RapidgatorNet.py @@ -7,13 +7,13 @@ from pycurl import HTTPHEADER from module.common.json_layer import json_loads from module.network.HTTPRequest import BadHeader from module.plugins.internal.CaptchaService import AdsCaptcha, ReCaptcha, SolveMedia -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, secondsToMidnight +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class RapidgatorNet(SimpleHoster): __name__ = "RapidgatorNet" __type__ = "hoster" - __version__ = "0.32" + __version__ = "0.33" __pattern__ = r'http://(?:www\.)?(rapidgator\.net|rg\.to)/file/\w+' @@ -36,7 +36,7 @@ class RapidgatorNet(SimpleHoster): JSVARS_PATTERN = r'\s+var\s*(startTimerUrl|getDownloadUrl|captchaUrl|fid|secs)\s*=\s*\'?(.*?)\'?;' PREMIUM_ONLY_PATTERN = r'You can download files up to|This file can be downloaded by premium only<' - ERROR_PATTERN = r'You have reached your (daily|hourly) downloads limit' + ERROR_PATTERN = r'You have reached your (?:daily|hourly) downloads limit' WAIT_PATTERN = r'(Delay between downloads must be not less than|Try again in).+' LINK_FREE_PATTERN = r'return \'(http://\w+.rapidgator.net/.*)\';' @@ -125,8 +125,12 @@ class RapidgatorNet(SimpleHoster): self.link = m.group(1) break else: - captcha, captcha_key = self.handleCaptcha() - response, challenge = captcha.challenge(captcha_key) + captcha = self.handleCaptcha() + + if not captcha: + self.error(_("Captcha pattern not found")) + + response, challenge = captcha.challenge() self.html = self.load(url, post={'DownloadCaptchaForm[captcha]': "", 'adcopy_challenge' : challenge, @@ -141,24 +145,10 @@ class RapidgatorNet(SimpleHoster): def handleCaptcha(self): - m = re.search(self.ADSCAPTCHA_PATTERN, self.html) - if m: - captcha_key = m.group(1) - captcha = AdsCaptcha(self) - else: - m = re.search(self.RECAPTCHA_PATTERN, self.html) - if m: - captcha_key = m.group(1) - captcha = ReCaptcha(self) - else: - m = re.search(self.SOLVEMEDIA_PATTERN, self.html) - if m: - captcha_key = m.group(1) - captcha = SolveMedia(self) - else: - self.error(_("Captcha")) - - return captcha, captcha_key + for klass in (AdsCaptcha, ReCaptcha, SolveMedia): + inst = klass(self) + if inst.detect_key(): + return inst def getJsonResponse(self, url): diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index df6e78485..2754b0b18 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -237,7 +237,7 @@ def secondsToMidnight(gmt=0): if hasattr(td, 'total_seconds'): res = td.total_seconds() - else: #@NOTE: work-around for python 2.5 and 2.6 missing timedelta.total_seconds + else: #: 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) @@ -246,7 +246,7 @@ def secondsToMidnight(gmt=0): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "1.16" + __version__ = "1.17" __pattern__ = r'^unmatchable$' @@ -537,8 +537,22 @@ class SimpleHoster(Hoster): elif hasattr(self, 'ERROR_PATTERN'): m = re.search(self.ERROR_PATTERN, self.html) if m: - errmsg = self.info['error'] = m.group(1) - self.error(errmsg) + errmsg + try: + errmsg = m.group(1) + except Exception: + errmsg = m.group(0) + + self.info['error'] = errmsg + + if "hour" in errmsg + self.wait(secondsToMidnight(gmt=2), True) + + elif re.search("da(il)?y|today", errmsg): + self.wait(1 * 60 * 60, True) + + else: + self.error(errmsg) elif hasattr(self, 'WAIT_PATTERN'): m = re.search(self.WAIT_PATTERN, self.html) @@ -546,7 +560,6 @@ class SimpleHoster(Hoster): wait_time = sum(int(v) * {"hr": 3600, "hour": 3600, "min": 60, "sec": 1}[u.lower()] for v, u in re.findall(r'(\d+)\s*(hr|hour|min|sec)', m.group(0), re.I)) self.wait(wait_time, wait_time > 300) - return self.info.pop('error', None) -- cgit v1.2.3 From 5a5ca4b172aecdc5e637b47bef0e52ed121c7b05 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 10 Mar 2015 03:33:54 +0100 Subject: [UptoboxCom] TEMP_OFFLINE_PATTERN --- module/plugins/hoster/UptoboxCom.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hoster/UptoboxCom.py b/module/plugins/hoster/UptoboxCom.py index 3f79e509e..991bc640e 100644 --- a/module/plugins/hoster/UptoboxCom.py +++ b/module/plugins/hoster/UptoboxCom.py @@ -6,7 +6,7 @@ from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo class UptoboxCom(XFSHoster): __name__ = "UptoboxCom" __type__ = "hoster" - __version__ = "0.17" + __version__ = "0.18" __pattern__ = r'https?://(?:www\.)?(uptobox|uptostream)\.com/\w{12}' @@ -15,8 +15,9 @@ class UptoboxCom(XFSHoster): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - INFO_PATTERN = r'"para_title">(?P.+) \((?P[\d.,]+) (?P[\w^_]+)\)' - OFFLINE_PATTERN = r'>(File not found|Access Denied|404 Not Found)' + INFO_PATTERN = r'"para_title">(?P.+) \((?P[\d.,]+) (?P[\w^_]+)\)' + OFFLINE_PATTERN = r'>(File not found|Access Denied|404 Not Found)' + TEMP_OFFLINE_PATTERN = r'>Service Unavailable' LINK_PATTERN = r'"(https?://\w+\.uptobox\.com/d/.*?)"' -- cgit v1.2.3 From 3e81879d0c472c1079e75a12c7a8584f8304a8db Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 10 Mar 2015 03:35:47 +0100 Subject: [SimpleHoster] Fixup --- module/plugins/internal/SimpleHoster.py | 14 +++++++++----- module/plugins/internal/XFSHoster.py | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 2754b0b18..4777d0641 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -246,7 +246,7 @@ def secondsToMidnight(gmt=0): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "1.17" + __version__ = "1.18" __pattern__ = r'^unmatchable$' @@ -537,11 +537,10 @@ class SimpleHoster(Hoster): elif hasattr(self, 'ERROR_PATTERN'): m = re.search(self.ERROR_PATTERN, self.html) if m: - errmsg try: - errmsg = m.group(1) + errmsg = m.group(1).strip() except Exception: - errmsg = m.group(0) + errmsg = m.group(0).strip() self.info['error'] = errmsg @@ -557,8 +556,13 @@ class SimpleHoster(Hoster): elif hasattr(self, 'WAIT_PATTERN'): m = re.search(self.WAIT_PATTERN, self.html) if m: + try: + waitmsg = m.group(1).strip() + except Exception: + waitmsg = m.group(0).strip() + wait_time = sum(int(v) * {"hr": 3600, "hour": 3600, "min": 60, "sec": 1}[u.lower()] for v, u in - re.findall(r'(\d+)\s*(hr|hour|min|sec)', m.group(0), re.I)) + re.findall(r'(\d+)\s*(hr|hour|min|sec)', waitmsg, re.I)) self.wait(wait_time, wait_time > 300) self.info.pop('error', None) diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py index e0c6d8824..6e0b5e4ab 100644 --- a/module/plugins/internal/XFSHoster.py +++ b/module/plugins/internal/XFSHoster.py @@ -16,7 +16,7 @@ from module.utils import html_unescape class XFSHoster(SimpleHoster): __name__ = "XFSHoster" __type__ = "hoster" - __version__ = "0.44" + __version__ = "0.45" __pattern__ = r'^unmatchable$' @@ -195,7 +195,7 @@ class XFSHoster(SimpleHoster): if 'wait' in self.errmsg: wait_time = sum(int(v) * {"hr": 3600, "hour": 3600, "min": 60, "sec": 1}[u.lower()] for v, u in re.findall(r'(\d+)\s*(hr|hour|min|sec)', self.errmsg, re.I)) - self.wait(wait_time, True) + self.wait(wait_time, wait_time > 300) elif 'country' in self.errmsg: self.fail(_("Downloads are disabled for your country")) -- cgit v1.2.3 From badb1317968331206d409ec8abf0c40ffc980bf8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 10 Mar 2015 03:56:31 +0100 Subject: [SimpleHoster] Fix https://github.com/pyload/pyload/issues/1242 --- module/plugins/internal/SimpleHoster.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 4777d0641..b2c40a828 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -246,7 +246,7 @@ def secondsToMidnight(gmt=0): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "1.18" + __version__ = "1.19" __pattern__ = r'^unmatchable$' @@ -544,7 +544,7 @@ class SimpleHoster(Hoster): self.info['error'] = errmsg - if "hour" in errmsg + if "hour" in errmsg: self.wait(secondsToMidnight(gmt=2), True) elif re.search("da(il)?y|today", errmsg): -- cgit v1.2.3 From 58e98ab99bd7672492109786c4db7076d231631b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 10 Mar 2015 15:32:24 +0100 Subject: [FileSharkPl] Fix https://github.com/pyload/pyload/issues/1040 (2) --- module/plugins/hoster/FileSharkPl.py | 30 ++++++------------------------ module/plugins/internal/SimpleHoster.py | 5 ++++- 2 files changed, 10 insertions(+), 25 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hoster/FileSharkPl.py b/module/plugins/hoster/FileSharkPl.py index ac669ab1b..df54997d8 100644 --- a/module/plugins/hoster/FileSharkPl.py +++ b/module/plugins/hoster/FileSharkPl.py @@ -10,7 +10,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class FileSharkPl(SimpleHoster): __name__ = "FileSharkPl" __type__ = "hoster" - __version__ = "0.08" + __version__ = "0.09" __pattern__ = r'http://(?:www\.)?fileshark\.pl/pobierz/\d+/\w+' @@ -20,10 +20,9 @@ class FileSharkPl(SimpleHoster): ("Walter Purcaro", "vuolter@gmail.com")] - NAME_PATTERN = r'

    (?P.+)

    ' - SIZE_PATTERN = r'

    (.*?)(?P\d+\.?\d*)\s(?P\w+)

    ' - - OFFLINE_PATTERN = '(P|p)lik zosta. (usuni.ty|przeniesiony)' + NAME_PATTERN = r'

    (?P.+)

    ' + SIZE_PATTERN = r'

    (.*?)(?P\d+\.?\d*)\s(?P\w+)

    ' + OFFLINE_PATTERN = r'(P|p)lik zosta. (usuni.ty|przeniesiony)' LINK_FREE_PATTERN = r'' LINK_PREMIUM_PATTERN = r'' @@ -33,7 +32,7 @@ class FileSharkPl(SimpleHoster): IP_ERROR_PATTERN = r'Strona jest dost.pna wy..cznie dla u.ytkownik.w znajduj.cych si. na terenie Polski' SLOT_ERROR_PATTERN = r'Osi.gni.to maksymaln. liczb. .ci.ganych jednocze.nie plik.w\.' - CAPTCHA_PATTERN = '' @@ -80,7 +79,7 @@ class FileSharkPl(SimpleHoster): link = urljoin("http://fileshark.pl", m.group(1)) - self.html = self.load(link, decode=True) + self.html = self.load(link) m = re.search(self.WAIT_PATTERN, self.html) if m: @@ -111,23 +110,6 @@ class FileSharkPl(SimpleHoster): self.download(link, post=inputs, disposition=True) - def checkFile(self): - check = self.checkDownload({'wrong_captcha': re.compile(r''), - 'wait_pattern' : re.compile(self.SECONDS_PATTERN), - 'DL-found' : re.compile('')}) - if check == "DL-found": - self.correctCaptcha() - - elif check == "wrong_captcha": - self.invalidCaptcha() - self.retry(10, 1, _("Wrong captcha solution")) - - elif check == "wait_pattern": - self.retry() - - return super(FileSharkPl, self).checkFile() - - def _decode64(self, data, *args, **kwargs): return data.decode('base64') diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index b2c40a828..3a38c4eea 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -246,7 +246,7 @@ def secondsToMidnight(gmt=0): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "1.19" + __version__ = "1.20" __pattern__ = r'^unmatchable$' @@ -516,6 +516,9 @@ class SimpleHoster(Hoster): if hasattr(self, 'ERROR_PATTERN'): rules['error'] = re.compile(self.ERROR_PATTERN) + if hasattr(self, 'WAIT_PATTERN'): + rules['wait error'] = re.compile(self.WAIT_PATTERN) + check = self.checkDownload(rules) if check: #@TODO: Move to hoster in 0.4.10 errmsg = check.strip().capitalize() -- cgit v1.2.3 From 85bba1418987aa3e8b11a75a2732577da6008d8a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 10 Mar 2015 16:29:19 +0100 Subject: [FilerNet] Fix WAIT_PATTERN --- module/plugins/hoster/FilerNet.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hoster/FilerNet.py b/module/plugins/hoster/FilerNet.py index c5007e945..e790272f4 100644 --- a/module/plugins/hoster/FilerNet.py +++ b/module/plugins/hoster/FilerNet.py @@ -16,7 +16,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class FilerNet(SimpleHoster): __name__ = "FilerNet" __type__ = "hoster" - __version__ = "0.16" + __version__ = "0.17" __pattern__ = r'https?://(?:www\.)?filer\.net/get/\w+' @@ -29,17 +29,9 @@ class FilerNet(SimpleHoster): INFO_PATTERN = r'

    Free Download (?P\S+) (?P[\w.]+) (?P[\w^_]+)

    ' OFFLINE_PATTERN = r'Nicht gefunden' - LINK_FREE_PATTERN = LINK_PREMIUM_PATTERN = r'href="([^"]+)">Get download
    ' - + WAIT_PATTERN = r'musst du (\d+)' - def checkErrors(self): - # Wait between downloads - m = re.search(r'musst du (\d+) Sekunden warten', self.html) - if m: - errmsg = self.info['error'] = _("Wait between free downloads") - self.retry(wait_time=int(m.group(1)), reason=errmsg) - - self.info.pop('error', None) + LINK_FREE_PATTERN = LINK_PREMIUM_PATTERN = r'href="([^"]+)">Get download' def handleFree(self, pyfile): -- cgit v1.2.3 From ebb9910a25dbf0fc0d16242e9b4e9ffaa418656e Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 10 Mar 2015 20:01:17 +0100 Subject: [SimpleHoster] Improve checkFile routine --- module/plugins/internal/SimpleHoster.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 3a38c4eea..ac25423fc 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -246,7 +246,7 @@ def secondsToMidnight(gmt=0): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "1.20" + __version__ = "1.21" __pattern__ = r'^unmatchable$' @@ -499,7 +499,7 @@ class SimpleHoster(Hoster): self.download(link, ref=False, disposition=disposition) - def checkFile(self): + def checkFile(self, rules={}): if self.cTask and not self.lastDownload: self.invalidCaptcha() self.retry(10, reason=_("Wrong captcha")) @@ -509,24 +509,28 @@ class SimpleHoster(Hoster): self.error(self.pyfile.error or _("No file downloaded")) else: - rules = {'empty file': re.compile(r'\A\Z'), - 'html file' : re.compile(r'\A\s*)?\d{3}(\Z|\s+)')} + errmsg = self.checkDownload({'Empty file': re.compile(r'\A\s*\Z')}) - if hasattr(self, 'ERROR_PATTERN'): - rules['error'] = re.compile(self.ERROR_PATTERN) + if errmsg: + self.lastDownload = "" + else: + for r, p in [('html file' , re.compile(r'\A\s*)?\d{3}(\Z|\s+)'))]: + if r not in rules: + rules[r] = p - if hasattr(self, 'WAIT_PATTERN'): - rules['wait error'] = re.compile(self.WAIT_PATTERN) + for r, a in [('error' , 'ERROR_PATTERN'), + ('wait error', 'WAIT_PATTERN' )]: + if r not in rules and hasattr(self, a): + rules[r] = getattr(self, a) - check = self.checkDownload(rules) - if check: #@TODO: Move to hoster in 0.4.10 - errmsg = check.strip().capitalize() + errmsg = self.checkDownload(rules, delete=not self.core.debug).strip().capitalize() if self.lastCheck: errmsg += " | " + self.lastCheck.group(0).strip() - self.lastDownload = "" - self.retry(10, 60, errmsg) + if errmsg: + self.logWarning("Bad file", "Waiting 1 minute and retry") + self.retry(3, 60, errmsg) def checkErrors(self): -- cgit v1.2.3 From 7f357700f340db51a0de65a8dcc0726a6965ecd3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 10 Mar 2015 22:37:29 +0100 Subject: [SimpleHoster] Improve checkFile routine (2) --- module/plugins/internal/SimpleHoster.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index ac25423fc..393af86f5 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -246,7 +246,7 @@ def secondsToMidnight(gmt=0): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "1.21" + __version__ = "1.22" __pattern__ = r'^unmatchable$' @@ -509,24 +509,27 @@ class SimpleHoster(Hoster): self.error(self.pyfile.error or _("No file downloaded")) else: - errmsg = self.checkDownload({'Empty file': re.compile(r'\A\s*\Z')}) + errmsg = self.checkDownload({'Empty file': re.compile(r'\A\s*\Z'), + 'Html error': re.compile(r'\A(\s*<.+>)?([\w\s]*([Ee]rror|ERROR)\s*:?)?\s*\d{3}(\Z|\s+)')}) - if errmsg: - self.lastDownload = "" - else: - for r, p in [('html file' , re.compile(r'\A\s*)?\d{3}(\Z|\s+)'))]: + if not errmsg: + for r, p in [('Html file' , re.compile(r'\A\s* Date: Tue, 10 Mar 2015 22:38:17 +0100 Subject: [FilerNet] Fix https://github.com/pyload/pyload/issues/1201 --- module/plugins/hoster/FilerNet.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'module/plugins') diff --git a/module/plugins/hoster/FilerNet.py b/module/plugins/hoster/FilerNet.py index e790272f4..b8a97d6a1 100644 --- a/module/plugins/hoster/FilerNet.py +++ b/module/plugins/hoster/FilerNet.py @@ -16,7 +16,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class FilerNet(SimpleHoster): __name__ = "FilerNet" __type__ = "hoster" - __version__ = "0.17" + __version__ = "0.18" __pattern__ = r'https?://(?:www\.)?filer\.net/get/\w+' @@ -63,4 +63,10 @@ class FilerNet(SimpleHoster): self.invalidCaptcha() + def checkFile(self, rules={}): + if self.checkDownload({'Html file': re.compile(r'\A\s* Date: Tue, 10 Mar 2015 22:42:32 +0100 Subject: Update plugins after SimpleHoster changes --- module/plugins/hoster/AlldebridCom.py | 6 +++--- module/plugins/hoster/CzshareCom.py | 6 +++--- module/plugins/hoster/EuroshareEu.py | 6 +++--- module/plugins/hoster/FastixRu.py | 6 +++--- module/plugins/hoster/FastshareCz.py | 6 +++--- module/plugins/hoster/FilefactoryCom.py | 6 +++--- module/plugins/hoster/OverLoadMe.py | 6 +++--- module/plugins/hoster/PremiumTo.py | 6 +++--- module/plugins/hoster/RealdebridCom.py | 6 +++--- module/plugins/hoster/ShareonlineBiz.py | 6 +++--- module/plugins/hoster/SimplydebridCom.py | 6 +++--- module/plugins/hoster/SmoozedCom.py | 6 +++--- module/plugins/hoster/UnrestrictLi.py | 6 +++--- module/plugins/hoster/UploadableCh.py | 6 +++--- module/plugins/hoster/UploadedTo.py | 6 +++--- module/plugins/hoster/UploadheroCom.py | 10 +++++----- module/plugins/hoster/ZeveraCom.py | 6 +++--- 17 files changed, 53 insertions(+), 53 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hoster/AlldebridCom.py b/module/plugins/hoster/AlldebridCom.py index 90590adac..0a35ae2be 100644 --- a/module/plugins/hoster/AlldebridCom.py +++ b/module/plugins/hoster/AlldebridCom.py @@ -13,7 +13,7 @@ from module.utils import parseFileSize class AlldebridCom(MultiHoster): __name__ = "AlldebridCom" __type__ = "hoster" - __version__ = "0.44" + __version__ = "0.45" __pattern__ = r'https?://(?:www\.|s\d+\.)?alldebrid\.com/dl/[\w^_]+' @@ -68,11 +68,11 @@ class AlldebridCom(MultiHoster): pyfile.name = self.getFilename(self.link) - def checkFile(self): + def checkFile(self, rules={}): if self.checkDownload({'error': "An error occured while processing your request"}) == "error": self.retry(wait_time=60, reason=_("An error occured while generating link")) - return super(AlldebridCom, self).checkFile() + return super(AlldebridCom, self).checkFile(rules) getInfo = create_getInfo(AlldebridCom) diff --git a/module/plugins/hoster/CzshareCom.py b/module/plugins/hoster/CzshareCom.py index d055f49ba..34f52c05c 100644 --- a/module/plugins/hoster/CzshareCom.py +++ b/module/plugins/hoster/CzshareCom.py @@ -12,7 +12,7 @@ from module.utils import parseFileSize class CzshareCom(SimpleHoster): __name__ = "CzshareCom" __type__ = "hoster" - __version__ = "0.98" + __version__ = "0.99" __pattern__ = r'http://(?:www\.)?(czshare|sdilej)\.(com|cz)/(\d+/|download\.php\?).+' @@ -133,7 +133,7 @@ class CzshareCom(SimpleHoster): self.wait() - def checkFile(self): + def checkFile(self, rules={}): # check download check = self.checkDownload({ "temp offline" : re.compile(r"^Soubor je do.*asn.* nedostupn.*$"), @@ -155,7 +155,7 @@ class CzshareCom(SimpleHoster): self.invalidCaptcha() self.retry() - return super(CzshareCom, self).checkFile() + return super(CzshareCom, self).checkFile(rules) getInfo = create_getInfo(CzshareCom) diff --git a/module/plugins/hoster/EuroshareEu.py b/module/plugins/hoster/EuroshareEu.py index b4c9ace6a..9b71ddfc1 100644 --- a/module/plugins/hoster/EuroshareEu.py +++ b/module/plugins/hoster/EuroshareEu.py @@ -8,7 +8,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class EuroshareEu(SimpleHoster): __name__ = "EuroshareEu" __type__ = "hoster" - __version__ = "0.27" + __version__ = "0.28" __pattern__ = r'http://(?:www\.)?euroshare\.(eu|sk|cz|hu|pl)/file/.+' @@ -57,11 +57,11 @@ class EuroshareEu(SimpleHoster): self.link = "http://euroshare.eu%s" % m.group(1) - def checkFile(self): + def checkFile(self, rules={}): if self.checkDownload({"multi-dl": re.compile(self.ERR_PARDL_PATTERN)}) self.longWait(5 * 60, 12) - return super(EuroshareEu, self).checkFile() + return super(EuroshareEu, self).checkFile(rules) getInfo = create_getInfo(EuroshareEu) diff --git a/module/plugins/hoster/FastixRu.py b/module/plugins/hoster/FastixRu.py index d534101d8..759b9bfec 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.09" + __version__ = "0.10" __pattern__ = r'http://(?:www\.)?fastix\.(ru|it)/file/\w{24}' @@ -56,11 +56,11 @@ class FastixRu(MultiHoster): pyfile.name = self.getFilename(self.link) - def checkFile(self): + def checkFile(self, rules={}): 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() + return super(FastixRu, self).checkFile(rules) getInfo = create_getInfo(FastixRu) diff --git a/module/plugins/hoster/FastshareCz.py b/module/plugins/hoster/FastshareCz.py index 6fe871ad4..626521ed2 100644 --- a/module/plugins/hoster/FastshareCz.py +++ b/module/plugins/hoster/FastshareCz.py @@ -10,7 +10,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class FastshareCz(SimpleHoster): __name__ = "FastshareCz" __type__ = "hoster" - __version__ = "0.27" + __version__ = "0.28" __pattern__ = r'http://(?:www\.)?fastshare\.cz/\d+/.+' @@ -57,7 +57,7 @@ class FastshareCz(SimpleHoster): self.download(urljoin(baseurl, action), post={'code': captcha, 'btn.x': 77, 'btn.y': 18}) - def checkFile(self): + def checkFile(self, rules={}): check = self.checkDownload({ 'paralell-dl' : re.compile(r"FastShare.cz|