if not manifest_url.lower().endswith(('/manifest', '.ismc', '.csm')):
manifest_url += '/Manifest'
- if manifest_url.startswith('http://'):
+ if os.path.exists(url):
+ local_manifest_path = url
+ else:
local_manifest_path = os.path.join(dest_dir, 'Manifest')
download_file(manifest_url, local_manifest_path, "w")
- else:
- local_manifest_path = url
manifest = etree.parse(local_manifest_path)
if version != "2":
raise Exception('Only Smooth Streaming version 2 supported')
- try:
- # if some intermediate client Manifest is used, like in Rai Replay
- clip = manifest.find("Clip")
- manifest_url = clip.attrib["Url"]
- manifest = download_file(manifest_url, None, None)
- except AttributeError:
- 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)