}
class IviewNode(Node):
- def __init__(self, title, parent, vpath):
+ def __init__(self, title, parent, params, vpath):
Node.__init__(self, title, parent)
+ self.params = params
self.vpath = vpath
self.can_download = True
def download(self):
- auth_doc = grab_xml(PARAMS["auth"], 0)
+ auth_doc = grab_xml(self.params["auth"], 0)
vbase = auth_doc.xpath("//auth:server/text()", namespaces=NS)[0]
token = auth_doc.xpath("//auth:token/text()", namespaces=NS)[0]
vbase += "?auth=" + token
return download_rtmp(filename, vbase, vpath, HASH_URL)
-class IviewSeries(Node):
- def __init__(self, series_title, series_id, parent):
- Node.__init__(self, series_title, parent)
- self.series_title = series_title
+class IviewSeriesNode(Node):
+ def __init__(self, title, parent, params, series_id):
+ Node.__init__(self, title, parent)
+ self.params = params
self.series_id = series_id
+ self.sort_children = True
def fill_children(self):
- series_doc = grab_json(PARAMS["api"] + "series=" + self.series_id, 3600)
+ series_doc = grab_json(self.params["api"] + "series=" + self.series_id, 3600)
if not series_doc:
return
for episode in series_doc[0]["f"]:
vpath = episode["n"]
episode_title = episode["b"].strip()
- if not episode_title.startswith(self.series_title):
- episode_title = self.series_title + " " + episode_title
+ if not episode_title.startswith(self.title):
+ episode_title = self.title + " " + episode_title
if episode_title.lower().endswith(" (final)"):
episode_title = episode_title[:-8]
- IviewNode(episode_title, self, vpath)
+ IviewNode(episode_title, self, self.params, vpath)
+
+class IviewRootNode(Node):
+ def __init__(self, parent):
+ Node.__init__(self, "ABC iView", parent)
+ self.sort_children = True
+
+ def fill_children(self):
+ config_doc = grab_xml(CONFIG_URL, 24*3600)
+ params = dict((p.attrib["name"], p.attrib["value"]) for p in config_doc.xpath("/config/param"))
+
+ categories_doc = grab_xml(BASE_URL + params["categories"], 24*3600)
+ categories_map = {}
+ for category in categories_doc.xpath("//category[@genre='true']"):
+ cid = category.attrib["id"]
+ category_name = category.xpath("name/text()")[0]
+ category_node = Node(category_name, self)
+ category_node.sort_children = True
+ categories_map[cid] = category_node
+
+ # Create a duplicate of each series within each category that it appears
+ series_list_doc = grab_json(params["api"] + "seriesIndex", 3600)
+ for series in series_list_doc:
+ categories = series["e"].split()
+ sid = series["a"]
+
+ series_title = series["b"].replace("&", "&")
+ for cid in categories:
+ category_node = categories_map.get(cid, None)
+ if category_node:
+ IviewSeriesNode(series_title, category_node, params, sid)
def fill_nodes(root_node):
- root_node = Node("ABC iView", root_node)
-
- config_doc = grab_xml(CONFIG_URL, 24*3600)
- global PARAMS
- PARAMS = dict((p.attrib["name"], p.attrib["value"]) for p in config_doc.xpath("/config/param"))
-
- categories_doc = grab_xml(BASE_URL + PARAMS["categories"], 24*3600)
- categories_map = {}
- for category in categories_doc.xpath("//category[@genre='true']"):
- cid = category.attrib["id"]
- category_name = category.xpath("name/text()")[0]
- category_node = Node(category_name, root_node)
- categories_map[cid] = category_node
-
- # Create a duplicate of each series within each category that it appears
- series_list_doc = grab_json(PARAMS["api"] + "seriesIndex", 3600)
- for series in series_list_doc:
- categories = series["e"].split()
- sid = series["a"]
-
- series_title = series["b"].replace("&", "&")
- for cid in categories:
- category_node = categories_map.get(cid, None)
- if category_node:
- IviewSeries(series_title, sid, category_node)
+ IviewRootNode(root_node)