- try:
- # if some intermediate client Manifest is used, like in Rai Replay
- clip = manifest.find("Clip")
- actual_manifest_url = clip.attrib["Url"]
- base_url = actual_manifest_url.lower().replace("/manifest", "")
- except:
- pass
+ # if some intermediate client Manifest is used, like in Rai Replay
+ # then get the final manifest
+ clip = manifest.find("Clip")
+ if clip is not None and "Url" in clip.attrib:
+ tmp_manifest_url = clip.attrib["Url"]
+ try:
+ tmp_manifest = download_file(tmp_manifest_url, None, None)
+ # set the new values only if the dowload succeded
+ manifest_url = tmp_manifest_url
+ manifest = tmp_manifest
+ except urllib2.HTTPError:
+ pass
+
+ manifest_pattern = re.compile("/manifest$", re.IGNORECASE)
+ base_url = manifest_pattern.sub("", manifest_url)