]> code.delx.au - webdl/blobdiff - iview.py
autograbber: implement .excludes.txt (fixes #75)
[webdl] / iview.py
index c2b7c5c056bca9ff420eac5d6fa5714f43300298..50395cfc2bb0c18dc997dd8b10381cd2e7a1d347 100644 (file)
--- a/iview.py
+++ b/iview.py
@@ -2,8 +2,8 @@ from common import grab_json, grab_xml, Node, download_hls
 import requests_cache
 import urllib.parse
 
-API_URL = "http://iview.abc.net.au/api"
-AUTH_URL = "http://iview.abc.net.au/auth"
+API_URL = "https://iview.abc.net.au/api"
+AUTH_URL = "https://iview.abc.net.au/auth"
 
 def format_episode_title(series, ep):
     if ep:
@@ -29,8 +29,10 @@ class IviewEpisodeNode(Node):
     def find_hls_url(self, playlist):
         for video in playlist:
             if video["type"] == "program":
-                return video["hls-high"].replace("http:", "https:")
-        raise Exception("Missing hls-high program stream for " + self.video_key)
+                for quality in ["hls-plus", "hls-high"]:
+                    if quality in video:
+                        return video[quality].replace("http:", "https:")
+        raise Exception("Missing program stream for " + self.video_key)
 
     def get_auth_details(self):
         with requests_cache.disabled():
@@ -51,6 +53,8 @@ class IviewEpisodeNode(Node):
 
     def download(self):
         info = grab_json(API_URL + "/programs/" + self.video_key)
+        if "playlist" not in info:
+            return False
         video_url = self.find_hls_url(info["playlist"])
         token, token_hostname= self.get_auth_details()
         video_url = self.add_auth_token_to_url(video_url, token, token_hostname)
@@ -64,9 +68,11 @@ class IviewIndexNode(Node):
 
     def fill_children(self):
         info = grab_json(self.url)
-        for index_list in info["index"]:
-            for ep_info in index_list["episodes"]:
-                self.add_series(ep_info)
+        for key in ["carousels", "collections", "index"]:
+            for collection_list in info.get(key, None):
+                if isinstance(collection_list, dict):
+                    for ep_info in collection_list.get("episodes", []):
+                        self.add_series(ep_info)
 
     def add_series(self, ep_info):
         title = ep_info["seriesTitle"]
@@ -86,7 +92,7 @@ class IviewSeriesNode(Node):
         series_slug = ep_info["href"].split("/")[1]
         series_url = API_URL + "/series/" + series_slug + "/" + ep_info["seriesHouseNumber"]
         info = grab_json(series_url)
-        for ep_info in info["episodes"]:
+        for ep_info in info.get("episodes", []):
             add_episode(self, ep_info)
 
 class IviewFlatNode(Node):
@@ -114,6 +120,7 @@ class IviewRootNode(Node):
         category("Lifestyle", "lifestyle")
         category("News & Current Affairs", "news")
         category("Panel & Discussion", "panel")
+        category("Regional Australia", "regional")
         category("Sport", "sport")
 
     def load_channels(self):