From e48cc4a6909f1a423bbc47ae9e830c6009a9d954 Mon Sep 17 00:00:00 2001 From: Jonny007-MKD Date: Sat, 4 Apr 2020 22:08:01 +0200 Subject: [PATCH] Catch exception when downloading EPG --- saneRenamix.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/saneRenamix.py b/saneRenamix.py index 29679e0..1b9f920 100755 --- a/saneRenamix.py +++ b/saneRenamix.py @@ -256,7 +256,11 @@ def getEpgData(info: EpisodeInfo): def downloadEpg(): url = f"https://www.onlinetvrecorder.com/epg/csv/epg_{info.datetime.strftime('%Y_%m_%d')}.csv" logging.debug(f" downloadEpg(): {url}") - request = urllib.request.urlopen(url) + try: + request = urllib.request.urlopen(url) + except requests.exceptions.HTTPError as e: + logging.error(f" failed: {e}") + sys.exit(ExitCode.DownloadingEPGFailed) if request.getcode() == 200: data = request.read().decode('latin-1') with open(filepath, 'w') as f: