X-Git-Url: https://git.ao2.it/smooth-dl.git/blobdiff_plain/3b8a5827480b918de8ec9a0cac4e615c9d9de6c5..87a28162a6f9cb85fa72a2250fe51cfaddf916ca:/smooth-dl.py diff --git a/smooth-dl.py b/smooth-dl.py index 2baa009..ac6e388 100755 --- a/smooth-dl.py +++ b/smooth-dl.py @@ -171,11 +171,20 @@ def download_chunks(base_url, manifest, stream_index, quality_level, dest_dir): 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})" + # or + # Url="QualityLevels({bitrate},{CustomAttributes})/Fragments(video={start time})" 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) @@ -221,11 +230,20 @@ def rebuild_stream(manifest, stream_index, quality_level, src_dir, 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})" + # or + # Url="QualityLevels({bitrate},{CustomAttributes})/Fragments(video={start time})" 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")