diff options
author | Antti Ajanki <antti.ajanki@iki.fi> | 2015-01-05 20:30:40 +0200 |
---|---|---|
committer | Antti Ajanki <antti.ajanki@iki.fi> | 2015-01-05 21:12:33 +0200 |
commit | f14f2a6d7909eae5cf0d6f447f8e8a3eb53752d4 (patch) | |
tree | 2ab299f207c47a6daf4cc310fdb6f15e177dce2d /youtube_dl/downloader | |
parent | 2c322cc5d65550de10d70d812ac3cd6742452252 (diff) |
[downloader/f4m] Minor cleanup
Diffstat (limited to 'youtube_dl/downloader')
-rw-r--r-- | youtube_dl/downloader/f4m.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/youtube_dl/downloader/f4m.py b/youtube_dl/downloader/f4m.py index 744bf91cb..c460c167a 100644 --- a/youtube_dl/downloader/f4m.py +++ b/youtube_dl/downloader/f4m.py @@ -191,6 +191,10 @@ 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 @@ -202,13 +206,12 @@ 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) write_unsigned_int(stream, FLV_TAG_HEADER_LEN + len(metadata)) |