- auth_doc = grab_xml(AUTH_URL)
- NS = {
- "auth": "http://www.abc.net.au/iView/Services/iViewHandshaker",
- }
- token = auth_doc.xpath("//auth:tokenhd/text()", namespaces=NS)[0]
- token_url = auth_doc.xpath("//auth:server/text()", namespaces=NS)[0]
- token_hostname = urllib.parse.urlparse(token_url).netloc
- return token, token_hostname
-
- def add_auth_token_to_url(self, video_url, token, token_hostname):
- parsed_url = urllib.parse.urlparse(video_url)
- hacked_url = parsed_url._replace(netloc=token_hostname, query="hdnea=" + token)
- video_url = urllib.parse.urlunparse(hacked_url)
- return video_url