Skip to content

Commit

Permalink
Added regexp to fix toprettyxml in python versions <= 2.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
barbibulle committed Feb 14, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 2082294 commit 0ca991e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Source/Python/utils/mp4-dash.py
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
from xml.dom.minidom import parseString
import tempfile
import fractions
import re
from mp4utils import *

# setup main options
@@ -371,7 +372,10 @@ def OutputDash(options, audio_tracks, video_tracks, subtitles_tracks):

# save the MPD
if options.mpd_filename:
open(path.join(options.output_dir, options.mpd_filename), "wb").write(parseString(xml.tostring(mpd)).toprettyxml(" "))
mpd_xml = parseString(xml.tostring(mpd)).toprettyxml(" ")
# use a regex to fix a bug in toprettyxml() that inserts newlines in text content
mpd_xml = re.sub(r'((?<=>)(\n[\s]*)(?=[^<\s]))|(?<=[^>\s])(\n[\s]*)(?=<)', '', mpd_xml)
open(path.join(options.output_dir, options.mpd_filename), "wb").write(mpd_xml)


#############################################

0 comments on commit 0ca991e

Please sign in to comment.