catch keyboard in head request too

This commit is contained in:
j 2017-10-05 01:49:32 +02:00
parent 6b0d0b4db6
commit 2a66932bff
1 changed files with 4 additions and 1 deletions

View File

@ -59,7 +59,10 @@ 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, allow_redirects=True)
try:
head = requests.head(url, allow_redirects=True)
except KeyboardInterrupt:
sys.exit(-1)
modified = head.headers.get("Last-Modified")
if modified:
mtime = time.mktime(datetime.strptime(modified, "%a, %d %b %Y %X GMT").timetuple())