Some manifest files can have CustomAttributes elements in the
QualityLevel settings, handle these. For instance on RaiReplay streams
there is a systemLanguage attribute to tell what language the audio
stream is in.
quality = stream.findall("QualityLevel")[quality_level]
bitrate = quality.attrib["Bitrate"]
quality = stream.findall("QualityLevel")[quality_level]
bitrate = quality.attrib["Bitrate"]
+ quality_attributes = quality.findall("CustomAttributes/Attribute")
+ custom_attributes = ""
+ for i in quality_attributes:
+ custom_attributes += "%s=%s," % (i.attrib["Name"], i.attrib["Value"])
+ custom_attributes = custom_attributes.rstrip(',')
+
# Assume URLs are in this form:
# Url="QualityLevels({bitrate})/Fragments(video={start time})"
# Assume URLs are in this form:
# Url="QualityLevels({bitrate})/Fragments(video={start time})"
+ # or
+ # Url="QualityLevels({bitrate},{CustomAttributes})/Fragments(video={start time})"
url = stream.attrib["Url"]
chunks_quality = url.split('/')[0].replace("{bitrate}", bitrate)
url = stream.attrib["Url"]
chunks_quality = url.split('/')[0].replace("{bitrate}", bitrate)
+ chunks_quality = chunks_quality.replace("{CustomAttributes}", custom_attributes)
chunks_dest_dir = os.path.join(dest_dir, chunks_quality)
if os.path.exists(chunks_dest_dir) == False:
os.mkdir(chunks_dest_dir, 0755)
chunks_dest_dir = os.path.join(dest_dir, chunks_quality)
if os.path.exists(chunks_dest_dir) == False:
os.mkdir(chunks_dest_dir, 0755)
quality = stream.findall("QualityLevel")[quality_level]
bitrate = quality.attrib["Bitrate"]
quality = stream.findall("QualityLevel")[quality_level]
bitrate = quality.attrib["Bitrate"]
+ quality_attributes = quality.findall("CustomAttributes/Attribute")
+ custom_attributes = ""
+ for i in quality_attributes:
+ custom_attributes += "%s=%s," % (i.attrib["Name"], i.attrib["Value"])
+ custom_attributes = custom_attributes.rstrip(',')
+
# Assume URLs are in this form:
# Url="QualityLevels({bitrate})/Fragments(video={start time})"
# Assume URLs are in this form:
# Url="QualityLevels({bitrate})/Fragments(video={start time})"
+ # or
+ # Url="QualityLevels({bitrate},{CustomAttributes})/Fragments(video={start time})"
url = stream.attrib["Url"]
chunks_quality = url.split('/')[0].replace("{bitrate}", bitrate)
url = stream.attrib["Url"]
chunks_quality = url.split('/')[0].replace("{bitrate}", bitrate)
+ chunks_quality = chunks_quality.replace("{CustomAttributes}", custom_attributes)
chunks_src_dir = os.path.join(src_dir, chunks_quality)
dest_file = open(dest_file_name, "wb")
chunks_src_dir = os.path.join(src_dir, chunks_quality)
dest_file = open(dest_file_name, "wb")