diff options
author | mkaay <mkaay@mkaay.de> | 2010-04-29 20:26:18 +0200 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2010-04-29 20:26:18 +0200 |
commit | 632fb7eb860675a0375b8e3a8669335ec97f6d81 (patch) | |
tree | 8b0cb62f009727b91923946e4e713017b739cea5 /module | |
parent | Some design modifications (diff) | |
download | pyload-632fb7eb860675a0375b8e3a8669335ec97f6d81.tar.xz |
fixed updater, moved config files, folder for each package now optional
Diffstat (limited to 'module')
-rw-r--r-- | module/Plugin.py | 6 | ||||
-rw-r--r-- | module/XMLConfigParser.py | 9 | ||||
-rw-r--r-- | module/config/core_default.xml | 1 | ||||
-rw-r--r-- | module/file_list.py | 8 | ||||
-rwxr-xr-x | module/network/Request.py | 6 | ||||
-rw-r--r-- | module/plugins/hoster/HotfileCom.py | 5 |
6 files changed, 17 insertions, 18 deletions
diff --git a/module/Plugin.py b/module/Plugin.py index 83610866d..59aa9c1d1 100644 --- a/module/Plugin.py +++ b/module/Plugin.py @@ -24,7 +24,6 @@ from os.path import join from time import sleep import sys -from os.path import exists from module.network.Request import Request from os import makedirs @@ -173,12 +172,13 @@ class Plugin(): def download(self, url, file_name, get={}, post={}, ref=True, cookies=True): download_folder = self.parent.core.config['general']['download_folder'] - if self.pyfile.package.data["package_name"] != (self.parent.core.config['general']['link_file']): + if self.pyfile.package.data["package_name"] != (self.parent.core.config['general']['link_file']) and self.parent.core.xmlconfig.get("general", "folder_per_package", False): self.pyfile.folder = self.pyfile.package.data["package_name"] location = join(download_folder, self.pyfile.folder.decode(sys.getfilesystemencoding())) - if not exists(location): makedirs(location) + makedirs(location) file_path = join(location.decode(sys.getfilesystemencoding()), self.pyfile.status.filename.decode(sys.getfilesystemencoding())) else: file_path = join(download_folder, self.pyfile.status.filename.decode(sys.getfilesystemencoding())) + file_path = join(download_folder, self.pyfile.status.filename.decode(sys.getfilesystemencoding())) self.pyfile.status.filename = self.req.download(url, file_path, get, post, ref, cookies) diff --git a/module/XMLConfigParser.py b/module/XMLConfigParser.py index 50214c49a..575dbd219 100644 --- a/module/XMLConfigParser.py +++ b/module/XMLConfigParser.py @@ -24,11 +24,14 @@ import re from shutil import copy class XMLConfigParser(): - def __init__(self, data, forceDefault=False): + def __init__(self, data, forceDefault=False, defaultFile=None): self.xml = None self.version = "0.1" self.file = data - self.file_default = self.file.replace(".xml", "_default.xml") + if defaultFile: + self.file_default = defaultFile + else: + self.file_default = self.file.replace(".xml", "_default.xml") self.forceDefault = forceDefault self.config = {} self.data = {} @@ -36,7 +39,7 @@ class XMLConfigParser(): self.loadData() self.root = self.xml.documentElement if not forceDefault: - self.defaultParser = XMLConfigParser(data, True) + self.defaultParser = XMLConfigParser(data, True, defaultFile=defaultFile) def loadData(self): file = self.file diff --git a/module/config/core_default.xml b/module/config/core_default.xml index ab247be08..e80892d46 100644 --- a/module/config/core_default.xml +++ b/module/config/core_default.xml @@ -35,6 +35,7 @@ <download_speed_limit type="int" name="Download Speed Limit">0</download_speed_limit> <checksum type="bool" name="Use Checksum">True</checksum> <min_free_space type="int" name="Min Free Space (MB)">200</min_free_space> + <folder_per_package type="bool" name="Create folder for each package">False</folder_per_package> </general> <updates name="Updates"> <search_updates type="bool" name="Search">True</search_updates> diff --git a/module/file_list.py b/module/file_list.py index 01a5924b3..eff96fa9e 100644 --- a/module/file_list.py +++ b/module/file_list.py @@ -44,7 +44,7 @@ class File_List(object): def __init__(self, core): self.core = core self.lock = RLock() - self.download_folder = self.core.config['general']['download_folder'] + self.download_folder = self.core.config["general"]["download_folder"] self.collector = self.pyLoadCollector(self) self.packager = self.pyLoadPackager(self) @@ -59,11 +59,11 @@ class File_List(object): def load(self): self.lock.acquire() try: - pkl_file = open(join(self.core.path, 'module', 'links.pkl'), 'rb') + pkl_file = open(join(self.core.configdir, "links.pkl"), "rb") obj = cPickle.load(pkl_file) except: obj = False - if obj != False and obj['version'] == LIST_VERSION: + if obj != False and obj["version"] == LIST_VERSION: packages = [] queue = [] collector = [] @@ -106,7 +106,7 @@ class File_List(object): pdata["queue"] = [PyLoadPackageData().set(x) for x in self.data["queue"]] pdata["collector"] = [PyLoadFileData().set(x) for x in self.data["collector"]] - output = open(join(self.core.path, 'module', 'links.pkl'), 'wb') + output = open(join(self.core.configdir, "links.pkl"), "wb") cPickle.dump(pdata, output, -1) self.lock.release() diff --git a/module/network/Request.py b/module/network/Request.py index 76f94ae41..d035048ff 100755 --- a/module/network/Request.py +++ b/module/network/Request.py @@ -343,11 +343,7 @@ def getURL(url): """ req = Request() c = req.load(url) - if req.curl: - try: - req.pycurl.close() - except: - pass + req.pycurl.close() return c if __name__ == "__main__": diff --git a/module/plugins/hoster/HotfileCom.py b/module/plugins/hoster/HotfileCom.py index d412ddd23..2a1117fc5 100644 --- a/module/plugins/hoster/HotfileCom.py +++ b/module/plugins/hoster/HotfileCom.py @@ -59,9 +59,8 @@ class HotfileCom(Plugin): def download_html(self): if self.config['premium']: self.req.add_auth(self.config['username'], self.config['password']) - self.url = self.parent.url + "?lang=en" - print self.url - self.html[0] = self.load(self.url, cookies=True) + self.url = self.parent.url + self.html[0] = self.load(self.url, get={"lang":"en"}, cookies=True) def get_file_url(self): if self.config['premium']: |