diff options
author | spoob <spoob@gmx.de> | 2009-12-15 22:47:26 +0100 |
---|---|---|
committer | spoob <spoob@gmx.de> | 2009-12-15 22:47:26 +0100 |
commit | 4e86c166dc20a8f4d1000e65120508c425f5b794 (patch) | |
tree | a448f511e2d6fef2f58fdb666d29a2cfa00b612e /module | |
parent | new Django webinterface(in development), small fixes (diff) | |
download | pyload-4e86c166dc20a8f4d1000e65120508c425f5b794.tar.xz |
Fixed LinkList.py and .part renaming
Diffstat (limited to 'module')
-rwxr-xr-x | module/network/Request.py | 53 | ||||
-rw-r--r-- | module/plugins/LinkList.py | 2 |
2 files changed, 28 insertions, 27 deletions
diff --git a/module/network/Request.py b/module/network/Request.py index cda8e50f1..f9a5cce0f 100755 --- a/module/network/Request.py +++ b/module/network/Request.py @@ -222,7 +222,7 @@ class Request: self.opener.add_handler(handler) self.downloader.add_handler(handler) - def download(self, url, file_name, folder="", get={}, post={}, ref=True, cookies=False): + def download(self, url, file_name, get={}, post={}, ref=True, cookies=False): if post: post = urllib.urlencode(post) @@ -236,8 +236,7 @@ class Request: get = "" if self.curl: - - file_temp = file_name + ".part" + file_temp = self.get_free_name(file_name + ".part") fp = open(file_temp, 'wb') self.init_curl() @@ -261,30 +260,19 @@ class Request: self.dl = True self.pycurl.perform() - if "..." in file_name: - download_folder = dirname(file_name) + sep - headers = self.get_header() - file_name_search = re.search('filename=(?P<quote>\")?(.+)(?(quote)\")', headers) - if file_name_search: - file_name = file_name_search.group(2) - if "?=" in file_name[-3:]: - file_name = file_name.replace("=?UTF-8?B?", "").replace("?=", "==") - file_name = b64decode(file_name) - file_name = download_folder + sep + file_name + #~ if "..." in file_name: + #~ download_folder = dirname(file_name) + sep + #~ headers = self.get_header() + #~ file_name_search = re.search('filename=(?P<quote>\")?(.+)(?(quote)\")', headers) + #~ if file_name_search: + #~ file_name = file_name_search.group(2) + #~ if "?=" in file_name[-3:]: + #~ file_name = file_name.replace("=?UTF-8?B?", "").replace("?=", "==") + #~ file_name = b64decode(file_name) + #~ file_name = download_folder + sep + file_name - file_count = 0 - while exists(file_name): - file_count += 1 - if "." in file_name: - file_split = file_name.split(".") - temp_name = "%s-%i.%s" % (".".join(file_split[:-1]), file_count, file_split[-1]) - else: - temp_name = "%s-%i" % (file_name, file_count) - if not exists(temp_name): - file_name = temp_name - - rename(file_temp, file_name) - + rename(file_temp, self.get_free_name(file_name)) + self.dl = False self.dl_finished = time.time() @@ -362,6 +350,19 @@ class Request: self.dl_arrived = int(dl_d) self.dl_size = int(dl_t) + def get_free_name(self, file_name): + file_count = 0 + while exists(file_name): + file_count += 1 + if "." in file_name: + file_split = file_name.split(".") + temp_name = "%s-%i.%s" % (".".join(file_split[:-1]), file_count, file_split[-1]) + else: + temp_name = "%s-%i" % (file_name, file_count) + if not exists(temp_name): + file_name = temp_name + return file_name + if __name__ == "__main__": import doctest doctest.testmod() diff --git a/module/plugins/LinkList.py b/module/plugins/LinkList.py index dba78ffd2..092e3ef10 100644 --- a/module/plugins/LinkList.py +++ b/module/plugins/LinkList.py @@ -32,7 +32,7 @@ class LinkList(Plugin): links = txt.readlines() for link in links: if link != "\n": - tmpLinks.append(link) + tmpLinks.append(link.replace("\n", "")) txt.close() if not self.parent.core.config['general']['debug_mode']: |