Commits

Frédéric Yhuel committed a154245

add parse_ismc.py

  • Participants
  • Parent commits 46e5cae

Comments (0)

Files changed (1)

+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+import shutil
+import sys
+from time import time
+from xml.dom.minidom import parse
+from subprocess import call
+
+
+def main():
+
+    fpath = sys.argv[1]
+    stream_name = sys.argv[2]
+    manifest = open(fpath)
+
+
+    dom = parse(manifest)
+    ss_media = dom.getElementsByTagName("SmoothStreamingMedia")[0]
+    streams = ss_media.getElementsByTagName("StreamIndex")
+    mstream = None
+    for stream in streams:
+        if stream.attributes["Name"].value == stream_name:
+            mstream = stream
+
+    durations = mstream.getElementsByTagName("c")
+
+    count = 0
+    st = 0
+    for duration in durations:
+        dur = int(duration.attributes["d"].value)
+        src = "/home/fred/smooth_media/ed_2962/frag_1_%i" % count
+        dst = "Fragments(audio_es=%i)" % st
+        #print src
+        #print dst
+        shutil.copy(src, dst)
+        st += dur
+        count += 1
+
+    manifest.close()
+
+    return 0
+
+if __name__ == "__main__":
+    main()