summary refs log tree commit diff
diff options
context:
space:
mode:
authorAntti Ajanki <antti.ajanki@iki.fi>2015-01-05 20:22:17 +0200
committerAntti Ajanki <antti.ajanki@iki.fi>2015-01-05 21:07:15 +0200
commit2c322cc5d65550de10d70d812ac3cd6742452252 (patch)
treeaf0e77751777d286cab6abf4d1aa2ccee15f236e
parent3b8f3a1504b46ff6085617ea22e027668d45a503 (diff)
downloadyoutube-dl-2c322cc5d65550de10d70d812ac3cd6742452252.tar.gz
youtube-dl-2c322cc5d65550de10d70d812ac3cd6742452252.tar.xz
youtube-dl-2c322cc5d65550de10d70d812ac3cd6742452252.zip
[downloader/f4m] The last value in a tag is the tag length
-rw-r--r--youtube_dl/downloader/f4m.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/youtube_dl/downloader/f4m.py b/youtube_dl/downloader/f4m.py
index 87d3150c7..744bf91cb 100644
--- a/youtube_dl/downloader/f4m.py
+++ b/youtube_dl/downloader/f4m.py
@@ -187,6 +187,10 @@ def build_fragments_list(boot_info):
     return res
 
 
+def write_unsigned_int(stream, val):
+    stream.write(struct_pack('!I', val))
+
+
 def write_flv_header(stream):
     """Writes the FLV header to stream"""
     # FLV header
@@ -198,6 +202,8 @@ def write_flv_header(stream):
 
 def write_metadata_tag(stream, metadata):
     """Writes optional metadata tag to stream"""
+    FLV_TAG_HEADER_LEN = 11
+
     if metadata:
         # Script data
         stream.write(b'\x12')
@@ -205,9 +211,7 @@ def write_metadata_tag(stream, metadata):
         stream.write(struct_pack('!L', len(metadata))[1:])
         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):