소스 검색

zdf_mediathek: also check for errors while reading data with urllib

Helmut Pozimski 5 년 전
부모
커밋
31ad61da7b
2개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 1 1
      lib_stov/main.py
  2. 2 2
      lib_stov/zdf_mediathek.py

+ 1 - 1
lib_stov/main.py

@@ -1,4 +1,4 @@
-#   This file is part of stov, written by Helmut Pozimski 2012-2017.
+#   This file is part of stov, written by Helmut Pozimski 2012-2018.
 #
 #   stov is free software: you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by

+ 2 - 2
lib_stov/zdf_mediathek.py

@@ -1,5 +1,5 @@
 #
-#   This file is part of stov, written by Helmut Pozimski 2012-2017.
+#   This file is part of stov, written by Helmut Pozimski 2012-2018.
 #
 #   stov is free software: you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -82,13 +82,13 @@ class Connector(object):
                 connection = urllib.request.urlopen(
                     "https://zdf-cdn.live.cellular.de/mediathekV2/broadcast-"
                     "missed/%s" % day, timeout=10)
+                data = connection.read().decode("utf-8")
             except urllib.error.HTTPError:
                 LOGGER.error("Error while fetching ZDF data for %s", day)
             except socket.timeout:
                 LOGGER.error("Connection timed out while fetching ZDF data "
                              "for %s", day)
             else:
-                data = connection.read().decode("utf-8")
                 response = json.loads(data)
                 for cluster in response["broadcastCluster"]:
                     for broadcast in cluster["teaser"]: