Node.__init__(self, title, parent)
self.vpath = vpath
self.can_download = True
-
+
def download(self):
auth_doc = grab_xml(PARAMS["auth"], 0)
vbase = auth_doc.xpath("//auth:server/text()", namespaces=NS)[0]
vpath = ext + ":" + vpath
filename = self.title + "." + ext
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
+ self.series_id = series_id
+
+ def get_children(self):
+ if self.children:
+ return self.children
+ print "DOWNLOADING SERIES"
+ series_doc = grab_json(PARAMS["api"] + "series=" + self.series_id, 3600)[0]
+ for episode in series_doc["f"]:
+ vpath = episode["n"]
+ episode_title = episode["b"].strip()
+ if self.series_title != episode_title:
+ episode_title = self.series_title + " " + episode_title
+ IviewNode(episode_title, self, vpath)
+ return self.children
+
+
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"))
# Create a duplicate of each series within each category that it appears
series_list_doc = grab_json(PARAMS["api"] + "seriesIndex", 3600)
- now = datetime.now()
for series in series_list_doc:
categories = series["e"].split()
sid = series["a"]
- max_age = None
- for episode in series["f"]:
- air_date = datetime.strptime(episode["f"], "%Y-%m-%d %H:%M:%S")
- diff = now - air_date
- diff = 24*3600*diff.days + diff.seconds
- if max_age is None or diff < max_age:
- max_age = diff
-
- if max_age is None:
- continue
series_title = series["b"].replace("&", "&")
- series_nodes = []
for cid in categories:
category_node = categories_map.get(cid, None)
if category_node:
- series_nodes.append(Node(series_title, category_node))
- if not series_nodes:
- continue
-
- series_doc = grab_json(PARAMS["api"] + "series=" + sid, max_age)[0]
- for episode in series_doc["f"]:
- vpath = episode["n"]
- episode_title = episode["b"].strip()
- if series_title != episode_title:
- episode_title = series_title + " " + episode_title
- for series_node in series_nodes:
- IviewNode(episode_title, series_node, vpath)
-
+ IviewSeries(series_title, sid, category_node)