use uuids

This commit is contained in:
j 2021-11-05 10:36:21 +00:00
parent f8c15e6944
commit 9524720585

View file

@ -3,14 +3,15 @@
import sys import sys
import os import os
from optparse import OptionParser from optparse import OptionParser
import tempfile
import shutil
import math
import time
import json import json
import urllib.request import math
import urllib.parse import shutil
import tempfile
import time
import urllib.error import urllib.error
import urllib.parse
import urllib.request
import uuid
import xml.sax.saxutils import xml.sax.saxutils
import ox import ox
@ -172,7 +173,7 @@ generator_template = '''<generatoritem id="Text%(id)s">
<mediatype>video</mediatype> <mediatype>video</mediatype>
</sourcetrack> </sourcetrack>
<itemhistory> <itemhistory>
<uuid>BAA51DEC-ECB0-4879-9910-8E83B0EF7C1B</uuid> <uuid>$(uuid)s</uuid>
</itemhistory> </itemhistory>
</generatoritem> </generatoritem>
''' '''
@ -184,7 +185,7 @@ fcp_footer = '''</xmeml>'''
sequence_template = ''' sequence_template = '''
<sequence id="%(id)s "> <sequence id="%(id)s ">
<uuid>72DC4146-6224-4400-BAAC-2AB6E0D3D292</uuid> <uuid>$(uuid)s</uuid>
<updatebehavior>add</updatebehavior> <updatebehavior>add</updatebehavior>
<name>%(id)s</name> <name>%(id)s</name>
<duration>%(duration)s</duration> <duration>%(duration)s</duration>
@ -325,6 +326,7 @@ class Fcp:
subs.append((start, end, value.split('\n'))) subs.append((start, end, value.split('\n')))
self.sequences.append(sequence_template % { self.sequences.append(sequence_template % {
'id': os.path.splitext(os.path.basename(srt))[0], 'id': os.path.splitext(os.path.basename(srt))[0],
'uuid': str(uuid.uuid1()).upper(),
'duration': duration, 'duration': duration,
'subs': '\n'.join([self.sub(*s) for s in subs]) 'subs': '\n'.join([self.sub(*s) for s in subs])
}) })
@ -334,6 +336,7 @@ class Fcp:
text = xml.sax.saxutils.escape('\n'.join(text).strip()).replace('\n', '&#13;') text = xml.sax.saxutils.escape('\n'.join(text).strip()).replace('\n', '&#13;')
return generator_template % { return generator_template % {
'id': self.gid, 'id': self.gid,
'uuid': str(uuid.uuid1()).upper(),
'start': start, 'start': start,
'end': end, 'end': end,
'duration': end-start, 'duration': end-start,