Workaround: Send credentials also for redirects.

This commit is contained in:
Alexander Weidinger
2015-11-18 16:32:25 +01:00
parent 0c81515ec5
commit 9d2c15bd10

View File

@@ -18,7 +18,9 @@ def create_filepath(filepath):
def download_files(session, f):
filename = f[1] + utils.unquote(f[0])[utils.unquote(f[0]).rindex('/'):]
if not exists(filename):
response = session.get(f[0])
response = session.get(f[0], allow_redirects=False)
if response.status_code == 301:
download_files(session, (response.headers['Location'], f[1]))
if response.status_code == 200:
create_filepath(f[1])
with open(filename, 'wb') as fd: