diff --git a/source code/Send Captions to Final Cut Pro.workflow/Contents/QuickLook/Preview.png b/source code/Send Captions to Final Cut Pro.workflow/Contents/QuickLook/Preview.png
index e76c8e3..1146f92 100644
Binary files a/source code/Send Captions to Final Cut Pro.workflow/Contents/QuickLook/Preview.png and b/source code/Send Captions to Final Cut Pro.workflow/Contents/QuickLook/Preview.png differ
diff --git a/source code/Send Captions to Final Cut Pro.workflow/Contents/QuickLook/Thumbnail.png b/source code/Send Captions to Final Cut Pro.workflow/Contents/QuickLook/Thumbnail.png
index d4fdbf8..79a986e 100644
Binary files a/source code/Send Captions to Final Cut Pro.workflow/Contents/QuickLook/Thumbnail.png and b/source code/Send Captions to Final Cut Pro.workflow/Contents/QuickLook/Thumbnail.png differ
diff --git a/source code/Send Captions to Final Cut Pro.workflow/Contents/document.wflow b/source code/Send Captions to Final Cut Pro.workflow/Contents/document.wflow
index 4c514cb..084fabf 100644
--- a/source code/Send Captions to Final Cut Pro.workflow/Contents/document.wflow
+++ b/source code/Send Captions to Final Cut Pro.workflow/Contents/document.wflow
@@ -51,11 +51,7 @@
ActionParameters
source
- function run(input, parameters) {
//Include OSA library
var app = Application.currentApplication()
app.includeStandardAdditions = true
var userPath = app.pathTo ('home folder')
var captionsInput = input.toString()
//Applescript/JXA boilerplate function
function writeTextToFile(text, file, overwriteExistingContent) {
try {
// Convert the file to a string
var fileString = file.toString()
// Open the file for writing
var openedFile = app.openForAccess(Path(fileString), { writePermission: true })
// Clear the file if content should be overwritten
if (overwriteExistingContent) {
app.setEof(openedFile, { to: 0 })
}
// Write the new content to the file
app.write(text, { to: openedFile, startingAt: app.getEof(openedFile) })
// Close the file
app.closeAccess(openedFile)
// Return a boolean indicating that writing was successful
return true
}
catch(error) {
try {
// Close the file
app.closeAccess(file)
}
catch(error) {
// Report the error is closing failed
console.log(`Couldn't close file: ${error}`)
}
// Return a boolean indicating that writing was successful
return false
}
}
//Generate an XML text block
var textImport = captionsInput.split("\n\n")
var projectTitle = textImport[0]
var textArray = []
//Import iTT template
var iTTString = userPath.toString() + '/Library/Application Support/CaptionsToFCP/FCPCaptionsBlank.itt'
var iTTBlank = app.read(Path(iTTString))
for (var i=1; i< textImport.length; i++){
var sectionText = textImport[i].split("\n")
for (var j=0; j<sectionText.length; j=j+2){
var textPair = sectionText[j]+ (sectionText[j+1] ? ("<br/>" + sectionText[j+1]):"")
textArray.push(textPair)
}
}
var captionDuration = 10
var replacementString = ""
var indexCount = 0
for (let element of textArray) {
var beginTimeInSeconds = indexCount * captionDuration
var endTimeInSeconds = beginTimeInSeconds + captionDuration
var date = new Date(null);
date.setSeconds(beginTimeInSeconds);
var beginTimeISO = date.toISOString().substr(11, 8);
-
-date = new Date(null);
date.setSeconds(endTimeInSeconds);
var endTimeISO = date.toISOString().substr(11, 8);
var stringConstruction = "<p begin=\"" + beginTimeISO + ":00\" end=\"" + endTimeISO +":00\" region=\"bottom\">" + element + "</p>"
replacementString = replacementString + "\n"+ stringConstruction
indexCount += 1
}
var generateITT = iTTBlank.replace(/<p.*<\/p>/gm, replacementString)
//remove curly quotes (app.write doesn't like them)
generateITT = generateITT.replace(/[\u2018\u2019]/g,"'")
generateITT = generateITT.replace(/[\u201C\u201D]/g,"\"")
-generateITT = generateITT.replace(/[\u2014]/g,"\-")
-
//Create filepath
var fileDir = userPath.toString() + '/Movies/CaptionsToFCP/'
var now = new Date()
var fileName = fileDir + projectTitle + now + ".itt";
//save textblock to file
writeTextToFile (generateITT, fileName, true)
}
+ function run(input, parameters) {
//Include OSA library
var app = Application.currentApplication()
app.includeStandardAdditions = true
var userPath = app.pathTo ('home folder')
var captionsInput = input.toString()
//Applescript/JXA boilerplate function
function writeTextToFile(text, file, overwriteExistingContent) {
try {
// Convert the file to a string
var fileString = file.toString()
// Open the file for writing
var openedFile = app.openForAccess(Path(fileString), { writePermission: true })
// Clear the file if content should be overwritten
if (overwriteExistingContent) {
app.setEof(openedFile, { to: 0 })
}
// Write the new content to the file
app.write(text, { to: openedFile, startingAt: app.getEof(openedFile) })
// Close the file
app.closeAccess(openedFile)
// Return a boolean indicating that writing was successful
return true
}
catch(error) {
try {
// Close the file
app.closeAccess(file)
}
catch(error) {
// Report the error is closing failed
console.log(`Couldn't close file: ${error}`)
}
// Return a boolean indicating that writing was successful
return false
}
}
//Generate an XML text block
var textImport = captionsInput.split("\n\n")
var projectTitle = textImport[0]
var textArray = []
//Import iTT template
var iTTString = userPath.toString() + '/Library/Application Support/CaptionsToFCP/FCPCaptionsBlank.itt'
var iTTBlank = app.read(Path(iTTString))
for (var i=1; i< textImport.length; i++){
var sectionText = textImport[i].split("\n")
for (var j=0; j<sectionText.length; j=j+2){
var textPair = sectionText[j]+ (sectionText[j+1] ? ("<br/>" + sectionText[j+1]):"")
textArray.push(textPair)
}
}
var captionDuration = 10
var replacementString = ""
var indexCount = 0
for (let element of textArray) {
var beginTimeInSeconds = indexCount * captionDuration
var endTimeInSeconds = beginTimeInSeconds + captionDuration
var date = new Date(null);
date.setSeconds(beginTimeInSeconds);
var beginTimeISO = date.toISOString().substr(11, 8);
date = new Date(null);
date.setSeconds(endTimeInSeconds);
var endTimeISO = date.toISOString().substr(11, 8);
var stringConstruction = "<p begin=\"" + beginTimeISO + ":00\" end=\"" + endTimeISO +":00\" region=\"bottom\">" + element + "</p>"
replacementString = replacementString + "\n"+ stringConstruction
indexCount += 1
}
var generateITT = iTTBlank.replace(/<p.*<\/p>/gm, replacementString)
//remove curly quotes (app.write doesn't like them)
generateITT = generateITT.replace(/[\u2018\u2019]/g,"'")
generateITT = generateITT.replace(/[\u201C\u201D]/g,"\"")
generateITT = generateITT.replace(/[\u2014]/g,"\-")
//Create filepath
var fileDir = userPath.toString() + '/Movies/CaptionsToFCP/'
var now = new Date()
var fileName = fileDir + projectTitle + now + ".itt";
//save textblock to file
writeTextToFile (generateITT, fileName, true)
}
BundleIdentifier
com.apple.Automator.RunJavaScript
@@ -110,16 +106,161 @@ generateITT = generateITT.replace(/[\u2014]/g,"\-")
isViewVisible
location
- 312.750000:586.000000
+ 299.500000:420.000000
nibPath
/System/Library/Automator/Run JavaScript.action/Contents/Resources/Base.lproj/main.nib
isViewVisible
+
+ action
+
+ AMAccepts
+
+ Container
+ List
+ Optional
+
+ Types
+
+
+ AMActionVersion
+ 1.0
+ AMApplication
+
+ Automator
+
+ AMParameterProperties
+
+ message
+
+ tokenizedValue
+
+ View your captions in Movies/CaptionsToFCP
+
+
+ subtitle
+
+ title
+
+ tokenizedValue
+
+ Script complete
+
+
+
+ AMProvides
+
+ Container
+ List
+ Types
+
+
+ ActionBundlePath
+ /System/Library/Automator/Display Notification.action
+ ActionName
+ Display Notification
+ ActionParameters
+
+ message
+
+ subtitle
+
+ title
+ Script complete
+
+ BundleIdentifier
+ com.apple.Automator.Display-Notification
+ CFBundleVersion
+ 1.0
+ CanShowSelectedItemsWhenRun
+
+ CanShowWhenRun
+
+ Category
+
+ AMCategoryUtilities
+
+ Class Name
+ AMDisplayNotificationAction
+ InputUUID
+ CF877E3A-9952-4C5C-8BDD-FDA54AC677D9
+ Keywords
+
+ OutputUUID
+ E1722104-5DBE-4A9C-A7BD-8E485C2C29D6
+ UUID
+ C8992ECD-AEEA-4873-8C5E-AC8C253E83A4
+ UnlocalizedApplications
+
+ Automator
+
+ arguments
+
+ 0
+
+ default value
+
+ name
+ message
+ required
+ 0
+ type
+ 0
+ uuid
+ 0
+
+ 1
+
+ default value
+
+ name
+ subtitle
+ required
+ 0
+ type
+ 0
+ uuid
+ 1
+
+ 2
+
+ default value
+
+ name
+ title
+ required
+ 0
+ type
+ 0
+ uuid
+ 2
+
+
+ conversionLabel
+ 0
+ isViewVisible
+
+ location
+ 299.500000:609.000000
+ nibPath
+ /System/Library/Automator/Display Notification.action/Contents/Resources/Base.lproj/main.nib
+
+ isViewVisible
+
+
connectors
-
+
+ ECEE8D09-4D81-4522-82AD-6FA144B1A9C2
+
+ from
+ CB6A29FB-1155-40BD-B9CF-416BE4072E23 - CB6A29FB-1155-40BD-B9CF-416BE4072E23
+ to
+ C8992ECD-AEEA-4873-8C5E-AC8C253E83A4 - C8992ECD-AEEA-4873-8C5E-AC8C253E83A4
+
+
workflowMetaData
applicationBundleIDsByPath