diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-05-01 01:06:01 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-05-01 01:06:01 +0200 |
commit | 1ef93e913238275f7657d496ba3d2e7eeb5a30a2 (patch) | |
tree | c52a2ab51763fce4a9b47d3c62388a27ebdeeda8 /module/plugins/hooks | |
parent | Fix https://github.com/pyload/pyload/issues/1373 (diff) | |
download | pyload-1ef93e913238275f7657d496ba3d2e7eeb5a30a2.tar.xz |
Use 'import' instead 'from'
Diffstat (limited to 'module/plugins/hooks')
-rw-r--r-- | module/plugins/hooks/BypassCaptcha.py | 6 | ||||
-rw-r--r-- | module/plugins/hooks/CaptchaBrotherhood.py | 11 | ||||
-rw-r--r-- | module/plugins/hooks/Checksum.py | 14 | ||||
-rw-r--r-- | module/plugins/hooks/DeathByCaptcha.py | 6 | ||||
-rw-r--r-- | module/plugins/hooks/ExpertDecoders.py | 9 | ||||
-rw-r--r-- | module/plugins/hooks/IRCInterface.py | 4 | ||||
-rw-r--r-- | module/plugins/hooks/ImageTyperz.py | 6 | ||||
-rw-r--r-- | module/plugins/hooks/SkipRev.py | 6 |
8 files changed, 30 insertions, 32 deletions
diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index 3c8f72524..9e01edfa2 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from pycurl import FORM_FILE, LOW_SPEED_TIME +import pycurl from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getURL, getRequest @@ -64,14 +64,14 @@ class BypassCaptcha(Hook): req = getRequest() #raise timeout threshold - req.c.setopt(LOW_SPEED_TIME, 80) + req.c.setopt(pycurl.LOW_SPEED_TIME, 80) try: res = req.load(self.SUBMIT_URL, post={'vendor_key': self.PYLOAD_KEY, 'key': self.getConfig('passkey'), 'gen_task_id': "1", - 'file': (FORM_FILE, captcha)}, + 'file': (pycurl.FORM_FILE, captcha)}, multipart=True) finally: req.close() diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index e5285a493..bda080037 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -5,14 +5,13 @@ from __future__ import with_statement import StringIO import pycurl import time +import urllib try: from PIL import Image except ImportError: import Image -from urllib import urlencode - from module.network.RequestFactory import getURL, getRequest from module.plugins.Hook import Hook, threaded @@ -90,10 +89,10 @@ class CaptchaBrotherhood(Hook): req = getRequest() url = "%ssendNewCaptcha.aspx?%s" % (self.API_URL, - urlencode({'username' : self.getConfig('username'), - 'password' : self.getConfig('passkey'), - 'captchaSource': "pyLoad", - 'timeout' : "80"})) + urllib.urlencode({'username' : self.getConfig('username'), + 'password' : self.getConfig('passkey'), + 'captchaSource': "pyLoad", + 'timeout' : "80"})) req.c.setopt(pycurl.URL, url) req.c.setopt(pycurl.POST, 1) diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 4ad17f55a..ab7daf701 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -3,12 +3,10 @@ from __future__ import with_statement import hashlib +import os import re import zlib -from os import remove -from os.path import getsize, isfile, splitext - from module.plugins.Hook import Hook from module.utils import save_join, fs_encode @@ -109,13 +107,13 @@ class Checksum(Hook): #download_folder = self.config['general']['download_folder'] #local_file = fs_encode(save_join(download_folder, pyfile.package().folder, pyfile.name)) - if not isfile(local_file): + if not os.path.isfile(local_file): self.checkFailed(pyfile, None, "File does not exist") # validate file size if "size" in data: api_size = int(data['size']) - file_size = getsize(local_file) + file_size = os.path.getsize(local_file) if api_size != file_size: self.logWarning(_("File %s has incorrect size: %d B (%d expected)") % (pyfile.name, file_size, api_size)) @@ -157,7 +155,7 @@ class Checksum(Hook): retry_action = self.getConfig('retry_action') if pyfile.plugin.retries < max_tries: if local_file: - remove(local_file) + os.remove(local_file) pyfile.plugin.retry(max_tries, self.getConfig('wait_time'), msg) elif retry_action == "nothing": return @@ -170,13 +168,13 @@ class Checksum(Hook): download_folder = save_join(self.config['general']['download_folder'], pypack.folder, "") for link in pypack.getChildren().itervalues(): - file_type = splitext(link['name'])[1][1:].lower() + file_type = os.path.splitext(link['name'])[1][1:].lower() if file_type not in self.formats: continue hash_file = fs_encode(save_join(download_folder, link['name'])) - if not isfile(hash_file): + if not os.path.isfile(hash_file): self.logWarning(_("File not found"), link['name']) continue diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 501de0c1a..f9618f011 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -2,11 +2,11 @@ from __future__ import with_statement +import pycurl import re import time from base64 import b64encode -from pycurl import FORM_FILE, HTTPHEADER from module.common.json_layer import json_loads from module.network.HTTPRequest import BadHeader @@ -74,7 +74,7 @@ class DeathByCaptcha(Hook): def api_response(self, api="captcha", post=False, multipart=False): req = getRequest() - req.c.setopt(HTTPHEADER, ["Accept: application/json", "User-Agent: pyLoad %s" % self.core.version]) + req.c.setopt(pycurl.HTTPHEADER, ["Accept: application/json", "User-Agent: pyLoad %s" % self.core.version]) if post: if not isinstance(post, dict): @@ -135,7 +135,7 @@ class DeathByCaptcha(Hook): #@NOTE: Workaround multipart-post bug in HTTPRequest.py if re.match("^\w*$", self.getConfig('passkey')): multipart = True - data = (FORM_FILE, captcha) + data = (pycurl.FORM_FILE, captcha) else: multipart = False with open(captcha, 'rb') as f: diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py index 79e98c020..ccd48f664 100644 --- a/module/plugins/hooks/ExpertDecoders.py +++ b/module/plugins/hooks/ExpertDecoders.py @@ -2,9 +2,10 @@ from __future__ import with_statement +import pycurl +import uuid + from base64 import b64encode -from pycurl import LOW_SPEED_TIME -from uuid import uuid4 from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getURL, getRequest @@ -48,7 +49,7 @@ class ExpertDecoders(Hook): @threaded def _processCaptcha(self, task): - task.data['ticket'] = ticket = uuid4() + task.data['ticket'] = ticket = uuid.uuid4() result = None with open(task.captchaFile, 'rb') as f: @@ -56,7 +57,7 @@ class ExpertDecoders(Hook): req = getRequest() #raise timeout threshold - req.c.setopt(LOW_SPEED_TIME, 80) + req.c.setopt(pycurl.LOW_SPEED_TIME, 80) try: result = req.load(self.API_URL, diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 9e2f670e6..33fde3d20 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import pycurl import re import socket import ssl import time import traceback -from pycurl import FORM_FILE from select import select from threading import Thread @@ -77,7 +77,7 @@ class IRCInterface(Thread, Hook): task.setWaiting(60) html = getURL("http://www.freeimagehosting.net/upload.php", - post={"attached": (FORM_FILE, task.captchaFile)}, multipart=True) + post={"attached": (pycurl.FORM_FILE, task.captchaFile)}, multipart=True) url = re.search(r"\[img\]([^\[]+)\[/img\]\[/url\]", html).group(1) self.response(_("New Captcha Request: %s") % url) diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index 132ab2e02..f1fcacb71 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -2,10 +2,10 @@ from __future__ import with_statement +import pycurl import re from base64 import b64encode -from pycurl import FORM_FILE, LOW_SPEED_TIME from module.network.RequestFactory import getURL, getRequest from module.plugins.Hook import Hook, threaded @@ -76,13 +76,13 @@ class ImageTyperz(Hook): def submit(self, captcha, captchaType="file", match=None): req = getRequest() #raise timeout threshold - req.c.setopt(LOW_SPEED_TIME, 80) + req.c.setopt(pycurl.LOW_SPEED_TIME, 80) try: #@NOTE: Workaround multipart-post bug in HTTPRequest.py if re.match("^\w*$", self.getConfig('passkey')): multipart = True - data = (FORM_FILE, captcha) + data = (pycurl.FORM_FILE, captcha) else: multipart = False with open(captcha, 'rb') as f: diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 157b55bbd..7901ca540 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- import re +import urllib +import urlparse from types import MethodType -from urllib import unquote -from urlparse import urlparse from module.PyFile import PyFile from module.plugins.Hook import Hook @@ -43,7 +43,7 @@ class SkipRev(Hook): return pyfile.pluginmodule.getInfo([pyfile.url]).next()[0] else: self.logWarning("Unable to grab file name") - return urlparse(unquote(pyfile.url)).path.split('/')[-1] + return urlparse.urlparse(urllib.unquote(pyfile.url)).path.split('/')[-1] def _pyfile(self, link): |