소스 검색

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