diff options
Diffstat (limited to 'module')
-rw-r--r-- | module/PyPackage.py | 4 | ||||
-rw-r--r-- | module/plugins/Container.py | 8 | ||||
-rw-r--r-- | module/plugins/Plugin.py | 4 | ||||
-rw-r--r-- | module/plugins/container/CCF.py | 4 | ||||
-rw-r--r-- | module/plugins/crypter/DailymotionBatch.py | 4 | ||||
-rw-r--r-- | module/plugins/crypter/YoutubeBatch.py | 4 | ||||
-rw-r--r-- | module/plugins/hooks/Checksum.py | 10 | ||||
-rw-r--r-- | module/plugins/hooks/ExternalScripts.py | 6 | ||||
-rw-r--r-- | module/plugins/hooks/ExtractArchive.py | 10 | ||||
-rw-r--r-- | module/plugins/hooks/MergeFiles.py | 6 | ||||
-rw-r--r-- | module/plugins/hooks/UpdateManager.py | 6 | ||||
-rw-r--r-- | module/plugins/hoster/Xdcc.py | 4 | ||||
-rw-r--r-- | module/plugins/internal/UnRar.py | 4 | ||||
-rw-r--r-- | module/utils.py | 4 |
14 files changed, 39 insertions, 39 deletions
diff --git a/module/PyPackage.py b/module/PyPackage.py index 01e67051c..7e6962d43 100644 --- a/module/PyPackage.py +++ b/module/PyPackage.py @@ -17,7 +17,7 @@ """ from module.PullEvents import UpdateEvent -from module.utils import safe_path +from module.utils import safe_filename class PyPackage: """ @@ -38,7 +38,7 @@ class PyPackage: @property def folder(self): - return safe_path(self._folder) + return safe_filename(self._folder) def toDict(self): """ Returns a dictionary representation of the data. diff --git a/module/plugins/Container.py b/module/plugins/Container.py index 63804d713..59efbd8dd 100644 --- a/module/plugins/Container.py +++ b/module/plugins/Container.py @@ -6,7 +6,7 @@ from os import remove from os.path import basename, exists from module.plugins.Crypter import Crypter -from module.utils import save_join +from module.utils import safe_join class Container(Crypter): @@ -42,7 +42,7 @@ class Container(Crypter): if self.pyfile.url.startswith("http"): self.pyfile.name = re.findall("([^\/=]+)", self.pyfile.url)[-1] content = self.load(self.pyfile.url) - self.pyfile.url = save_join(self.config['general']['download_folder'], self.pyfile.name) + self.pyfile.url = safe_join(self.config['general']['download_folder'], self.pyfile.name) f = open(self.pyfile.url, "wb" ) f.write(content) f.close() @@ -50,8 +50,8 @@ class Container(Crypter): else: self.pyfile.name = basename(self.pyfile.url) if not exists(self.pyfile.url): - if exists(save_join(pypath, self.pyfile.url)): - self.pyfile.url = save_join(pypath, self.pyfile.url) + if exists(safe_join(pypath, self.pyfile.url)): + self.pyfile.url = safe_join(pypath, self.pyfile.url) else: self.fail(_("File not exists.")) diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index 8a2554ea0..03ff58418 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -14,7 +14,7 @@ if os.name != "nt": from itertools import islice -from module.utils import safe_join, safe_path, fs_encode, fs_decode +from module.utils import safe_join, safe_filename, fs_encode, fs_decode def chunks(iterable, size): it = iter(iterable) @@ -503,7 +503,7 @@ class Plugin(Base): # convert back to unicode location = fs_decode(location) - name = safe_path(self.pyfile.name) + name = safe_filename(self.pyfile.name) filename = join(location, name) diff --git a/module/plugins/container/CCF.py b/module/plugins/container/CCF.py index ee92beb9a..959eeb1d0 100644 --- a/module/plugins/container/CCF.py +++ b/module/plugins/container/CCF.py @@ -9,7 +9,7 @@ from urllib2 import build_opener from module.lib.MultipartPostHandler import MultipartPostHandler from module.plugins.Container import Container -from module.utils import save_join +from module.utils import safe_join class CCF(Container): @@ -35,7 +35,7 @@ class CCF(Container): download_folder = self.config['general']['download_folder'] - tempdlc_name = save_join(download_folder, "tmp_%s.dlc" % pyfile.name) + tempdlc_name = safe_join(download_folder, "tmp_%s.dlc" % pyfile.name) tempdlc = open(tempdlc_name, "w") tempdlc.write(re.search(r'<dlc>(.*)</dlc>', tempdlc_content, re.DOTALL).group(1)) tempdlc.close() diff --git a/module/plugins/crypter/DailymotionBatch.py b/module/plugins/crypter/DailymotionBatch.py index e43d4e1fd..e9a1bb98c 100644 --- a/module/plugins/crypter/DailymotionBatch.py +++ b/module/plugins/crypter/DailymotionBatch.py @@ -6,7 +6,7 @@ from urlparse import urljoin from module.common.json_layer import json_loads from module.plugins.Crypter import Crypter -from module.utils import save_join +from module.utils import safe_join class DailymotionBatch(Crypter): @@ -93,6 +93,6 @@ class DailymotionBatch(Crypter): 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) + p_folder = safe_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 index 1caca16bd..158dfeee9 100644 --- a/module/plugins/crypter/YoutubeBatch.py +++ b/module/plugins/crypter/YoutubeBatch.py @@ -6,7 +6,7 @@ from urlparse import urljoin from module.common.json_layer import json_loads from module.plugins.Crypter import Crypter -from module.utils import save_join +from module.utils import safe_join API_URL = "AIzaSyCKnWLNlkX-L4oD1aEzqqhRw1zczeD6_k0" @@ -122,7 +122,7 @@ class YoutubeBatch(Crypter): 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) + p_folder = safe_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: diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 013172899..c2c088066 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -10,7 +10,7 @@ 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 +from module.utils import safe_join, fs_encode def computeChecksum(local_file, algorithm): @@ -91,7 +91,7 @@ class Checksum(Hook): local_file = fs_encode(pyfile.plugin.lastDownload) #download_folder = self.config['general']['download_folder'] - #local_file = fs_encode(save_join(download_folder, pyfile.package().folder, pyfile.name)) + #local_file = fs_encode(safe_join(download_folder, pyfile.package().folder, pyfile.name)) if not isfile(local_file): self.checkFailed(pyfile, None, "File does not exist") @@ -143,7 +143,7 @@ class Checksum(Hook): pyfile.plugin.fail(reason=msg) def packageFinished(self, pypack): - download_folder = save_join(self.config['general']['download_folder'], pypack.folder, "") + download_folder = safe_join(self.config['general']['download_folder'], pypack.folder, "") for link in pypack.getChildren().itervalues(): file_type = splitext(link['name'])[1][1:].lower() @@ -152,7 +152,7 @@ class Checksum(Hook): if file_type not in self.formats: continue - hash_file = fs_encode(save_join(download_folder, link['name'])) + hash_file = fs_encode(safe_join(download_folder, link['name'])) if not isfile(hash_file): self.logWarning("File not found: %s" % link['name']) continue @@ -164,7 +164,7 @@ class Checksum(Hook): data = m.groupdict() self.logDebug(link['name'], data) - local_file = fs_encode(save_join(download_folder, data['name'])) + local_file = fs_encode(safe_join(download_folder, data['name'])) algorithm = self.methods.get(file_type, file_type) checksum = computeChecksum(local_file, algorithm) if checksum == data['hash']: diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 8d03d27d4..90ae3bee0 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -6,7 +6,7 @@ from os import listdir, access, X_OK, makedirs from os.path import join, exists, basename, abspath from module.plugins.Hook import Hook -from module.utils import save_join +from module.utils import safe_join class ExternalScripts(Hook): @@ -73,13 +73,13 @@ class ExternalScripts(Hook): def downloadFinished(self, pyfile): for script in self.scripts['download_finished']: self.callScript(script, pyfile.pluginname, pyfile.url, pyfile.name, - save_join(self.config['general']['download_folder'], + safe_join(self.config['general']['download_folder'], pyfile.package().folder, pyfile.name), pyfile.id) def packageFinished(self, pypack): for script in self.scripts['package_finished']: folder = self.config['general']['download_folder'] - folder = save_join(folder, pypack.folder) + folder = safe_join(folder, pypack.folder) self.callScript(script, pypack.name, folder, pypack.password, pypack.id) diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 144829459..183f189a6 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -49,7 +49,7 @@ if os.name != "nt": from module.plugins.Hook import Hook, threaded, Expose from module.plugins.internal.AbstractExtractor import ArchiveError, CRCError, WrongPassword -from module.utils import save_join, fs_encode +from module.utils import safe_join, fs_encode class ExtractArchive(Hook): @@ -148,21 +148,21 @@ class ExtractArchive(Hook): continue # determine output folder - out = save_join(dl, p.folder, "") + out = safe_join(dl, p.folder, "") # force trailing slash if self.getConfig("destination") and self.getConfig("destination").lower() != "none": - out = save_join(dl, p.folder, self.getConfig("destination"), "") + out = safe_join(dl, p.folder, self.getConfig("destination"), "") #relative to package folder if destination is relative, otherwise absolute path overwrites them if self.getConfig("subfolder"): - out = save_join(out, fs_encode(p.folder)) + out = safe_join(out, fs_encode(p.folder)) if not exists(out): makedirs(out) - files_ids = [(save_join(dl, p.folder, x['name']), x['id']) for x in p.getChildren().itervalues()] + files_ids = [(safe_join(dl, p.folder, x['name']), x['id']) for x in p.getChildren().itervalues()] matched = False # check as long there are unseen files diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py index a859092fb..ad1de7e6a 100644 --- a/module/plugins/hooks/MergeFiles.py +++ b/module/plugins/hooks/MergeFiles.py @@ -5,7 +5,7 @@ import re import traceback from module.plugins.Hook import Hook, threaded -from module.utils import save_join, fs_encode +from module.utils import safe_join, fs_encode class MergeFiles(Hook): @@ -41,11 +41,11 @@ class MergeFiles(Hook): download_folder = self.config['general']['download_folder'] if self.config['general']['folder_per_package']: - download_folder = save_join(download_folder, pack.folder) + download_folder = safe_join(download_folder, pack.folder) for name, file_list in files.iteritems(): self.logInfo("Starting merging of %s" % name) - final_file = open(save_join(download_folder, name), "wb") + final_file = open(safe_join(download_folder, name), "wb") for splitted_file in file_list: self.logDebug("Merging part %s" % splitted_file) diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 546e6e6e8..320bc24e3 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -8,7 +8,7 @@ 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 +from module.utils import safe_join class UpdateManager(Hook): @@ -200,7 +200,7 @@ class UpdateManager(Hook): content = getURL(url % plugin) m = vre.search(content) if m and m.group(2) == version: - f = open(save_join("userplugins", prefix, filename), "wb") + f = open(safe_join("userplugins", prefix, filename), "wb") f.write(content) f.close() updated.append((prefix, name)) @@ -257,7 +257,7 @@ class UpdateManager(Hook): for root in ("userplugins", path.join(pypath, "module", "plugins")): - filename = save_join(root, type, file) + filename = safe_join(root, type, file) try: remove(filename) except Exception, e: diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py index a26e239ad..d26f12a78 100644 --- a/module/plugins/hoster/Xdcc.py +++ b/module/plugins/hoster/Xdcc.py @@ -11,7 +11,7 @@ from os.path import exists, join from select import select from module.plugins.Hoster import Hoster -from module.utils import save_join +from module.utils import safe_join class Xdcc(Hoster): @@ -187,7 +187,7 @@ class Xdcc(Hoster): self.pyfile.name = packname download_folder = self.config['general']['download_folder'] - filename = save_join(download_folder, packname) + filename = safe_join(download_folder, packname) self.logInfo("XDCC: Downloading %s from %s:%d" % (packname, ip, port)) diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index 19c278735..42ba2f66f 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -9,7 +9,7 @@ from string import digits from subprocess import Popen, PIPE from module.plugins.internal.AbstractExtractor import AbtractExtractor, WrongPassword, ArchiveError, CRCError -from module.utils import save_join, decode +from module.utils import safe_join, decode class UnRar(AbtractExtractor): @@ -173,7 +173,7 @@ class UnRar(AbtractExtractor): for f in decode(out).splitlines(): f = f.strip() - result.add(save_join(self.out, f)) + result.add(safe_join(self.out, f)) self.files = result diff --git a/module/utils.py b/module/utils.py index 5e8c2b12b..b9eb8c88e 100644 --- a/module/utils.py +++ b/module/utils.py @@ -39,7 +39,7 @@ def remove_chars(string, repl): return string.translate(dict([(ord(s), None) for s in repl])) -def safe_path(name): +def safe_filename(name): """ remove bad chars """ name = name.encode('ascii', 'replace') # Non-ASCII chars usually breaks file saving. Replacing. if os.name == 'nt': @@ -50,7 +50,7 @@ def safe_path(name): #: Deprecated method def save_path(name): - return safe_path(name) + return safe_filename(name) def safe_join(*args): |