diff options
author | spoob <spoob@gmx.de> | 2009-09-03 16:44:21 +0200 |
---|---|---|
committer | spoob <spoob@gmx.de> | 2009-09-03 16:44:21 +0200 |
commit | aaa0dfd0a5a8843b549e6c1ea66fcb786a8069cf (patch) | |
tree | 89cfe1f1509e116d368578f73797b13608ab878d /module/network | |
parent | netload fix (diff) | |
download | pyload-aaa0dfd0a5a8843b549e6c1ea66fcb786a8069cf.tar.xz |
Fixed #24
Diffstat (limited to 'module/network')
-rwxr-xr-x | module/network/Request.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/module/network/Request.py b/module/network/Request.py index e693afa1d..084c84f95 100755 --- a/module/network/Request.py +++ b/module/network/Request.py @@ -9,10 +9,11 @@ import base64 import cookielib from gzip import GzipFile import time +import re from os import sep, rename from os.path import dirname, exists import urllib - +from base64 import b64decode from cStringIO import StringIO try: @@ -240,11 +241,25 @@ 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 + file_count = 0 while exists(file_name): file_count += 1 - file_split = file_name.split(".") - temp_name = "%s-%i.%s" % (file_split[0], file_count, file_split[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 |