Browse Source

zdf_mediathek: also check for errors while reading data with urllib

Helmut Pozimski 5 years ago
parent
commit
31ad61da7b
2 changed files with 3 additions and 3 deletions
  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"]: