mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2026-01-02 01:40:49 +00:00
AvidMarker creation, reworking
This commit is contained in:
@@ -9,7 +9,7 @@ import csv
|
|||||||
import ptulsconv
|
import ptulsconv
|
||||||
from .reporting import print_section_header_style, print_status_style, print_warning
|
from .reporting import print_section_header_style, print_status_style, print_warning
|
||||||
from .validations import *
|
from .validations import *
|
||||||
from .xml.common import fmp_dump, fmp_transformed_dump
|
from .xml.common import dump_fmpxml, fmp_transformed_dump
|
||||||
|
|
||||||
from ptulsconv.pdf.supervisor_1pg import output_report as output_supervisor_1pg
|
from ptulsconv.pdf.supervisor_1pg import output_report as output_supervisor_1pg
|
||||||
from ptulsconv.pdf.line_count import output_report as output_line_count
|
from ptulsconv.pdf.line_count import output_report as output_line_count
|
||||||
@@ -130,6 +130,12 @@ def output_adr_csv(lines):
|
|||||||
with open(outfile_name, mode='w', newline='') as outfile:
|
with open(outfile_name, mode='w', newline='') as outfile:
|
||||||
dump_keyed_csv(these_lines, adr_keys, outfile)
|
dump_keyed_csv(these_lines, adr_keys, outfile)
|
||||||
|
|
||||||
|
def output_avid_markers(lines):
|
||||||
|
reels = set([ln['Reel'] for ln in lines if 'Reel' in ln.keys()])
|
||||||
|
|
||||||
|
for reel in reels:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def create_adr_reports(parsed):
|
def create_adr_reports(parsed):
|
||||||
lines = [e for e in parsed['events'] if 'ADR' in e.keys()]
|
lines = [e for e in parsed['events'] if 'ADR' in e.keys()]
|
||||||
@@ -159,11 +165,26 @@ def create_adr_reports(parsed):
|
|||||||
output_adr_csv(lines)
|
output_adr_csv(lines)
|
||||||
os.chdir("..")
|
os.chdir("..")
|
||||||
|
|
||||||
|
print_status_style("Creating Avid Marker XML files")
|
||||||
|
os.makedirs("Avid Markers", exist_ok=True)
|
||||||
|
os.chdir("Avid Markers")
|
||||||
|
output_avid_markers(lines)
|
||||||
|
|
||||||
print_status_style("Creating Scripts directory and reports")
|
print_status_style("Creating Scripts directory and reports")
|
||||||
os.makedirs("Talent Scripts", exist_ok=True)
|
os.makedirs("Talent Scripts", exist_ok=True)
|
||||||
os.chdir("Talent Scripts")
|
os.chdir("Talent Scripts")
|
||||||
output_talent_sides(lines)
|
output_talent_sides(lines)
|
||||||
|
|
||||||
|
def parse_text_export(file):
|
||||||
|
ast = ptulsconv.protools_text_export_grammar.parse(file.read())
|
||||||
|
dict_parser = ptulsconv.DictionaryParserVisitor()
|
||||||
|
parsed = dict_parser.visit(ast)
|
||||||
|
print_status_style('Session title: %s' % parsed['header']['session_name'])
|
||||||
|
print_status_style('Session timecode format: %f' % parsed['header']['timecode_format'])
|
||||||
|
print_status_style('Fount %i tracks' % len(parsed['tracks']))
|
||||||
|
print_status_style('Found %i markers' % len(parsed['markers']))
|
||||||
|
return parsed
|
||||||
|
|
||||||
|
|
||||||
def convert(input_file, output_format='fmpxml',
|
def convert(input_file, output_format='fmpxml',
|
||||||
progress=False, include_muted=False, xsl=None,
|
progress=False, include_muted=False, xsl=None,
|
||||||
@@ -226,21 +247,9 @@ def convert(input_file, output_format='fmpxml',
|
|||||||
|
|
||||||
elif output_format == 'fmpxml':
|
elif output_format == 'fmpxml':
|
||||||
if xsl is None:
|
if xsl is None:
|
||||||
fmp_dump(parsed, input_file, output, adr_field_map)
|
dump_fmpxml(parsed, input_file, output, adr_field_map)
|
||||||
else:
|
else:
|
||||||
print_section_header_style("Performing XSL Translation")
|
print_section_header_style("Performing XSL Translation")
|
||||||
print_status_style("Using builtin translation: %s" % xsl)
|
print_status_style("Using builtin translation: %s" % xsl)
|
||||||
fmp_transformed_dump(parsed, input_file, xsl, output)
|
fmp_transformed_dump(parsed, input_file, xsl, output)
|
||||||
|
|
||||||
|
|
||||||
def parse_text_export(file):
|
|
||||||
ast = ptulsconv.protools_text_export_grammar.parse(file.read())
|
|
||||||
dict_parser = ptulsconv.DictionaryParserVisitor()
|
|
||||||
parsed = dict_parser.visit(ast)
|
|
||||||
print_status_style('Session title: %s' % parsed['header']['session_name'])
|
|
||||||
print_status_style('Session timecode format: %f' % parsed['header']['timecode_format'])
|
|
||||||
print_status_style('Fount %i tracks' % len(parsed['tracks']))
|
|
||||||
print_status_style('Found %i markers' % len(parsed['markers']))
|
|
||||||
return parsed
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -226,6 +226,8 @@ class TagInterpreter(Transformation):
|
|||||||
event['PT.Track.Name'] = track_tags['line']
|
event['PT.Track.Name'] = track_tags['line']
|
||||||
event['PT.Session.Name'] = self.title_tags['line']
|
event['PT.Session.Name'] = self.title_tags['line']
|
||||||
event['PT.Session.TimecodeFormat'] = header_dict['timecode_format']
|
event['PT.Session.TimecodeFormat'] = header_dict['timecode_format']
|
||||||
|
event['PT.Session.Start'] = header_dict['start_timecode']
|
||||||
|
event['PT.Session.DropFrame'] = header_dict['timecode_drop_frame']
|
||||||
event['PT.Clip.Number'] = clip['event']
|
event['PT.Clip.Number'] = clip['event']
|
||||||
event['PT.Clip.Name'] = clip_tags['line']
|
event['PT.Clip.Name'] = clip_tags['line']
|
||||||
event['PT.Clip.Start'] = clip['start_time']
|
event['PT.Clip.Start'] = clip['start_time']
|
||||||
|
|||||||
@@ -1,15 +1,82 @@
|
|||||||
|
import datetime
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import pathlib
|
import pathlib
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import glob
|
import glob
|
||||||
|
import datetime
|
||||||
|
import ptulsconv
|
||||||
|
|
||||||
|
from xml.etree.ElementTree import TreeBuilder, tostring
|
||||||
|
|
||||||
|
|
||||||
def fmp_dump(data, input_file_name, output, adr_field_map):
|
def avid_marker_list(lines, report_date=datetime.datetime.now(), reel_start_frame=0):
|
||||||
from xml.etree.ElementTree import TreeBuilder, tostring
|
doc = TreeBuilder(element_factory=None)
|
||||||
import ptulsconv
|
|
||||||
|
|
||||||
|
doc.start('Avid:StreamItems', {'xmlns:Avid': 'http://www.avid.com'})
|
||||||
|
doc.start('Avid:XMLFileData')
|
||||||
|
doc.start('AvProp', {'name': 'DomainMagic', 'type':'string'})
|
||||||
|
doc.data("Domain")
|
||||||
|
doc.end('AvProp')
|
||||||
|
doc.start('AvProp', {'name': 'DomainKey', 'type': 'string'})
|
||||||
|
doc.data("58424a44")
|
||||||
|
doc.end('AvProp')
|
||||||
|
|
||||||
|
def insert_elem(kind, attb, atype, name, value):
|
||||||
|
doc.start('ListElem')
|
||||||
|
doc.start('AvProp', {'id': 'ATTR',
|
||||||
|
'name': 'OMFI:ATTB:Kind',
|
||||||
|
'type': 'int32'})
|
||||||
|
doc.data(kind)
|
||||||
|
doc.end('AvProp')
|
||||||
|
|
||||||
|
doc.start('AvProp', {'id': 'ATTR',
|
||||||
|
'name': 'OMFI:ATTB:Name',
|
||||||
|
'type': 'string'})
|
||||||
|
doc.data(name)
|
||||||
|
doc.end('AvProp')
|
||||||
|
|
||||||
|
doc.start('AvProp', {'id': 'ATTR',
|
||||||
|
'name': attb,
|
||||||
|
'type': atype})
|
||||||
|
doc.data(value)
|
||||||
|
doc.end('AvProp')
|
||||||
|
|
||||||
|
doc.end('ListElem')
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
doc.start('AvClass', {'id': 'ATTR'})
|
||||||
|
doc.start('AvProp', {'id': 'ATTR', 'name': '__OMFI:ATTR:NumItems', 'type': 'int32'})
|
||||||
|
doc.data('7')
|
||||||
|
doc.end('AvProp')
|
||||||
|
|
||||||
|
doc.start('List', {'id': 'OMFI:ATTR:AttrRefs'})
|
||||||
|
|
||||||
|
insert_elem('1', 'OMFI:ATTB:IntAttribute', 'int32', '_ATN_CRM_LONG_CREATE_DATE', report_date.strftime("%s"))
|
||||||
|
insert_elem('2', 'OMFI:ATTB:StringAttribute', 'string', '_ATN_CRM_COLOR', 'yellow')
|
||||||
|
insert_elem('2', 'OMFI:ATTB:StringAttribute', 'string', '_ATN_CRM_USER', line['Supervisor'])
|
||||||
|
|
||||||
|
marker_name = "%s: %s" % (line['Cue Number'], line['Line'])
|
||||||
|
insert_elem('2', 'OMFI:ATTB:StringAttribute', 'string', '_ATN_CRM_COM', marker_name)
|
||||||
|
|
||||||
|
insert_elem('2', "OMFI:ATTB:StringAttribute", 'string', '_ATN_CRM_TC',
|
||||||
|
str(lines['Start Frames'] - reel_start_frame))
|
||||||
|
|
||||||
|
insert_elem('2', "OMFI:ATTB:StringAttribute", 'string', '_ATN_CRM_TRK', 'V1')
|
||||||
|
insert_elem('1', "OMFI:ATTB:IntAttribute", 'int32', '_ATN_CRM_LENGTH', '1')
|
||||||
|
|
||||||
|
doc.start('ListElem')
|
||||||
|
doc.end('ListElem')
|
||||||
|
|
||||||
|
doc.end('List')
|
||||||
|
doc.end('AvClass')
|
||||||
|
|
||||||
|
doc.end('Avid:XMLFileData')
|
||||||
|
doc.end('Avid:StreamItems')
|
||||||
|
|
||||||
|
|
||||||
|
def dump_fmpxml(data, input_file_name, output, adr_field_map):
|
||||||
doc = TreeBuilder(element_factory=None)
|
doc = TreeBuilder(element_factory=None)
|
||||||
|
|
||||||
doc.start('FMPXMLRESULT', {'xmlns': 'http://www.filemaker.com/fmpxmlresult'})
|
doc.start('FMPXMLRESULT', {'xmlns': 'http://www.filemaker.com/fmpxmlresult'})
|
||||||
@@ -80,7 +147,7 @@ def fmp_transformed_dump(data, input_file, xsl_name, output, adr_field_map):
|
|||||||
pipe = io.StringIO()
|
pipe = io.StringIO()
|
||||||
|
|
||||||
print_status_style("Generating base XML")
|
print_status_style("Generating base XML")
|
||||||
fmp_dump(data, input_file, pipe, adr_field_map)
|
dump_fmpxml(data, input_file, pipe, adr_field_map)
|
||||||
|
|
||||||
str_data = pipe.getvalue()
|
str_data = pipe.getvalue()
|
||||||
print_status_style("Base XML size %i" % (len(str_data)))
|
print_status_style("Base XML size %i" % (len(str_data)))
|
||||||
|
|||||||
Reference in New Issue
Block a user