allow redirects

This commit is contained in:
j 2017-10-04 01:28:31 +02:00
parent 7fec0d2dae
commit b1f2b4b43d

View file

@ -53,9 +53,11 @@ def update_video(url, name):
if folder and not os.path.exists(folder):
os.makedirs(folder)
if os.path.exists(name):
head = requests.head(url)
mtime = time.mktime(datetime.strptime(head.headers.get("Last-Modified"), "%a, %d %b %Y %X GMT").timetuple())
get = mtime > os.path.getmtime(name) or int(head.headers.get("Content-Length")) != os.path.getsize(name)
head = requests.head(url, allow_redirects=True)
modified = head.headers.get("Last-Modified")
if modified:
mtime = time.mktime(datetime.strptime(modified, "%a, %d %b %Y %X GMT").timetuple())
get = mtime > os.path.getmtime(name) or int(head.headers.get("Content-Length")) != os.path.getsize(name)
else:
get = True
if get: