make sure all tracks are exactly the same length

This commit is contained in:
j 2024-12-04 09:16:24 +00:00
commit b2552d6059
3 changed files with 78 additions and 22 deletions

View file

@ -4,6 +4,7 @@ import subprocess
import lxml.etree
import uuid
import os
import sys
_CACHE = {}
_IDS = defaultdict(int)
@ -12,6 +13,14 @@ def get_propery(element, name):
return element.xpath('property[@name="%s"]' % name)[0].text
def get_melt():
cmd = ['melt']
if 'XDG_RUNTIME_DIR' not in os.environ:
os.environ['XDG_RUNTIME_DIR'] = '/tmp/runtime-pandora'
if 'DISPLAY' not in os.environ:
cmd = ['xvfb-run', '-a'] + cmd
return cmd
def melt_xml(file):
out = None
real_path = os.path.realpath(file)
@ -20,7 +29,8 @@ def melt_xml(file):
if os.stat(real_path).st_mtime != ts:
out = None
if not out:
out = subprocess.check_output(['melt', file, '-consumer', 'xml']).decode()
cmd = get_melt() + [file, '-consumer', 'xml']
out = subprocess.check_output(cmd).decode()
_CACHE[file] = [os.stat(real_path).st_mtime, out]
return out