From 08a31a3cd07d542593a4aa96c9081c4f7a577bee Mon Sep 17 00:00:00 2001 From: Alexander Weidinger Date: Mon, 4 Apr 2016 11:19:34 +0200 Subject: [PATCH] Handle Last-Modified header not available. --- tudown.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tudown.py b/tudown.py index f3e1324..bb3dac4 100644 --- a/tudown.py +++ b/tudown.py @@ -33,7 +33,12 @@ def download_files(session, f): download_files(session, (response.headers['Location'], f[1])) elif response.status_code == 200: last_mod_file = getmtime(filename) - last_mod_www = timegm(strptime(response.headers['Last-Modified'], '%a, %d %b %Y %H:%M:%S %Z')) + try: + last_mod_www = timegm(strptime(response.headers['Last-Modified'], '%a, %d %b %Y %H:%M:%S %Z')) + except KeyError: + print('Can\'t check {} for updates.'.format(f[0])) + last_mod_www = last_mod_file + if last_mod_www > last_mod_file: response = session.get(f[0]) if response.status_code == 200: