14 Commits

Author SHA1 Message Date
Jamie Hardt
3718541e09 Update README.md 2020-05-15 15:47:24 -07:00
Jamie Hardt
a58451d225 Bumped version to 0.4, added --xform command-line option to run builtin xsl 2020-05-15 15:40:13 -07:00
Jamie Hardt
319ef3800d Renamed AvidMarkers 2020-05-15 11:28:26 -07:00
Jamie Hardt
1d63234447 Update ptulsconv.1
More elaboration
2020-02-16 15:38:28 -08:00
Jamie Hardt
edb641b7ec Update .gitignore
Added .DS_Store to gitignore
2020-02-16 15:38:18 -08:00
Jamie Hardt
eaf24ad6a8 Update ptulsconv.1 2020-02-16 15:23:25 -08:00
Jamie Hardt
6d5cd04c50 Create ptulsconv.1 2020-02-16 15:19:16 -08:00
Jamie Hardt
013081ef96 Delete TAG_FIELDS.md
Totally needless.
2020-02-16 12:46:45 -08:00
Jamie Hardt
d57ee88bc2 Create TAG_FIELDS.md
Based on the ProToolsText wiki page
2020-02-16 11:10:11 -08:00
Jamie Hardt
d29a08dadf Update README.md 2020-01-05 14:57:13 -08:00
Jamie Hardt
e806de0c1f Update README.md 2020-01-05 14:57:01 -08:00
Jamie Hardt
22edecdbbf Update __init__.py
Ver 0.3.3
2020-01-04 23:15:51 -08:00
Jamie Hardt
7c8a74aed9 Merge branch 'master' of https://github.com/iluvcapra/ptulsconv 2020-01-04 23:13:18 -08:00
Jamie Hardt
96a4cdb612 Added py3.8 to tests 2020-01-04 23:10:55 -08:00
9 changed files with 91 additions and 9 deletions

1
.gitignore vendored
View File

@@ -102,3 +102,4 @@ venv.bak/
# mypy
.mypy_cache/
.DS_Store

View File

@@ -1,6 +1,7 @@
language: python
python:
- "3.7"
- "3.8
script:
- "python -m unittest discover tests"
install:

View File

@@ -1,5 +1,8 @@
[![Build Status](https://travis-ci.com/iluvcapra/ptulsconv.svg?branch=master)](https://travis-ci.com/iluvcapra/ptulsconv)
![](https://img.shields.io/github/license/iluvcapra/ptulsconv.svg) ![](https://img.shields.io/pypi/pyversions/ptulsconv.svg) [![](https://img.shields.io/pypi/v/ptulsconv.svg)](https://pypi.org/project/ptulsconv/) ![](https://img.shields.io/pypi/wheel/ptulsconv.svg)
![Upload Python Package](https://github.com/iluvcapra/ptulsconv/workflows/Upload%20Python%20Package/badge.svg)
# ptulsconv
Read Pro Tools text exports and generate XML, JSON, reports
@@ -110,3 +113,4 @@ A clip name beginning with "&" will have its parsed clip name appended to the pr
cues will be applied (later clips having precedence). The clips need not be touching, and the clips will be combined
into a single row of the output. The start time of the first clip will become the start time of the row, and the finish
time of the last clip will become the finish time of the row.

24
man/ptulsconv.1 Normal file
View File

@@ -0,0 +1,24 @@
.\" Manpage for ptulsconv
.\" Contact https://github.com/iluvcapra/ptulsconv
.TH ptulsconv 1 "12 Feb 2020" "0.3.3" "ptulsconv man page"
.SH NAME
.BR "ptulsconv" " \- convert
.IR "Avid Pro Tools" " text exports"
.SH SYNOPSIS
ptulsconv [OPTIONS] Export.txt
.SH DESCRIPTION
Description
.SH OPTIONS
.IP "-h, --help"
show a help message and exit
.TP
.RI "-i " "TC"
Don't output events before this timecode, and offset all remaining
events to start at this timecode.
.TP
.RI "-o " "TC"
Don't output events occurring after this timecode.
.SH SEE ALSO
See Also
.SH AUTHOR
Jamie Hardt (contact at https://github.com/iluvcapra/ptulsconv)

View File

@@ -2,6 +2,6 @@ from .ptuls_grammar import protools_text_export_grammar
from .ptuls_parser_visitor import DictionaryParserVisitor
from .transformations import TimecodeInterpreter
__version__ = '0.3.1'
__version__ = '0.4.0'
__author__ = 'Jamie Hardt'
__license__ = 'MIT'

View File

@@ -1,10 +1,12 @@
from ptulsconv.commands import convert, dump_field_map
from ptulsconv.commands import convert, dump_field_map, dump_xform_options
from ptulsconv import __name__, __version__, __author__
from optparse import OptionParser, OptionGroup
from .reporting import print_status_style, print_banner_style, print_section_header_style, print_fatal_error
import datetime
import sys
import traceback
def main():
parser = OptionParser()
parser.usage = "ptulsconv TEXT_EXPORT.txt"
@@ -21,9 +23,15 @@ def main():
action='store_true',
default=False, help='Display tag mappings for the FMP XML output style and exit.')
parser.add_option('--show-available-transforms', dest='show_transforms',
action='store_true',
default=False, help='Display available built-in XSLT transforms.')
parser.add_option('--xform', dest='xslt', help="Convert with built-is XSLT transform.",
default=None, metavar='NAME')
(options, args) = parser.parse_args(sys.argv)
print_banner_style("%s %s (c) 2019 %s. All rights reserved." % (__name__, __version__, __author__))
print_banner_style("%s %s (c) 2020 %s. All rights reserved." % (__name__, __version__, __author__))
print_section_header_style("Startup")
print_status_style("This run started %s" % (datetime.datetime.now().isoformat() ) )
@@ -32,6 +40,10 @@ def main():
dump_field_map('ADR')
sys.exit(0)
if options.show_transforms:
dump_xform_options()
sys.exit(0)
if len(args) < 2:
print_fatal_error("Error: No input file")
parser.print_help(sys.stderr)
@@ -55,7 +67,7 @@ def main():
try:
convert(input_file=args[1], start=options.in_time, end=options.out_time,
include_muted=options.include_muted,
include_muted=options.include_muted, xsl=options.xslt,
progress=False, output=sys.stdout, log_output=sys.stderr)
except FileNotFoundError as e:
print_fatal_error("Error trying to read input file")
@@ -63,6 +75,7 @@ def main():
except Exception as e:
print_fatal_error("Error trying to convert file")
print("\033[31m" + e.__repr__() + "\033[0m", file=sys.stderr)
print(traceback.format_exc())
if __name__ == "__main__":

View File

@@ -1,8 +1,11 @@
import io
import json
import os
import os.path
import sys
from xml.etree.ElementTree import TreeBuilder, tostring
import subprocess
import pathlib
import ptulsconv
from .reporting import print_section_header_style, print_status_style
@@ -91,6 +94,21 @@ def fmp_dump(data, input_file_name, output):
output.write(xmlstr)
import glob
xslt_path = os.path.join(pathlib.Path(__file__).parent.absolute(), 'xslt')
def xform_options():
return glob.glob(os.path.join(xslt_path, "*.xsl"))
def dump_xform_options(output=sys.stdout):
print("# Available transforms:", file=output)
print("# Transform dir: %s" % (xslt_path), file=output)
for f in xform_options():
base = os.path.basename(f)
name, _ = os.path.splitext(base)
print("# " + name, file=output)
def dump_field_map(field_map_name, output=sys.stdout):
output.write("# Map of Tag fields to XML output columns\n")
output.write("# (in order of precedence)\n")
@@ -106,13 +124,28 @@ def dump_field_map(field_map_name, output=sys.stdout):
for n, field in enumerate(field_map):
for tag in field[0]:
output.write("# %-24s-> %-20s | %-8s| %-7i\n" % (tag[:24], field[1][:20], field[2].__name__, n+1 ))
output.write("# %-24s-> %-20s | %-8s| %-7i\n" % (tag[:24], field[1][:20], field[2].__name__, n + 1))
def fmp_transformed_dump(data, input_file, xsl_name, output):
pipe = io.StringIO()
print_status_style("Generating base XML")
fmp_dump(data, input_file, pipe)
strdata = pipe.getvalue()
print_status_style("Base XML size %i" % (len(strdata)))
print_status_style("Running xsltproc")
xsl_path = os.path.join(pathlib.Path(__file__).parent.absolute(), 'xslt', xsl_name + ".xsl")
print_status_style("Using xsl: %s" % (xsl_path))
result = subprocess.run(['xsltproc', xsl_path, '-'], input=strdata, text=True,
stdout=output, shell=False, check=True)
def convert(input_file, output_format='fmpxml', start=None, end=None,
progress=False, include_muted=False,
progress=False, include_muted=False, xsl=None,
output=sys.stdout, log_output=sys.stderr):
with open(input_file, 'r') as file:
print_section_header_style('Parsing')
ast = ptulsconv.protools_text_export_grammar.parse(file.read())
@@ -146,4 +179,9 @@ def convert(input_file, output_format='fmpxml', start=None, end=None,
if output_format == 'json':
json.dump(parsed, output)
elif output_format == 'fmpxml':
fmp_dump(parsed, input_file, output)
if xsl is None:
fmp_dump(parsed, input_file, output)
else:
print_section_header_style("Performing XSL Translation")
print_status_style("Using builtin translation: %s" % (xsl))
fmp_transformed_dump(parsed, input_file, xsl, output)

View File

@@ -24,12 +24,13 @@ setup(name='ptulsconv',
'Topic :: Multimedia',
'Topic :: Multimedia :: Sound/Audio',
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Development Status :: 4 - Beta",
"Topic :: Text Processing :: Filters",
"Topic :: Text Processing :: Markup :: XML"],
packages=['ptulsconv'],
keywords='text-processing parsers film tv editing editorial',
install_requires=['parsimonious','tqdm'],
install_requires=['parsimonious', 'tqdm'],
entry_points={
'console_scripts': [
'ptulsconv = ptulsconv.__main__:main'