@@ -74,67 +74,69 @@ def add_complex_child(parent, element_name, subelement_name, role_name, subeleme
7474
7575 parser = argparse .ArgumentParser (
7676 description = 'Extract metadata from BWF and create PBCore XML, incorporating existing OHMS XML as an extension' )
77- parser .add_argument ('infile' , help = "WAV file" )
77+ parser .add_argument ('infile' , nargs = "+" , help = "WAV file(s) " )
7878 args = parser .parse_args ()
7979
80- infile = args .infile
81- ohmsfile = args .infile .rsplit ('.' , 1 )[0 ] + '_ohms.xml'
82- outfile = args .infile .rsplit ('.' , 1 )[0 ] + '_pbcore.xml'
83-
84- metadata = get_bwf_core (True , infile )
85- metadata .update (get_bwf_tech (True , infile ))
86- metadata .update (get_xmp (infile , ["bwfmetaedit" , "--specialchars" , "--accept-nopadding" ]))
87-
88- pbcore_root = ET .Element (qualified_element ("pbcore" , "pbcoreDescriptionDocument" ))
89- pbcore_root .append (ET .Comment ('Automatically generated by bwf2pbcore. DO NOT EDIT BY HAND.' ))
90- pbcore_root .append (ET .Comment ('To make changes, edit the internal metadata in {} and re-run bwf2pbcore' .format (infile )))
91-
92- add_child (pbcore_root , "pbcoreAssetType" , metadata ["form" ])
93- add_child (pbcore_root , "pbcoreAssetDate" , metadata ["ICRD" ])
94- add_child (pbcore_root , "pbcoreIdentifier" , metadata ["FileContent" ], {"source" : "local" })
95- add_child (pbcore_root , "pbcoreTitle" , metadata ["INAM" ])
96-
97- add_multivalue_child (pbcore_root , "pbcoreSubject" , metadata ["topics" ], {"subjectType" : "topic" })
98- add_multivalue_child (pbcore_root , "pbcoreSubject" , metadata ["names" ], {"subjectType" : "name" })
99- add_multivalue_child (pbcore_root , "pbcoreSubject" , metadata ["events" ], {"subjectType" : "period" })
100- add_multivalue_child (pbcore_root , "pbcoreSubject" , metadata ["places" ], {"subjectType" : "geographic" })
101-
102- add_child (pbcore_root , "pbcoreDescription" , metadata ["xmp_description" ])
103-
104- add_complex_child (pbcore_root , "pbcoreContributor" , "contributor" ,
105- "contributorRole" , metadata ["interviewer" ], "interviewer" )
106- add_complex_child (pbcore_root , "pbcoreContributor" , "contributor" ,
107- "contributorRole" , metadata ["interviewee" ], "interviewee" )
108- add_complex_child (pbcore_root , "pbcoreContributor" , "contributor" ,
109- "contributorRole" , metadata ["host" ], "host" )
110- add_complex_child (pbcore_root , "pbcoreContributor" , "contributor" ,
111- "contributorRole" , metadata ["speaker" ], "speaker" )
112- add_complex_child (pbcore_root , "pbcoreContributor" , "contributor" ,
113- "contributorRole" , metadata ["performer" ], "performer" )
114-
115- if metadata ["owner" ] != "" :
116- publisher = ET .SubElement (pbcore_root , qualified_element ("pbcore" , "pbcorePublisher" ))
117- add_child (publisher , "publisher" , metadata ["owner" ])
118- add_child (publisher , "publisherRole" , "copyright holder" )
119-
120- rights = ET .SubElement (pbcore_root , qualified_element ("pbcore" , "pbcoreRightsSummary" ))
121- add_child (rights , "rightsSummary" , metadata ["ICOP" ])
122-
123- instantiation = ET .SubElement (pbcore_root , qualified_element ("pbcore" , "pbcoreInstantiation" ))
124- add_child (instantiation , "instantiationIdentifier" , metadata ["OriginatorReference" ], attributes = {"source" : "local" })
125- add_child (instantiation , "instantiationLocation" , infile )
126- add_child (instantiation , "instantiationDuration" , metadata ["Duration" ].split ('.' )[0 ])
127- add_child (instantiation , "instantiationLanguage" , "" .join (metadata ["language" ].split ())) # eliminate whitespace
128-
129- add_child (pbcore_root , "pbcoreAnnotation" , metadata ["ISRC" ], {"annotationType" : "source collection" })
130-
131- if path .isfile (ohmsfile ):
132- ohms_root = ET .parse (ohmsfile ).getroot ()
133- extension = add_child (instantiation , "instantiationExtension" , "" , allow_empty = True )
134- embedded = add_child (extension , "extensionEmbedded" , "" , allow_empty = True )
135- embedded .append (ohms_root )
136-
137- ET .ElementTree (pbcore_root ).write (outfile , xml_declaration = True , encoding = 'utf-8' )
80+ for infile in args .infile :
81+ ohmsfile = infile .rsplit ('.' , 1 )[0 ] + '_ohms.xml'
82+ outfile = infile .rsplit ('.' , 1 )[0 ] + '_pbcore.xml'
83+
84+ metadata = get_bwf_core (True , infile )
85+ metadata .update (get_bwf_tech (True , infile ))
86+ metadata .update (get_xmp (infile , ["bwfmetaedit" , "--specialchars" , "--accept-nopadding" ]))
87+
88+ pbcore_root = ET .Element (qualified_element ("pbcore" , "pbcoreDescriptionDocument" ))
89+ pbcore_root .append (ET .Comment ('Automatically generated by bwf2pbcore. DO NOT EDIT BY HAND.' ))
90+ pbcore_root .append (ET .Comment ('To make changes, edit the internal metadata in {}' .format (infile )))
91+ pbcore_root .append (ET .Comment ('and re-run bwf2pbcore' ))
92+
93+ add_child (pbcore_root , "pbcoreAssetType" , metadata ["form" ])
94+ add_child (pbcore_root , "pbcoreAssetDate" , metadata ["ICRD" ])
95+ add_child (pbcore_root , "pbcoreIdentifier" , metadata ["FileContent" ], {"source" : "local" })
96+ add_child (pbcore_root , "pbcoreTitle" , metadata ["INAM" ])
97+
98+ add_multivalue_child (pbcore_root , "pbcoreSubject" , metadata ["topics" ], {"subjectType" : "topic" })
99+ add_multivalue_child (pbcore_root , "pbcoreSubject" , metadata ["names" ], {"subjectType" : "name" })
100+ add_multivalue_child (pbcore_root , "pbcoreSubject" , metadata ["events" ], {"subjectType" : "period" })
101+ add_multivalue_child (pbcore_root , "pbcoreSubject" , metadata ["places" ], {"subjectType" : "geographic" })
102+
103+ add_child (pbcore_root , "pbcoreDescription" , metadata ["xmp_description" ])
104+
105+ add_complex_child (pbcore_root , "pbcoreContributor" , "contributor" ,
106+ "contributorRole" , metadata ["interviewer" ], "interviewer" )
107+ add_complex_child (pbcore_root , "pbcoreContributor" , "contributor" ,
108+ "contributorRole" , metadata ["interviewee" ], "interviewee" )
109+ add_complex_child (pbcore_root , "pbcoreContributor" , "contributor" ,
110+ "contributorRole" , metadata ["host" ], "host" )
111+ add_complex_child (pbcore_root , "pbcoreContributor" , "contributor" ,
112+ "contributorRole" , metadata ["speaker" ], "speaker" )
113+ add_complex_child (pbcore_root , "pbcoreContributor" , "contributor" ,
114+ "contributorRole" , metadata ["performer" ], "performer" )
115+
116+ if metadata ["owner" ] != "" :
117+ publisher = ET .SubElement (pbcore_root , qualified_element ("pbcore" , "pbcorePublisher" ))
118+ add_child (publisher , "publisher" , metadata ["owner" ])
119+ add_child (publisher , "publisherRole" , "copyright holder" )
120+
121+ rights = ET .SubElement (pbcore_root , qualified_element ("pbcore" , "pbcoreRightsSummary" ))
122+ add_child (rights , "rightsSummary" , metadata ["ICOP" ])
123+
124+ instantiation = ET .SubElement (pbcore_root , qualified_element ("pbcore" , "pbcoreInstantiation" ))
125+ add_child (instantiation , "instantiationIdentifier" , metadata ["OriginatorReference" ],
126+ attributes = {"source" : "local" })
127+ add_child (instantiation , "instantiationLocation" , infile )
128+ add_child (instantiation , "instantiationDuration" , metadata ["Duration" ].split ('.' )[0 ])
129+ add_child (instantiation , "instantiationLanguage" , "" .join (metadata ["language" ].split ())) # eliminate whitespace
130+
131+ add_child (pbcore_root , "pbcoreAnnotation" , metadata ["ISRC" ], {"annotationType" : "source collection" })
132+
133+ if path .isfile (ohmsfile ):
134+ ohms_root = ET .parse (ohmsfile ).getroot ()
135+ extension = add_child (instantiation , "instantiationExtension" , "" , allow_empty = True )
136+ embedded = add_child (extension , "extensionEmbedded" , "" , allow_empty = True )
137+ embedded .append (ohms_root )
138+
139+ ET .ElementTree (pbcore_root ).write (outfile , xml_declaration = True , encoding = 'utf-8' )
138140
139141
140142if __name__ == '__main__' :
0 commit comments