瀏覽代碼

zdf_mediathek: retrieve json data of the last 7 days instead of just yesterday

Helmut Pozimski 6 年之前
父節點
當前提交
661d533b5a
共有 2 個文件被更改,包括 13 次插入11 次删除
  1. 1 1
      README.md
  2. 12 10
      lib_stov/zdf_mediathek.py

+ 1 - 1
README.md

@@ -66,7 +66,7 @@ For this site, all features are supported, you can subscribe to users, channels
 
 ### ZDF Mediathek
 
-Only the "channel" subscription type is supported. The string you put in as the channel name will be used to select broadcasts from all of the available ones to download. Since it uses the "Sendung verpasst?" feature of the json API, you should run stov at least daily to catch all broadcasts.
+Only the "channel" subscription type is supported. The string you put in as the channel name will be used to select broadcasts from all of the available ones to download. Since many broadcasts are removed from the Mediathek after 7 days, you should run stov at least weekly to catch all broadcasts.
 
 ### Twitch.tv
 

+ 12 - 10
lib_stov/zdf_mediathek.py

@@ -71,16 +71,18 @@ class Connector(object):
         videos_list = []
         new_videos = []
         today = datetime.today()
-        connection = urllib.request.urlopen(
-            "https://zdf-cdn.live.cellular.de/mediathekV2/broadcast-missed/%s"
-            % (today-timedelta(days=1)).strftime("%Y-%m-%d"))
-        data = connection.read().decode("utf-8")
-        response = json.loads(data)
-        for cluster in response["broadcastCluster"]:
-            for broadcast in cluster["teaser"]:
-                if self._name in broadcast["titel"]:
-                    new_videos.append((broadcast["sharingUrl"],
-                                       broadcast["titel"]))
+        for i in range(7, -1, -1):
+            connection = urllib.request.urlopen(
+                "https://zdf-cdn.live.cellular.de/mediathekV2/broadcast-"
+                "missed/%s"
+                % (today-timedelta(days=1)).strftime("%Y-%m-%d"))
+            data = connection.read().decode("utf-8")
+            response = json.loads(data)
+            for cluster in response["broadcastCluster"]:
+                for broadcast in cluster["teaser"]:
+                    if self._name in broadcast["titel"]:
+                        new_videos.append((broadcast["sharingUrl"],
+                                           broadcast["titel"]))
         if new_videos:
             for broadcast in new_videos:
                 video_exists = False