diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-05-01 13:05:40 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-05-01 13:05:40 +0200 |
commit | 095ad393330d9ccb86adac4894fe3280caa44234 (patch) | |
tree | f03b4a5674b4f6e79706350e06543ba565effd85 /pyload/plugin/addon | |
parent | Use bitmath lib to formatSize (diff) | |
parent | Fix https://github.com/pyload/pyload/issues/1351 (diff) | |
download | pyload-095ad393330d9ccb86adac4894fe3280caa44234.tar.xz |
Merge branch 'stable' into 0.4.10
Conflicts:
module/plugins/hoster/RehostTo.py
module/plugins/hoster/XVideosCom.py
module/plugins/hoster/ZeveraCom.py
module/plugins/internal/CaptchaService.py
pyload/plugin/account/FilefactoryCom.py
pyload/plugin/account/OneFichierCom.py
pyload/plugin/account/WebshareCz.py
pyload/plugin/addon/AntiVirus.py
pyload/plugin/addon/Checksum.py
pyload/plugin/addon/ExtractArchive.py
pyload/plugin/container/CCF.py
pyload/plugin/crypter/Go4UpCom.py
pyload/plugin/hook/BypassCaptcha.py
pyload/plugin/hook/CaptchaBrotherhood.py
pyload/plugin/hook/ExpertDecoders.py
pyload/plugin/hook/ImageTyperz.py
pyload/plugin/hook/XFileSharingPro.py
pyload/plugin/hoster/Ftp.py
pyload/plugin/hoster/GigapetaCom.py
pyload/plugin/hoster/MegaRapidCz.py
pyload/plugin/hoster/MegaRapidoNet.py
pyload/plugin/hoster/MultishareCz.py
pyload/plugin/hoster/NarodRu.py
pyload/plugin/hoster/QuickshareCz.py
pyload/plugin/hoster/RapidgatorNet.py
pyload/plugin/hoster/RapiduNet.py
pyload/plugin/hoster/UnibytesCom.py
pyload/plugin/hoster/UploadingCom.py
pyload/plugin/hoster/WrzucTo.py
pyload/plugin/internal/BasePlugin.py
pyload/plugin/internal/SimpleDereferer.py
pyload/plugin/internal/SimpleHoster.py
pyload/plugin/internal/XFSCrypter.py
pyload/plugin/internal/XFSHoster.py
Diffstat (limited to 'pyload/plugin/addon')
-rw-r--r-- | pyload/plugin/addon/AntiVirus.py | 29 | ||||
-rw-r--r-- | pyload/plugin/addon/Checksum.py | 14 | ||||
-rw-r--r-- | pyload/plugin/addon/ExtractArchive.py | 29 | ||||
-rw-r--r-- | pyload/plugin/addon/IRCInterface.py | 4 | ||||
-rw-r--r-- | pyload/plugin/addon/SkipRev.py | 6 |
5 files changed, 36 insertions, 46 deletions
diff --git a/pyload/plugin/addon/AntiVirus.py b/pyload/plugin/addon/AntiVirus.py index 87780e337..e2280a0a5 100644 --- a/pyload/plugin/addon/AntiVirus.py +++ b/pyload/plugin/addon/AntiVirus.py @@ -4,6 +4,11 @@ import os import shutil import subprocess +try: + import send2trash +except ImportError: + pass + from pyload.plugin.Addon import Addon, Expose, threaded from pyload.utils import fs_encode, fs_join @@ -11,7 +16,7 @@ from pyload.utils import fs_encode, fs_join class AntiVirus(Addon): __name = "AntiVirus" __type = "addon" - __version = "0.07" + __version = "0.08" #@TODO: add trash option (use Send2Trash lib) __config = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), @@ -27,16 +32,7 @@ class AntiVirus(Addon): __authors = [("Walter Purcaro", "vuolter@gmail.com")] - def setup(self): - try: - import send2trash - - except ImportError: - self.logDebug("Send2Trash lib not found") - self.trashable = False - else: - self.trashable = True @Expose @@ -76,13 +72,14 @@ class AntiVirus(Addon): if not self.getConfig('deltotrash'): os.remove(file) - elif self.trashable: - send2trash.send2trash(file) - else: - self.logWarning(_("Unable to move file to trash, move to quarantine instead")) - pyfile.setCustomStatus(_("file moving")) - shutil.move(file, self.getConfig('quardir')) + try: + send2trash.send2trash(file) + + except Exception: + self.logWarning(_("Unable to move file to trash, move to quarantine instead")) + pyfile.setCustomStatus(_("file moving")) + shutil.move(file, self.getConfig('quardir')) elif action == "Quarantine": pyfile.setCustomStatus(_("file moving")) diff --git a/pyload/plugin/addon/Checksum.py b/pyload/plugin/addon/Checksum.py index 750dd665e..ada52d56e 100644 --- a/pyload/plugin/addon/Checksum.py +++ b/pyload/plugin/addon/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 pyload.plugin.Addon import Addon from pyload.utils import fs_join, fs_encode @@ -108,13 +106,13 @@ class Checksum(Addon): # download_folder = self.config.get("general", "download_folder") # local_file = fs_encode(fs_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)) @@ -156,7 +154,7 @@ class Checksum(Addon): 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 @@ -169,13 +167,13 @@ class Checksum(Addon): download_folder = fs_join(self.config.get("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(fs_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/pyload/plugin/addon/ExtractArchive.py b/pyload/plugin/addon/ExtractArchive.py index 616334af2..71802cbfe 100644 --- a/pyload/plugin/addon/ExtractArchive.py +++ b/pyload/plugin/addon/ExtractArchive.py @@ -6,8 +6,6 @@ import os import sys import traceback -from copy import copy - # monkey patch bug in python 2.6 and lower # http://bugs.python.org/issue6122, http://bugs.python.org/issue1236, http://bugs.python.org/issue1731717 if sys.version_info < (2, 7) and os.name != "nt": @@ -48,6 +46,12 @@ if sys.version_info < (2, 7) and os.name != "nt": subprocess.Popen.wait = wait +try: + import send2trash +except ImportError: + pass + +from copy import copy if os.name != "nt": from grp import getgrnam from pwd import getpwnam @@ -109,7 +113,7 @@ class ArchiveQueue(object): class ExtractArchive(Addon): __name = "ExtractArchive" __type = "addon" - __version = "1.41" + __version = "1.42" __config = [("activated" , "bool" , "Activated" , True), ("fullpath" , "bool" , "Extract with full paths" , True), @@ -151,16 +155,6 @@ class ExtractArchive(Addon): self.passwords = [] self.repair = False - try: - import send2trash - - except ImportError: - self.logDebug("Send2Trash lib not found") - self.trashable = False - - else: - self.trashable = True - def activate(self): for p in ("UnRar", "SevenZip", "UnZip"): @@ -475,11 +469,12 @@ class ExtractArchive(Addon): if not deltotrash: os.remove(file) - elif self.trashable: - send2trash.send2trash(file) - else: - self.logWarning(_("Unable to move %s to trash") % os.path.basename(f)) + try: + send2trash.send2trash(file) + + except Exception: + self.logWarning(_("Unable to move %s to trash") % os.path.basename(f)) self.logInfo(name, _("Extracting finished")) extracted_files = archive.files or archive.list() diff --git a/pyload/plugin/addon/IRCInterface.py b/pyload/plugin/addon/IRCInterface.py index 07a07e381..051d30aa9 100644 --- a/pyload/plugin/addon/IRCInterface.py +++ b/pyload/plugin/addon/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 @@ -74,7 +74,7 @@ class IRCInterface(Thread, Addon): 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/pyload/plugin/addon/SkipRev.py b/pyload/plugin/addon/SkipRev.py index 5209da615..b54e66af5 100644 --- a/pyload/plugin/addon/SkipRev.py +++ b/pyload/plugin/addon/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 pyload.datatype.File import PyFile from pyload.plugin.Addon import Addon @@ -36,7 +36,7 @@ class SkipRev(Addon): 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): |