summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar spoob <spoob@gmx.de> 2009-12-15 22:47:26 +0100
committerGravatar spoob <spoob@gmx.de> 2009-12-15 22:47:26 +0100
commit4e86c166dc20a8f4d1000e65120508c425f5b794 (patch)
treea448f511e2d6fef2f58fdb666d29a2cfa00b612e
parentnew Django webinterface(in development), small fixes (diff)
downloadpyload-4e86c166dc20a8f4d1000e65120508c425f5b794.tar.xz
Fixed LinkList.py and .part renaming
-rwxr-xr-xmodule/network/Request.py53
-rw-r--r--module/plugins/LinkList.py2
-rwxr-xr-xpyLoadCore.py5
3 files changed, 31 insertions, 29 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']:
diff --git a/pyLoadCore.py b/pyLoadCore.py
index b39f2b667..72f938c37 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -106,9 +106,10 @@ class Core(object):
self.path = dirname(__file__)
self.config = {}
- self.plugin_folder = "module" + sep + "plugins"
self.plugins_avaible = {}
+ self.plugin_folder = join("module", "plugins")
+
self.read_config()
self.do_kill = False
@@ -148,7 +149,7 @@ class Core(object):
self.server_methods.check_update()
self.init_server()
- self.init_webserver() # start webinterface like cli, gui etc
+ #~ self.init_webserver() # start webinterface like cli, gui etc
self.logger.info(_("Downloadtime: %s") % self.server_methods.is_time_download()) # debug only