]> code.delx.au - webdl/commitdiff
iView fixed for metered ISPs like Optus
authorJames Bunton <jamesbunton@delx.net.au>
Mon, 17 Dec 2012 03:43:42 +0000 (14:43 +1100)
committerJames Bunton <jamesbunton@delx.net.au>
Mon, 17 Dec 2012 03:43:42 +0000 (14:43 +1100)
iview.py

index bb129f91ffec81eba5e3ccc642d86dfab78d6f52..f734be751e017b7c9b0be27f3484d9a0e915359e 100644 (file)
--- a/iview.py
+++ b/iview.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # vim:ts=4:sts=4:sw=4:noet
 
-from common import append_to_qs, grab_xml, grab_json, download_rtmp, Node
+from common import grab_xml, grab_json, download_rtmp, Node
 from datetime import datetime
 
 BASE_URL = "http://www.abc.net.au/iview/"
@@ -10,6 +10,9 @@ HASH_URL = BASE_URL + "images/iview.jpg"
 NS = {
        "auth": "http://www.abc.net.au/iView/Services/iViewHandshaker",
 }
+PLAYPATH_PREFIXES = {
+       "akamai": "flash/playback/_definst_/",
+}
 
 class IviewNode(Node):
        def __init__(self, title, parent, params, vpath):
@@ -20,10 +23,13 @@ class IviewNode(Node):
 
        def download(self):
                auth_doc = grab_xml(self.params["auth"], 0)
+               host = auth_doc.xpath("//auth:host/text()", namespaces=NS)[0]
+               playpath_prefix = PLAYPATH_PREFIXES.get(host.lower(), "")
                vbase = auth_doc.xpath("//auth:server/text()", namespaces=NS)[0]
                token = auth_doc.xpath("//auth:token/text()", namespaces=NS)[0]
-               vbase = append_to_qs(vbase, {"auth": token})
+               vbase += "?auth=" + token
                vpath, ext = self.vpath.rsplit(".", 1)
+               vpath = playpath_prefix + vpath
                vpath = ext + ":" + vpath
                filename = self.title + "." + ext
                return download_rtmp(filename, vbase, vpath, HASH_URL)