catch keyboard in head request too

This commit is contained in:
j 2017-10-05 01:49:32 +02:00
parent 6b0d0b4db6
commit 2a66932bff

View file

@ -59,7 +59,10 @@ def update_video(url, name):
if folder and not os.path.exists(folder): if folder and not os.path.exists(folder):
os.makedirs(folder) os.makedirs(folder)
if os.path.exists(name): if os.path.exists(name):
head = requests.head(url, allow_redirects=True) try:
head = requests.head(url, allow_redirects=True)
except KeyboardInterrupt:
sys.exit(-1)
modified = head.headers.get("Last-Modified") modified = head.headers.get("Last-Modified")
if modified: if modified:
mtime = time.mktime(datetime.strptime(modified, "%a, %d %b %Y %X GMT").timetuple()) mtime = time.mktime(datetime.strptime(modified, "%a, %d %b %Y %X GMT").timetuple())