Python Sample Export Videos

From truxwiki.com
Revision as of 16:55, 11 September 2024 by Sam (talk | contribs) (→‎Media Export)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This sample shows how to export video files from Truxton using Python.

Global Export

This will export the videos from an instance of Truxton.

 1 import sys
 2 sys.path.append('C:/Program Files/Truxton/SDK')
 3 import truxton
 4 
 5 def main() -> None:
 6 
 7  t = truxton.create()
 8  exporter = t.newexporter()
 9  exporter.addcriteria( exporter.fqgroup, truxton.Type_VideoCategory )
10  exporter.addoption( exporter.eoname, "{hash}.{ext}" )
11  exporter.addoption( exporter.eofolder, "c:\\temp" )
12  exporter.addoption( exporter.eotar, "UniqueVideosFromTruxton.tar" ) 
13  exporter.addoption( exporter.eounique, "1" )
14  exporter.addoption( exporter.eometa, "1" )
15  exporter.execute()
16 
17  return None
18 
19 if __name__ == "__main__":
20     sys.exit(main())

Code Walkthrough

The above code shows how to export a category of files from Truxton.

Line 8 creates the exporter.

Line 9 tells the exporter that we want all file types in the Type_VideoCategory.

Line 10 tells the exporter to use the MD5 hash as the filename and the extension registered for the type of file as the extension.

Line 11 will cause the exporter to write the output the file to the c:\temp folder.

Line 12 sets the format of the output to TAR in a file named UniqueVideosFromTruxton.tar

Line 13 tells the exporter to only output one copy of a file. Only unique file contents will be output, no copies.

Line 14 tells the exporter to include a file called FileMeta.json that contains metdata about the exported file.

Line 15 begins the process of exporting the files. This provides no feedback, we suggest you monitor the output folder.

Media Export

This will export the videos from a single media in Truxton. It is identical to the sample above but adds a single criteria that limits the results to a single media.

import sys
sys.path.append('C:/Program Files/Truxton/SDK')
import truxton

def main() -> None:

 t = truxton.create()
 exporter = t.newexporter()
 exporter.addcriteria( exporter.fqgroup, truxton.Type_VideoCategory )
 exporter.addcriteria( exporter.fqmedia, "1931adc6-fd91-0ecc-5597-21d058a2dfc7" )
 exporter.addoption( exporter.eoname, "{hash}.{ext}" )
 exporter.addoption( exporter.eofolder, "c:\\temp" )
 exporter.addoption( exporter.eotar, "UniqueVideosFromTruxton.tar" ) 
 exporter.addoption( exporter.eounique, "1" )
 exporter.addoption( exporter.eometa, "1" )
 exporter.execute()

 return None

if __name__ == "__main__":
    sys.exit(main())