X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=youtube_dl%2Fdownloader%2Ff4m.py;h=c460c167a2db78be7a1cdb8e81a3efe89e677ed1;hb=b4a64c592b5f0f547c11c72e6c840612b336de5d;hp=87d3150c705037c4ff520c02e82679805b18b9d4;hpb=3b8f3a1504b46ff6085617ea22e027668d45a503;p=youtube-dl.git diff --git a/youtube_dl/downloader/f4m.py b/youtube_dl/downloader/f4m.py index 87d3150c7..c460c167a 100644 --- a/youtube_dl/downloader/f4m.py +++ b/youtube_dl/downloader/f4m.py @@ -187,6 +187,14 @@ def build_fragments_list(boot_info): return res +def write_unsigned_int(stream, val): + stream.write(struct_pack('!I', val)) + + +def write_unsigned_int_24(stream, val): + stream.write(struct_pack('!I', val)[1:]) + + def write_flv_header(stream): """Writes the FLV header to stream""" # FLV header @@ -198,16 +206,15 @@ def write_flv_header(stream): def write_metadata_tag(stream, metadata): """Writes optional metadata tag to stream""" + SCRIPT_TAG = b'\x12' + FLV_TAG_HEADER_LEN = 11 + if metadata: - # Script data - stream.write(b'\x12') - # Size of the metadata with 3 bytes - stream.write(struct_pack('!L', len(metadata))[1:]) + stream.write(SCRIPT_TAG) + write_unsigned_int_24(stream, len(metadata)) stream.write(b'\x00\x00\x00\x00\x00\x00\x00') stream.write(metadata) - # Magic numbers extracted from the output files produced by AdobeHDS.php - # (https://github.com/K-S-V/Scripts) - stream.write(b'\x00\x00\x01\x73') + write_unsigned_int(stream, FLV_TAG_HEADER_LEN + len(metadata)) def _add_ns(prop):