summaryrefslogtreecommitdiffstats
path: root/pyload/plugin
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-16 17:48:30 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-16 18:06:38 +0200
commit6cdb1ae0fe8f4faf897220d0520ca3e753e9f3e4 (patch)
tree24a8d6e3c2e62597b6cd3a75b77bf1a6470bd702 /pyload/plugin
parentFix lib import (diff)
downloadpyload-6cdb1ae0fe8f4faf897220d0520ca3e753e9f3e4.tar.xz
[config] Use get method instead dict access
Diffstat (limited to 'pyload/plugin')
-rw-r--r--pyload/plugin/Container.py2
-rw-r--r--pyload/plugin/Crypter.py4
-rw-r--r--pyload/plugin/Plugin.py28
-rw-r--r--pyload/plugin/addon/Checksum.py4
-rw-r--r--pyload/plugin/addon/ClickNLoad.py4
-rw-r--r--pyload/plugin/addon/ExternalScripts.py36
-rw-r--r--pyload/plugin/addon/ExtractArchive.py14
-rw-r--r--pyload/plugin/addon/MergeFiles.py4
-rw-r--r--pyload/plugin/addon/MultiHome.py2
-rw-r--r--pyload/plugin/container/CCF.py2
-rw-r--r--pyload/plugin/crypter/DailymotionComFolder.py2
-rw-r--r--pyload/plugin/crypter/RelinkUs.py2
-rw-r--r--pyload/plugin/crypter/YoutubeComFolder.py2
-rw-r--r--pyload/plugin/hoster/Xdcc.py2
-rw-r--r--pyload/plugin/internal/SimpleCrypter.py2
15 files changed, 55 insertions, 55 deletions
diff --git a/pyload/plugin/Container.py b/pyload/plugin/Container.py
index 87d75976f..e8e42bb2b 100644
--- a/pyload/plugin/Container.py
+++ b/pyload/plugin/Container.py
@@ -45,7 +45,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 = fs_join(self.core.config['general']['download_folder'], self.pyfile.name)
+ self.pyfile.url = fs_join(self.core.config.get("general", "download_folder"), self.pyfile.name)
try:
with open(self.pyfile.url, "wb") as f:
f.write(content)
diff --git a/pyload/plugin/Crypter.py b/pyload/plugin/Crypter.py
index bfb558abd..3c1413f09 100644
--- a/pyload/plugin/Crypter.py
+++ b/pyload/plugin/Crypter.py
@@ -12,7 +12,7 @@ class Crypter(Plugin):
__version = "0.05"
__pattern = r'^unmatchable$'
- __config = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package']
+ __config = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config.get("general", "folder_per_package")
("subfolder_per_package", "bool", "Create a subfolder for each package", True)]
__description = """Base decrypter plugin"""
@@ -65,7 +65,7 @@ class Crypter(Plugin):
package_password = self.pyfile.package().password
package_queue = self.pyfile.package().queue
- folder_per_package = self.core.config['general']['folder_per_package']
+ folder_per_package = self.core.config.get("general", "folder_per_package")
try:
use_subfolder = self.getConfig('use_subfolder')
except Exception:
diff --git a/pyload/plugin/Plugin.py b/pyload/plugin/Plugin.py
index 3ccf94f34..c18e16643 100644
--- a/pyload/plugin/Plugin.py
+++ b/pyload/plugin/Plugin.py
@@ -252,8 +252,8 @@ class Plugin(Base):
def getChunkCount(self):
if self.chunkLimit <= 0:
- return self.core.config['download']['chunks']
- return min(self.core.config['download']['chunks'], self.chunkLimit)
+ return self.core.config.get("download", "chunks")
+ return min(self.core.config.get("download", "chunks"), self.chunkLimit)
def __call__(self):
@@ -616,17 +616,17 @@ class Plugin(Base):
if disposition:
self.pyfile.name = urlparse.urlparse(url).path.split('/')[-1] or self.pyfile.name
- download_folder = self.core.config['general']['download_folder']
+ download_folder = self.core.config.get("general", "download_folder")
location = fs_join(download_folder, self.pyfile.package().folder)
if not exists(location):
try:
- makedirs(location, int(self.core.config['permission']['folder'], 8))
+ makedirs(location, int(self.core.config.get("permission", "folder"), 8))
- if self.core.config['permission']['change_dl'] and os.name != "nt":
- uid = getpwnam(self.core.config['permission']['user'])[2]
- gid = getgrnam(self.core.config['permission']['group'])[2]
+ if self.core.config.get("permission", "change_dl") and os.name != "nt":
+ uid = getpwnam(self.core.config.get("permission", "user"))[2]
+ gid = getgrnam(self.core.config.get("permission", "group"))[2]
chown(location, uid, gid)
except Exception, e:
@@ -657,16 +657,16 @@ class Plugin(Base):
fs_filename = fs_encode(filename)
- if self.core.config['permission']['change_file']:
+ if self.core.config.get("permission", "change_file"):
try:
- chmod(fs_filename, int(self.core.config['permission']['file'], 8))
+ chmod(fs_filename, int(self.core.config.get("permission", "file"), 8))
except Exception, e:
self.logWarning(_("Setting file mode failed"), e)
- if self.core.config['permission']['change_dl'] and os.name != "nt":
+ if self.core.config.get("permission", "change_dl") and os.name != "nt":
try:
- uid = getpwnam(self.core.config['permission']['user'])[2]
- gid = getgrnam(self.core.config['permission']['group'])[2]
+ uid = getpwnam(self.core.config.get("permission", "user"))[2]
+ gid = getgrnam(self.core.config.get("permission", "group"))[2]
chown(fs_filename, uid, gid)
except Exception, e:
@@ -740,10 +740,10 @@ class Plugin(Base):
elif pyfile.status in (5, 7) and starting: # a download is waiting/starting and was appenrently started before
raise SkipDownload(pyfile.pluginname)
- download_folder = self.core.config['general']['download_folder']
+ download_folder = self.core.config.get("general", "download_folder")
location = fs_join(download_folder, pack.folder, self.pyfile.name)
- if starting and self.core.config['download']['skip_existing'] and exists(location):
+ if starting and self.core.config.get("download", "skip_existing") and exists(location):
size = os.stat(location).st_size
if size >= self.pyfile.size:
raise SkipDownload("File exists")
diff --git a/pyload/plugin/addon/Checksum.py b/pyload/plugin/addon/Checksum.py
index 53b9b4e9f..ed50b0f5e 100644
--- a/pyload/plugin/addon/Checksum.py
+++ b/pyload/plugin/addon/Checksum.py
@@ -105,7 +105,7 @@ class Checksum(Addon):
self.checkFailed(pyfile, None, "No file downloaded")
local_file = fs_encode(pyfile.plugin.lastDownload)
- #download_folder = self.config['general']['download_folder']
+ #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):
@@ -166,7 +166,7 @@ class Checksum(Addon):
def packageFinished(self, pypack):
- download_folder = fs_join(self.config['general']['download_folder'], pypack.folder, "")
+ 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()
diff --git a/pyload/plugin/addon/ClickNLoad.py b/pyload/plugin/addon/ClickNLoad.py
index b6448598a..4e1be807d 100644
--- a/pyload/plugin/addon/ClickNLoad.py
+++ b/pyload/plugin/addon/ClickNLoad.py
@@ -37,11 +37,11 @@ class ClickNLoad(Addon):
def activate(self):
- if not self.core.config['webui']['activated']:
+ if not self.core.config.get("webui", "activated"):
return
ip = "" if self.getConfig('extern') else "127.0.0.1"
- webport = self.core.config['webui']['port']
+ webport = self.core.config.get("webui", "port")
cnlport = self.getConfig('port')
self.proxy(ip, webport, cnlport)
diff --git a/pyload/plugin/addon/ExternalScripts.py b/pyload/plugin/addon/ExternalScripts.py
index 19d5202fd..341dd6dcd 100644
--- a/pyload/plugin/addon/ExternalScripts.py
+++ b/pyload/plugin/addon/ExternalScripts.py
@@ -122,10 +122,10 @@ class ExternalScripts(Addon):
def downloadFailed(self, pyfile):
- if self.core.config['general']['folder_per_package']:
- download_folder = fs_join(self.core.config['general']['download_folder'], pyfile.package().folder)
+ if self.core.config.get("general", "folder_per_package"):
+ download_folder = fs_join(self.core.config.get("general", "download_folder"), pyfile.package().folder)
else:
- download_folder = self.core.config['general']['download_folder']
+ download_folder = self.core.config.get("general", "download_folder")
for script in self.scripts['download_failed']:
file = fs_join(download_folder, pyfile.name)
@@ -133,10 +133,10 @@ class ExternalScripts(Addon):
def downloadFinished(self, pyfile):
- if self.core.config['general']['folder_per_package']:
- download_folder = fs_join(self.core.config['general']['download_folder'], pyfile.package().folder)
+ if self.core.config.get("general", "folder_per_package"):
+ download_folder = fs_join(self.core.config.get("general", "download_folder"), pyfile.package().folder)
else:
- download_folder = self.core.config['general']['download_folder']
+ download_folder = self.core.config.get("general", "download_folder")
for script in self.scripts['download_finished']:
file = fs_join(download_folder, pyfile.name)
@@ -154,10 +154,10 @@ class ExternalScripts(Addon):
def packageFinished(self, pypack):
- if self.core.config['general']['folder_per_package']:
- download_folder = fs_join(self.core.config['general']['download_folder'], pypack.folder)
+ if self.core.config.get("general", "folder_per_package"):
+ download_folder = fs_join(self.core.config.get("general", "download_folder"), pypack.folder)
else:
- download_folder = self.core.config['general']['download_folder']
+ download_folder = self.core.config.get("general", "download_folder")
for script in self.scripts['package_finished']:
self.callScript(script, pypack.id, pypack.name, download_folder, pypack.password)
@@ -166,30 +166,30 @@ class ExternalScripts(Addon):
def packageDeleted(self, pid):
pack = self.core.api.getPackageInfo(pid)
- if self.core.config['general']['folder_per_package']:
- download_folder = fs_join(self.core.config['general']['download_folder'], pack.folder)
+ if self.core.config.get("general", "folder_per_package"):
+ download_folder = fs_join(self.core.config.get("general", "download_folder"), pack.folder)
else:
- download_folder = self.core.config['general']['download_folder']
+ download_folder = self.core.config.get("general", "download_folder")
for script in self.scripts['package_deleted']:
self.callScript(script, pack.id, pack.name, download_folder, pack.password)
def package_extract_failed(self, pypack):
- if self.core.config['general']['folder_per_package']:
- download_folder = fs_join(self.core.config['general']['download_folder'], pypack.folder)
+ if self.core.config.get("general", "folder_per_package"):
+ download_folder = fs_join(self.core.config.get("general", "download_folder"), pypack.folder)
else:
- download_folder = self.core.config['general']['download_folder']
+ download_folder = self.core.config.get("general", "download_folder")
for script in self.scripts['package_extract_failed']:
self.callScript(script, pypack.id, pypack.name, download_folder, pypack.password)
def package_extracted(self, pypack):
- if self.core.config['general']['folder_per_package']:
- download_folder = fs_join(self.core.config['general']['download_folder'], pypack.folder)
+ if self.core.config.get("general", "folder_per_package"):
+ download_folder = fs_join(self.core.config.get("general", "download_folder"), pypack.folder)
else:
- download_folder = self.core.config['general']['download_folder']
+ download_folder = self.core.config.get("general", "download_folder")
for script in self.scripts['package_extracted']:
self.callScript(script, pypack.id, pypack.name, download_folder)
diff --git a/pyload/plugin/addon/ExtractArchive.py b/pyload/plugin/addon/ExtractArchive.py
index a4a28ab32..26d3f07d9 100644
--- a/pyload/plugin/addon/ExtractArchive.py
+++ b/pyload/plugin/addon/ExtractArchive.py
@@ -264,7 +264,7 @@ class ExtractArchive(Addon):
# reload from txt file
self.reloadPasswords()
- download_folder = self.config['general']['download_folder']
+ download_folder = self.config.get("general", "download_folder")
# iterate packages -> extractors -> targets
for pid in ids:
@@ -551,16 +551,16 @@ class ExtractArchive(Addon):
continue
try:
- if self.config['permission']['change_file']:
+ if self.config.get("permission", "change_file"):
if os.path.isfile(f):
- os.chmod(f, int(self.config['permission']['file'], 8))
+ os.chmod(f, int(self.config.get("permission", "file"), 8))
elif os.path.isdir(f):
- os.chmod(f, int(self.config['permission']['folder'], 8))
+ os.chmod(f, int(self.config.get("permission", "folder"), 8))
- if self.config['permission']['change_dl'] and os.name != "nt":
- uid = getpwnam(self.config['permission']['user'])[2]
- gid = getgrnam(self.config['permission']['group'])[2]
+ if self.config.get("permission", "change_dl") and os.name != "nt":
+ uid = getpwnam(self.config.get("permission", "user"))[2]
+ gid = getgrnam(self.config.get("permission", "group"))[2]
os.chown(f, uid, gid)
except Exception, e:
diff --git a/pyload/plugin/addon/MergeFiles.py b/pyload/plugin/addon/MergeFiles.py
index dfc5f41d4..4f95ef9d7 100644
--- a/pyload/plugin/addon/MergeFiles.py
+++ b/pyload/plugin/addon/MergeFiles.py
@@ -37,9 +37,9 @@ class MergeFiles(Addon):
files[data['name'][:-4]].sort()
fid_dict[data['name']] = fid
- download_folder = self.config['general']['download_folder']
+ download_folder = self.config.get("general", "download_folder")
- if self.config['general']['folder_per_package']:
+ if self.config.get("general", "folder_per_package"):
download_folder = fs_join(download_folder, pack.folder)
for name, file_list in files.iteritems():
diff --git a/pyload/plugin/addon/MultiHome.py b/pyload/plugin/addon/MultiHome.py
index 057764a1e..bca6493db 100644
--- a/pyload/plugin/addon/MultiHome.py
+++ b/pyload/plugin/addon/MultiHome.py
@@ -24,7 +24,7 @@ class MultiHome(Addon):
self.parseInterfaces(self.getConfig('interfaces').split(";"))
if not self.interfaces:
- self.parseInterfaces([self.config['download']['interface']])
+ self.parseInterfaces([self.config.get("download", "interface")])
self.setConfig("interfaces", self.toConfig())
diff --git a/pyload/plugin/container/CCF.py b/pyload/plugin/container/CCF.py
index 12031989e..ef105d8a8 100644
--- a/pyload/plugin/container/CCF.py
+++ b/pyload/plugin/container/CCF.py
@@ -33,7 +33,7 @@ class CCF(Container):
'filename': "test.ccf",
'upload' : open(fs_filename, "rb")}).read()
- download_folder = self.config['general']['download_folder']
+ download_folder = self.config.get("general", "download_folder")
dlc_file = fs_join(download_folder, "tmp_%s.dlc" % pyfile.name)
try:
diff --git a/pyload/plugin/crypter/DailymotionComFolder.py b/pyload/plugin/crypter/DailymotionComFolder.py
index 2fdb1ec8e..fe173fe82 100644
--- a/pyload/plugin/crypter/DailymotionComFolder.py
+++ b/pyload/plugin/crypter/DailymotionComFolder.py
@@ -101,6 +101,6 @@ class DailymotionComFolder(Crypter):
for p_id, p_name, p_owner in playlists:
p_videos = self.getVideos(p_id)
- p_folder = fs_join(self.config['general']['download_folder'], p_owner, p_name)
+ p_folder = fs_join(self.config.get("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/pyload/plugin/crypter/RelinkUs.py b/pyload/plugin/crypter/RelinkUs.py
index e7fb7ed06..6296e9f40 100644
--- a/pyload/plugin/crypter/RelinkUs.py
+++ b/pyload/plugin/crypter/RelinkUs.py
@@ -219,7 +219,7 @@ class RelinkUs(Crypter):
try:
dlc = self.load(container_url)
dlc_filename = self.fileid + ".dlc"
- dlc_filepath = fs_join(self.config['general']['download_folder'], dlc_filename)
+ dlc_filepath = fs_join(self.config.get("general", "download_folder"), dlc_filename)
with open(dlc_filepath, "wb") as f:
f.write(dlc)
package_links.append(dlc_filepath)
diff --git a/pyload/plugin/crypter/YoutubeComFolder.py b/pyload/plugin/crypter/YoutubeComFolder.py
index da76e556b..84277207a 100644
--- a/pyload/plugin/crypter/YoutubeComFolder.py
+++ b/pyload/plugin/crypter/YoutubeComFolder.py
@@ -132,7 +132,7 @@ class YoutubeComFolder(Crypter):
for p in playlists:
p_name = p['title']
p_videos = self.getVideosId(p['id'])
- p_folder = fs_join(self.config['general']['download_folder'], p['channelTitle'], p_name)
+ p_folder = fs_join(self.config.get("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/pyload/plugin/hoster/Xdcc.py b/pyload/plugin/hoster/Xdcc.py
index ff8d2c3b8..eda518150 100644
--- a/pyload/plugin/hoster/Xdcc.py
+++ b/pyload/plugin/hoster/Xdcc.py
@@ -191,7 +191,7 @@ class Xdcc(Hoster):
self.pyfile.name = packname
- download_folder = self.config['general']['download_folder']
+ download_folder = self.config.get("general", "download_folder")
filename = fs_join(download_folder, packname)
self.logInfo(_("Downloading %s from %s:%d") % (packname, ip, port))
diff --git a/pyload/plugin/internal/SimpleCrypter.py b/pyload/plugin/internal/SimpleCrypter.py
index f6c5aa5e2..c6582647f 100644
--- a/pyload/plugin/internal/SimpleCrypter.py
+++ b/pyload/plugin/internal/SimpleCrypter.py
@@ -15,7 +15,7 @@ class SimpleCrypter(Crypter, SimpleHoster):
__version = "0.43"
__pattern = r'^unmatchable$'
- __config = [("use_subfolder" , "bool", "Save package to subfolder" , True), #: Overrides core.config['general']['folder_per_package']
+ __config = [("use_subfolder" , "bool", "Save package to subfolder" , True), #: Overrides core.config.get("general", "folder_per_package")
("subfolder_per_pack", "bool", "Create a subfolder for each package", True)]
__description = """Simple decrypter plugin"""