From 46bd7ee8ae71246b460440c59a4e34b8e86b8398 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Fri, 15 Jan 2016 20:21:52 +0100 Subject: [PATCH] smooth-dl.py: improve getting the manifest of Clip elements --- smooth-dl.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/smooth-dl.py b/smooth-dl.py index 39785a4..a496bc7 100755 --- a/smooth-dl.py +++ b/smooth-dl.py @@ -130,13 +130,18 @@ def get_manifest(url, dest_dir): 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) -- 2.1.4