AppleScript XML TTML

[TTML]現時点でのまとめ(自分用)更新

Timed Text Markup Language 1 (TTML1) - W3C
https://www.w3.org/TR/2018/REC-ttml1-20181108/
Timed Text Markup Language 2 (TTML2) - W3C
https://www.w3.org/TR/2018/REC-ttml2-20181108/



iTT (iTunes Timed Text)
iTunes Video and Audio Asset Guide 5.3.12 
Lyrics Example Annotations
[TTML] TTMLファイルにiTT (iTunes Timed Text)の要素の付与
https://quicktimer.cocolog-nifty.com/icefloe/2023/12/post-dc3854.html


TTML関連
https://quicktimer.cocolog-nifty.com/icefloe/cat76053036/index.html
LRC関連
https://quicktimer.cocolog-nifty.com/icefloe/cat76053331/index.html
SRT関連
https://quicktimer.cocolog-nifty.com/icefloe/cat76053335/index.html
FFMETADATA1
https://quicktimer.cocolog-nifty.com/icefloe/2023/04/post-dd127e.html
[TTML]編集にはVisual Studio Codeと機能拡張がベター
https://quicktimer.cocolog-nifty.com/icefloe/2023/08/post-bf9686.html


Mac表示
Screen-20230112-120243

モバイル表示
Screen-20230112-120429



JEDIT用カラーリングファイル

ダウンロード - ttml_coloring.plist




【留意】
R0-R2等上部に設定すると、iPhone等のカメラの出っ張りに隠れてしまう表示がある
なので
意図したポジションにCCを出したい場合は
R4からR10ぐらいが確実かもしれない
通常の1行の場合はR14にしておけば良いのか?な?


ポジションサンプル(現時点)
留意:displayAlignはafterで換算しています
extentを0%設定しているのは、値を入れると『現時点で』意図する表示にならないので0%にしていますが、本来は文字のサイズに対応して5%ぐらいを指定するのが良いのかも?しれない

    <layout>

      <region xml:id="R0" tts:origin="0.000% 5%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R1" tts:origin="0.000% 19%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R2" tts:origin="0.000% 25%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R3" tts:origin="0.000% 29%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R4" tts:origin="0.000% 34%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R5" tts:origin="0.000% 40%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R6" tts:origin="0.000% 45%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R7" tts:origin="0.000% 50%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R8" tts:origin="0.000% 56%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R9" tts:origin="0.000% 61%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R10" tts:origin="0.000% 67%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R11" tts:origin="0.000% 72%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R12" tts:origin="0.000% 80%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R13" tts:origin="0.000% 86%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R14" tts:origin="0.000% 95%" tts:extent="100.000% 0%" tts:displayAlign="after" />

    </layout>


ツール類 基本XMLなので
Visual Studio Code
https://code.visualstudio.com/
Visual Studio Code用機能拡張 
XML Tools
https://marketplace.visualstudio.com/items?itemName=DotJoshJohnson.xml
Red HatのXMLはソースの閲覧には良いが 編集には向かない(執筆時点)
https://marketplace.visualstudio.com/items?itemName=redhat.vscode-xml

ツール類
ssa2srt
https://strawberrysw.com/ssa2srt/
Screen-5
ツール類
Jubler Subtitle Εditor
https://www.jubler.org
Jublerscreenshotwebp
記事発行時点でYoutubeではlayout内にstyleを記述すると
一部の属性で無視される
202404130147371536x1092
ポジショニングについてのメモ Ttml0011920x1080Ttml0021920x1080Ttml0031920x1080Ttml0041920x1080Ttml0051920x1080Ttml0061920x1080
縦書き置換用正規表現
([\p{Hiragana}\p{Katakana}\p{Han}])
\1<br />

202404150249351002x736

|

[TTML]現時点でのまとめ(自分用)

Timed Text Markup Language 1 (TTML1) - W3C
https://www.w3.org/TR/2018/REC-ttml1-20181108/
Timed Text Markup Language 2 (TTML2) - W3C
https://www.w3.org/TR/2018/REC-ttml2-20181108/



iTT (iTunes Timed Text)
iTunes Video and Audio Asset Guide 5.3.12 
Lyrics Example Annotations
[TTML] TTMLファイルにiTT (iTunes Timed Text)の要素の付与
https://quicktimer.cocolog-nifty.com/icefloe/2023/12/post-dc3854.html


TTML関連
https://quicktimer.cocolog-nifty.com/icefloe/cat76053036/index.html
LRC関連
https://quicktimer.cocolog-nifty.com/icefloe/cat76053331/index.html
SRT関連
https://quicktimer.cocolog-nifty.com/icefloe/cat76053335/index.html
FFMETADATA1
https://quicktimer.cocolog-nifty.com/icefloe/2023/04/post-dd127e.html
[TTML]編集にはVisual Studio Codeと機能拡張がベター
https://quicktimer.cocolog-nifty.com/icefloe/2023/08/post-bf9686.html


Mac表示
Screen-20230112-120243

モバイル表示
Screen-20230112-120429



JEDIT用カラーリングファイル

ダウンロード - ttml_coloring.plist




【留意】
R0-R2等上部に設定すると、iPhone等のカメラの出っ張りに隠れてしまう表示がある
なので
意図したポジションにCCを出したい場合は
R4からR10ぐらいが確実かもしれない
通常の1行の場合はR14にしておけば良いのか?な?


ポジションサンプル(現時点)
留意:displayAlignはafterで換算しています
extentを0%設定しているのは、値を入れると『現時点で』意図する表示にならないので0%にしていますが、本来は文字のサイズに対応して5%ぐらいを指定するのが良いのかも?しれない

    <layout>

      <region xml:id="R0" tts:origin="0.000% 5%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R1" tts:origin="0.000% 19%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R2" tts:origin="0.000% 25%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R3" tts:origin="0.000% 29%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R4" tts:origin="0.000% 34%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R5" tts:origin="0.000% 40%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R6" tts:origin="0.000% 45%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R7" tts:origin="0.000% 50%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R8" tts:origin="0.000% 56%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R9" tts:origin="0.000% 61%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R10" tts:origin="0.000% 67%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R11" tts:origin="0.000% 72%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R12" tts:origin="0.000% 80%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R13" tts:origin="0.000% 86%" tts:extent="100.000% 0%" tts:displayAlign="after" />

      <region xml:id="R14" tts:origin="0.000% 95%" tts:extent="100.000% 0%" tts:displayAlign="after" />

    </layout>


ツール類 基本XMLなので
Visual Studio Code
https://code.visualstudio.com/
Visual Studio Code用機能拡張 
XML Tools
https://marketplace.visualstudio.com/items?itemName=DotJoshJohnson.xml
Red HatのXMLはソースの閲覧には良いが 編集には向かない(執筆時点)
https://marketplace.visualstudio.com/items?itemName=redhat.vscode-xml

ツール類
ssa2srt
https://strawberrysw.com/ssa2srt/
Screen-5
ツール類
Jubler Subtitle Εditor
https://www.jubler.org
Jublerscreenshotwebp

|

[TTML]字幕に時間表示 カウントアップv3(色々治した)


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
(*

com.cocolog-nifty.quicktimer.icefloe
*)
#
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application

###################################
##### 設定項目
###################################

###適応させるビデオのFPS値
set strFPS to ("50") as text
###【1】何分ぶん作成するか?
set numMinute to 60 as integer

###【2】カウント『アップ?=true』『ダウン?= false』
set boolCountUp to true as boolean

###【2】カウントアップ値どうする?
#100分の1単位は設定可能だがYoutube上で再現されないので最低値は10分の1秒まで
#カウントアップ値(10分の1秒)の場合
# set numTimeInterval to (100 / 1000)
#カウントアップ値(1秒)の場合
set numTimeInterval to 1


###################################
##### 処理開始
###################################
##18000=60x30x10=30分
###【1】繰り返し回数計算
if numTimeInterval < 1 then
  set numRepeatTImes to (numMinute * 60 * 10) as integer
  set boolDecimal to true as boolean
else
  set numRepeatTImes to (numMinute * 60) as integer
  set boolDecimal to false as boolean
end if
###################################
##### 日付コンポーネント
###################################
###【2】『アップ?』『ダウン?』
if boolCountUp is true then
  #保存ファイル名
  set strSaveFileName to "カウントアップタイマー.ttml" as text
  #カウントアップ値
  set numTimeInterval to numTimeInterval
  ###【カウントアップ】コンポーネント
  #タイムライン用の1時間スタート値
  set ocidDateComponents to refMe's NSDateComponents's alloc()'s init()
ocidDateComponents's setHour:1
ocidDateComponents's setMinute:0
ocidDateComponents's setSecond:0
  #表示テキスト用の0時スタート値
  set ocidDateComponentsText to refMe's NSDateComponents's alloc()'s init()
ocidDateComponentsText's setHour:0
ocidDateComponentsText's setMinute:0
ocidDateComponentsText's setSecond:0
else
  #保存ファイル名
  set strSaveFileName to "カウントダウンタイマー.ttml" as text
  #カウントダウン
  set numTimeInterval to -(numTimeInterval)
  ###【カウントダウン】コンポーネント
  #タイムライン用の1時間スタート値
  set ocidDateComponents to refMe's NSDateComponents's alloc()'s init()
ocidDateComponents's setHour:1
ocidDateComponents's setMinute:(numMinute)
ocidDateComponents's setSecond:0
  #表示テキスト用の0時スタート値
  set ocidDateComponentsText to refMe's NSDateComponents's alloc()'s init()
ocidDateComponentsText's setHour:0
ocidDateComponentsText's setMinute:(numMinute)
ocidDateComponentsText's setSecond:0
end if
###カレンダー初期化
set ocidCalendar to refMe's NSCalendar's currentCalendar()
set ocidCalendarText to ocidCalendar
###↑の時間をセット
set ocidDate to ocidCalendar's dateFromComponents:(ocidDateComponents)
set ocidDateText to ocidCalendarText's dateFromComponents:(ocidDateComponentsText)
###################################
###日付コンポーネントを利用したカウントダウン
###################################
###【XML】 TTMLのdivエレメントを生成しておく
set ocidDiv to refMe's NSXMLNode's elementWithName:"div"
set ocidSetAttribute to refMe's NSXMLNode's attributeWithName:"xml:id" stringValue:"D0"
ocidDiv's addAttribute:(ocidSetAttribute)
set ocidSetAttribute to refMe's NSXMLNode's attributeWithName:"region" stringValue:"R0"
ocidDiv's addAttribute:(ocidSetAttribute)
set ocidSetAttribute to refMe's NSXMLNode's attributeWithName:"style" stringValue:"S0"
ocidDiv's addAttribute:(ocidSetAttribute)

###繰返しカウントアップ
repeat numRepeatTImes times
  
  ###【スタートタイム】日付時間の書式設定
  set ocidDateFormatterForBegin to refMe's NSDateFormatter's alloc()'s init()
  ##ocidDateFormatterForBegin's setLocale:(refMe's NSLocale's localeWithLocaleIdentifier:"en_US")
ocidDateFormatterForBegin's setDateFormat:"HH:mm:ss.S00"
  set ocidDateStringsBegin to ocidDateFormatterForBegin's stringFromDate:(ocidDate)
  ###【表示テキスト】日付時間の書式設定
  set ocidDateFormatterForText to refMe's NSDateFormatter's alloc()'s init()
  ##ocidDateFormatterForText's setLocale:(refMe's NSLocale's localeWithLocaleIdentifier:"en_US")
  ## ocidDateFormatterForText's setDateFormat:"H:mm:ss.S"
  if boolDecimal is true then
ocidDateFormatterForText's setDateFormat:"H:mm:ss.S"
  else
ocidDateFormatterForText's setDateFormat:"H:mm:ss"
  end if
  ###書式でテキスト化
  set ocidDateStrings to ocidDateFormatterForText's stringFromDate:(ocidDateText)
  
  ###次のカウントアップ用に、カウントアップした値をセット
  ###タイムインターバルをセット
  set ocidNewDate to ocidDate's dateByAddingTimeInterval:(numTimeInterval)
  set ocidNewDateText to ocidDateText's dateByAddingTimeInterval:(numTimeInterval)
  
  ###【エンドタイム】日付時間の書式設定
  set ocidDateFormatterForEnd to refMe's NSDateFormatter's alloc()'s init()
  ##ocidDateFormatterForEnd's setLocale:(refMe's NSLocale's localeWithLocaleIdentifier:"en_US")
ocidDateFormatterForEnd's setDateFormat:"HH:mm:ss.S00"
  set ocidDateStringsEnd to ocidDateFormatterForEnd's stringFromDate:(ocidNewDate)
  ###【XML】
  set ocidParagraphElement to (refMe's NSXMLElement's alloc()'s initWithName:("p"))
  #表示テキストをセット
  set ocidSetNode to (refMe's NSXMLNode's textWithStringValue:(ocidDateStrings))
(ocidParagraphElement's addChild:(ocidSetNode))
  #スタートタイム
  set ocidSetNode to refMe's NSXMLNode's attributeWithName:("begin") stringValue:(ocidDateStringsBegin)
ocidParagraphElement's addAttribute:(ocidSetNode)
  #エンドタイム
  set ocidSetNode to refMe's NSXMLNode's attributeWithName:("end") stringValue:(ocidDateStringsEnd)
ocidParagraphElement's addAttribute:(ocidSetNode)
  #生成されたPエレメントをDIVエレメントにセット
(ocidDiv's addChild:(ocidParagraphElement))
  
  ###次のリピートに備える
  set ocidDate to ocidNewDate
  set ocidDateText to ocidNewDateText
  ###出来上がりP要素をテキストに『アペンド』する
  #ocidOutPutStrings's appendString:strXMLP
end repeat

########################
##TTML生成開始

###ROOT エレメント
set ocidRootElement to refMe's NSXMLElement's alloc()'s initWithName:("tt")
###ROOT エレメントにネームスペース
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("ttp:frameRate") stringValue:(strFPS))
# smpte clock media から ビデオ編集用ならmediaが使いやすい
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("ttp:timeBase") stringValue:("media"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xml:lang") stringValue:("en"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xmlns") stringValue:("http://www.w3.org/ns/ttml"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xmlns:ttm") stringValue:("http://www.w3.org/ns/ttml#metadata"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xmlns:tts") stringValue:("http://www.w3.org/ns/ttml#styling"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xmlns:ttp") stringValue:("http://www.w3.org/ns/ttml#parameter"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xmlns:ittp") stringValue:("http://www.w3.org/ns/ttml/profile/imsc1#parameter"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xmlns:itts") stringValue:("http://www.w3.org/ns/ttml/profile/imsc1#styling"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("ttp:profile") stringValue:("http://www.w3.org/ns/ttml/profile/imsc1/text"))

############ head
set ocidHead to refMe's NSXMLNode's elementWithName:"head"
ocidRootElement's addChild:(ocidHead)
##styling
set ocidStyling to refMe's NSXMLNode's elementWithName:"styling"
set ocidStyle to refMe's NSXMLNode's elementWithName:"style"

set ocidElementDict to refMe's NSXMLNode's attributeWithName:"xml:id" stringValue:"S0"
ocidStyle's addAttribute:ocidElementDict
set ocidElementDict to refMe's NSXMLNode's attributeWithName:"tts:color" stringValue:"#ffffff"
ocidStyle's addAttribute:ocidElementDict
set ocidElementDict to refMe's NSXMLNode's attributeWithName:"tts:opacity" stringValue:"0.75"
ocidStyle's addAttribute:ocidElementDict
set ocidElementDict to refMe's NSXMLNode's attributeWithName:"tts:fontSize" stringValue:"100%"
ocidStyle's addAttribute:ocidElementDict
### "default"| "monospace"| "sansSerif"| "serif"| "monospaceSansSerif"| "monospaceSerif"| "proportionalSansSerif"| "proportionalSerif"
set ocidElementDict to refMe's NSXMLNode's attributeWithName:"tts:fontFamily" stringValue:"proportionalSansSerif"
ocidStyle's addAttribute:ocidElementDict
## left | center | right | start | end
set ocidElementDict to refMe's NSXMLNode's attributeWithName:"tts:textAlign" stringValue:"start"
ocidStyle's addAttribute:ocidElementDict

ocidStyling's addChild:(ocidStyle)
ocidHead's addChild:(ocidStyling)

############ layout
set ocidLayout to refMe's NSXMLNode's elementWithName:"layout"
ocidHead's addChild:ocidLayout
##region
set ocidRegion to refMe's NSXMLNode's elementWithName:"region"
ocidLayout's addChild:ocidRegion
set ocidElementDict to refMe's NSXMLNode's attributeWithName:"xml:id" stringValue:"R0"
ocidRegion's addAttribute:ocidElementDict
set ocidElementDict to refMe's NSXMLNode's attributeWithName:"tts:origin" stringValue:"0.000% 30%"
ocidRegion's addAttribute:ocidElementDict
set ocidElementDict to refMe's NSXMLNode's attributeWithName:"tts:extent" stringValue:"100.000% 0%"
ocidRegion's addAttribute:ocidElementDict
###before | center | after
set ocidElementDict to refMe's NSXMLNode's attributeWithName:"tts:displayAlign" stringValue:"center"
ocidRegion's addAttribute:ocidElementDict

############ body
set ocidBodyElement to refMe's NSXMLNode's elementWithName:"body"
##DIV要素をBODYにセット
(ocidBodyElement's addChild:(ocidDiv))
##BODYをROOTにセット
ocidRootElement's addChild:(ocidBodyElement)
##
set ocidOutPutXML to refMe's NSXMLDocument's alloc()'s initWithRootElement:(ocidRootElement)
ocidOutPutXML's setVersion:"1.0"
ocidOutPutXML's setCharacterEncoding:"UTF-8"

####################
####保存
##################
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
set ocidSaveFilePathURL to ocidDesktopDirPathURL's URLByAppendingPathComponent:(strSaveFileName)

###【6】XMLデータにして(ここでテキスト形式のXMLに)
set ocidXMLdata to ocidOutPutXML's XMLDataWithOptions:(refMe's NSXMLNodePrettyPrint)
###【7】ファイルに保存
set listDone to ocidXMLdata's writeToURL:(ocidSaveFilePathURL) options:(refMe's NSDataWritingAtomic) |error|:(reference)

|

[TTML]テキストデータからTTMLを作成する(ちょっと修正)


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()

##設定項目
###カウントアップ値(10分の1秒) 例=3.0だと行毎で3秒間隔で作成
set numTimeInterval to 3.0 as number
###時間のスタート 1か0か-->仕様を確認してください
set numStartH to 1 as integer
#【A】ROOT
##FPS 1秒間のフレーム数 ビデオの仕様を確認して設定
##指定のない場合は25 50 100 が計算しやすい
set strFPS to ("50") as text
#【B】HEAD共通のID
set strID to ("div01") as text
#【B−1】HEADのstyling
#配置位置 Youtubeは基本center
#"before" | "center" | "after" | "justify"
set strDisplayAlign to ("center") as text
##########
##テキスト
##文字色 HEX指定
set strTextColor to ("#ffffff") as text
# 0-1 0が完全透明 1が透明なし
set strTextOpacity to ("0.8") as text
#テキストのアウトライン
#なしの場合はテキスト色 で0px
set strTextOutline to ("#646364 1px") as text

##テキストの寄せ位置 Youtubeは基本center
#"left" | "center" | "right" | "start" | "end" | "justify"
set strTextAlign to ("center") as text
##########
##フォント
##100%=72pt=1in 50%で36pt 25%=18pt
set strFontSize to ("100%") as text
##フォントファミリー
##PostScript FamilyNameで指定も可能
#"default","monospace","sansSerif","serif","monospaceSansSerif","monospaceSerif","proportionalSansSerif","proportionalSerif"
set strFontFamily to ("proportionalSerif") as text
##フォントの装飾 基本はnormal
#"normal", "italic" ,"oblique"
set strFontStyle to ("normal") as text
#"normal" | "bold" 基本はnormal
set strFontWeight to ("normal") as text
##シャドウ RGBA指定も可
set strTextShadow to ("1.1px 1.1px 8px #081020")

#【B−2】HEADのlayout
#前半の0%は固定 後半の値 100%が画面下部 0%が画面上部
set strOrigin to ("0% 90%") as text
# 他の値はYoutubeでは無用なので設定省略

#############################
##ダイアログを前面に
tell current application
  set strName to name as text
end tell
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
############ デフォルトロケーション
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
############UTIリスト
set listUTI to {"public.text", "public.plain-text"}
set strMes to ("ファイルを選んでください") as text
set strPrompt to ("ファイルを選んでください") as text
try
  ### ファイル選択時
  set aliasFilePath to (choose file strMes with prompt strPrompt default location aliasDefaultLocation of type listUTI without invisibles, multiple selections allowed and showing package contents) as alias
on error
log "エラーしました"
return "エラーしました"
end try
###入力パス
set strFilePath to (POSIX path of aliasFilePath) as text
set ocidFilePathStr to (refMe's NSString's stringWithString:(strFilePath))
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
set strFileName to (ocidFilePathURL's lastPathComponent()) as text
########################
##テキスト読み込み
set listReadText to refMe's NSString's alloc()'s initWithContentsOfURL:(ocidFilePathURL) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)
set ocidReadText to (item 1 of listReadText)
####行毎のリストにしておく
set ocidChrSet to refMe's NSCharacterSet's newlineCharacterSet
set ocidReadTextArray to ocidReadText's componentsSeparatedByCharactersInSet:(ocidChrSet)
########################
##保存先パス
set ocidContainerDirPathURL to ocidFilePathURL's URLByDeletingLastPathComponent()
##保存ファイルパス
set strSaveFileName to (strFileName & ".ttml") as text
set ocidSaveFilePathURL to ocidContainerDirPathURL's URLByAppendingPathComponent:(strSaveFileName)
########################
##TTMLの時間の初期化
set ocidDateComponents to refMe's NSDateComponents's alloc()'s init()
##時間を1でスタートする場合は1
ocidDateComponents's setHour:(numStartH)
ocidDateComponents's setMinute:0
ocidDateComponents's setSecond:0
###カレンダー初期化
set ocidCalendar to refMe's NSCalendar's currentCalendar()
###↑の時間をセット
set ocidTime to ocidCalendar's dateFromComponents:(ocidDateComponents)
###日付時間の書式設定
set ocidDateFormatter to refMe's NSDateFormatter's alloc()'s init()
(ocidDateFormatter's setLocale:(refMe's NSLocale's localeWithLocaleIdentifier:"en_US"))
(ocidDateFormatter's setDateFormat:"HH:mm:ss.SSS")
########################
##TTML生成開始
###【A】ROOT エレメント
set ocidRootElement to refMe's NSXMLElement's alloc()'s initWithName:("tt")
###【A-1】ROOT エレメントにネームスペース
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("ttp:frameRate") stringValue:(strFPS))
# smpte clock media から ビデオ編集用ならmediaが使いやすい
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("ttp:timeBase") stringValue:("media"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xml:lang") stringValue:("en"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xmlns") stringValue:("http://www.w3.org/ns/ttml"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xmlns:ttm") stringValue:("http://www.w3.org/ns/ttml#metadata"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xmlns:tts") stringValue:("http://www.w3.org/ns/ttml#styling"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xmlns:ttp") stringValue:("http://www.w3.org/ns/ttml#parameter"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xmlns:ittp") stringValue:("http://www.w3.org/ns/ttml/profile/imsc1#parameter"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xmlns:itts") stringValue:("http://www.w3.org/ns/ttml/profile/imsc1#styling"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("ttp:profile") stringValue:("http://www.w3.org/ns/ttml/profile/imsc1/text"))
##################
###【B】head エレメント
set ocidHeadElement to refMe's NSXMLElement's alloc()'s initWithName:("head")
###【B-1】styling エレメント
set ocidStylingElement to refMe's NSXMLElement's alloc()'s initWithName:("styling")
###【B-1-1】styling エレメント
set ocidStyleElement to refMe's NSXMLElement's alloc()'s initWithName:("style")
set strStyleID to (strID & "s")
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xml:id") stringValue:(strStyleID))
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:displayAlign") stringValue:(strDisplayAlign))
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:color") stringValue:(strTextColor))
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:textShadow") stringValue:(strTextShadow))

ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:opacity") stringValue:(strTextOpacity))
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:fontSize") stringValue:(strFontSize))
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:fontFamily") stringValue:(strFontFamily))
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:fontStyle") stringValue:(strFontStyle))
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:fontWeight") stringValue:(strFontWeight))
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:textOutline") stringValue:(strTextOutline))
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:textAlign") stringValue:(strTextAlign))
## StyleをStylingにセット
(ocidStylingElement's addChild:(ocidStyleElement))
## Styling を Headにセット
(ocidHeadElement's addChild:(ocidStylingElement))
###【B-2】layout エレメント
set ocidLayoutElement to refMe's NSXMLElement's alloc()'s initWithName:("layout")
###【B-2-1】region エレメント
set ocidRegionElement to refMe's NSXMLElement's alloc()'s initWithName:("region")
set strRegionID to (strID & "r")
ocidRegionElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xml:id") stringValue:(strRegionID))
ocidRegionElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:origin") stringValue:(strOrigin))
ocidRegionElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:extent") stringValue:("100% 0%"))
ocidRegionElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:displayAlign") stringValue:("center"))
## RegionをLayoutにセット
(ocidLayoutElement's addChild:(ocidRegionElement))
## LayoutをHeadにセット
(ocidHeadElement's addChild:(ocidLayoutElement))
## Headをrootエレメントにセット
(ocidRootElement's addChild:(ocidHeadElement))
##################
###【C】Body エレメント
set ocidBodyElement to refMe's NSXMLElement's alloc()'s initWithName:("body")
###【C-1】div エレメント divは複数設定可能なので エレメント名に番号を入れる
set ocidDiv01Element to refMe's NSXMLElement's alloc()'s initWithName:("div")
ocidDiv01Element's addAttribute:(refMe's NSXMLNode's attributeWithName:("xml:id") stringValue:(strID))
ocidDiv01Element's addAttribute:(refMe's NSXMLNode's attributeWithName:("style") stringValue:(strStyleID))
ocidDiv01Element's addAttribute:(refMe's NSXMLNode's attributeWithName:("region") stringValue:(strRegionID))
###【C-1-1】ここが各行のテキストになる
repeat with itemReadText in ocidReadTextArray
  set ocidParagraphElement to (refMe's NSXMLElement's alloc()'s initWithName:("p"))
  set ocidSetNode to (refMe's NSXMLNode's textWithStringValue:(itemReadText))
  #各行のテキストデータ=NODEをPにセット
(ocidParagraphElement's addChild:(ocidSetNode))
  ###時間を書式でテキスト化
  set ocidDateStrings to (ocidDateFormatter's stringFromDate:(ocidTime))
  ##開始時間としてセット
(ocidParagraphElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("begin") stringValue:(ocidDateStrings)))
  ###日付時間の書式設定
  ###タイムインターバルをセット
  set ocidNewDate to (ocidTime's dateByAddingTimeInterval:(numTimeInterval))
  ###インターバル分追加した時間をテキストにして
  set ocidDateStrings to (ocidDateFormatter's stringFromDate:(ocidNewDate))
  ##end時間としてセット
(ocidParagraphElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("end") stringValue:(ocidDateStrings)))
  ##加算された時間を次のリピートの開始時間とするためにセット
  set ocidTime to ocidNewDate
  ##1行分のPデータを親要素のDIVにセットする
(ocidDiv01Element's addChild:(ocidParagraphElement))
end repeat
##DIV要素をBODYにセット
(ocidBodyElement's addChild:(ocidDiv01Element))
##BODYをROOTエレメントにセット
(ocidRootElement's addChild:(ocidBodyElement))
##【D】保存
###【XML】↑からのROOTエレメントをセットしてXMLとする 【A】をXMLドキュメントにする
set ocidOutPutXML to refMe's NSXMLDocument's alloc()'s initWithRootElement:(ocidRootElement)
ocidOutPutXML's setVersion:"1.0"
ocidOutPutXML's setCharacterEncoding:"UTF-8"
###XML形式のテキストに出力
set ocidSaveStrings to ocidOutPutXML's XMLString()
###改行コードを指定して
ocidSaveStrings's appendString:"\n"
##上書きチェック
set ocidSaveFilePath to doChkExists(ocidSaveFilePathURL)
set ocidSaveFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidSaveFilePath) isDirectory:false)
##保存
set listDone to ocidSaveStrings's writeToURL:(ocidSaveFilePathURL) atomically:true encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)

return



####################################
#上書きチェック
# ocid file path = NSPathStore を返します
####################################
to doChkExists(argFilePath)
log (className() of argFilePath) as text
  if (class of argFilePath) is text then
log "テキストファイルパス"
    set ocidFilePathStr to refMe's NSString's stringWithString:(argFilePath)
    set ocidArgFilePath to ocidFilePathStr's stringByStandardizingPath()
  else if (class of argFilePath) is alias then
log "エリアスファイルパス"
    set strArgFilePath to (POSIX path of argFilePath) as text
    set ocidFilePathStr to refMe's NSString's stringWithString:(argFilePath)
    set ocidArgFilePath to ocidFilePathStr's stringByStandardizingPath()
  else if (class of argFilePath) is «class furl» then
log "エリアスfurlファイルパス"
    set aliasFilePath to argFilePath as alias
    set strArgFilePath to (POSIX path of argFilePath) as text
    set ocidFilePathStr to refMe's NSString's stringWithString:(argFilePath)
    set ocidArgFilePath to ocidFilePathStr's stringByStandardizingPath()
  else if (className() of argFilePath as text) contains "NSCFString" then
log "NSStringファイルパス"
    set ocidArgFilePath to argFilePath's stringByStandardizingPath()
  else if (className() of argFilePath as text) contains "NSPathStore" then
log "NSPathStore2ファイルパス"
    set ocidArgFilePath to argFilePath
  else if (className() of argFilePath as text) contains "NSURL" then
log "NSURLファイルパス"
    set ocidArgFilePath to argFilePath's |path|
  end if
  ####
  set appFileManager to refMe's NSFileManager's defaultManager()
  set boolExists to appFileManager's fileExistsAtPath:(ocidArgFilePath) isDirectory:(false)
  #
  if boolExists = true then
    ##ダイアログを前面に
    set strName to (name of current application) as text
    if strName is "osascript" then
      tell application "Finder" to activate
    else
      tell current application to activate
    end if
    set strMes to "上書きします?" as text
    try
      set objResponse to (display alert strMes buttons {"上書きする", "処理を中止する", "ファイル名を変更"} default button "上書きする" cancel button "処理を中止する" as informational giving up after 20)
    on error
log "処理を中止しました"
return "処理を中止しました"
      error number -128
    end try
    if true is equal to (gave up of objResponse) then
log "時間切れですやりなおしてください"
return "時間切れですやりなおしてください"
      error number -128
    end if
    if "上書きする" is equal to (button returned of objResponse) then
log "上書き保存します"
      set ocidReturnFilePath to ocidArgFilePath
    else if "ファイル名を変更" is equal to (button returned of objResponse) then
log "ファイル名を変更"
      set ocidContainerDirFilePath to ocidArgFilePath's stringByDeletingLastPathComponent()
      set strFileName to ocidArgFilePath's lastPathComponent() as text
      set aliasContainerDirPath to (POSIX file (ocidContainerDirFilePath as text)) as alias
      ##
      set strPromptText to "名前を決めてください" as text
      set strMesText to "名前を決めてください" as text
      ###ファイル名 ダイアログ
      set aliasFilePath to (choose file name strMesText default location aliasContainerDirPath default name strFileName with prompt strPromptText) as «class furl»
      set strFilePath to (POSIX path of aliasFilePath) as text
      set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
      set ocidReturnFilePath to ocidFilePathStr's stringByStandardizingPath()
    else if "処理を中止する" is equal to (button returned of objResponse) then
return "処理を中止しました"
    else
return "エラーしました"
      error number -128
    end if
  else if boolExists = false then
log "そのままファイル生成"
    set ocidReturnFilePath to ocidArgFilePath
  end if
return ocidReturnFilePath
  
end doChkExists

|

[TTML]テキストデータからTTMLを作成する


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()

##設定項目
###カウントアップ値(10分の1秒)
set numTimeInterval to 3.0 as number
###時間のスタート 1か0か
set numStartH to 1 as integer
#【A】ROOT
##指定のない場合は25 50 100 が計算しやすい
set strFPS to ("50") as text
#【B】HEAD共通のID
set strID to ("div01") as text
#【B−1】HEADのstyling
#"before" | "center" | "after" | "justify"
set strDisplayAlign to ("center") as text
set strTextColor to ("#ffffff") as text
# 0-1 0が完全透明 1が透明なし
set strTextOpacity to ("0.8") as text
set strTextOutline to ("#646364 1px") as text
#"left" | "center" | "right" | "start" | "end" | "justify"
set strTextAlign to ("center") as text
set strFontSize to ("100%") as text
#"default","monospace","sansSerif","serif","monospaceSansSerif","monospaceSerif","proportionalSansSerif","proportionalSerif"
set strFontFamily to ("proportionalSerif") as text
#"normal", "italic" ,"oblique"
set strFontStyle to ("italic") as text
#"normal" | "bold"
set strFontWeight to ("bold") as text

#【B−2】HEADのlayout
#前半の0%は固定 後半の値 100%が画面下部 0%が画面上部
set strOrigin to ("0% 90%") as text
# 他の値はYoutubeでは無用なので設定省略


#############################
##ダイアログを前面に
tell current application
  set strName to name as text
end tell
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
############ デフォルトロケーション
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
############UTIリスト
set listUTI to {"public.text", "public.plain-text"}
set strMes to ("ファイルを選んでください") as text
set strPrompt to ("ファイルを選んでください") as text
try
  ### ファイル選択時
  set aliasFilePath to (choose file strMes with prompt strPrompt default location aliasDefaultLocation of type listUTI without invisibles, multiple selections allowed and showing package contents) as alias
on error
log "エラーしました"
return "エラーしました"
end try
###入力パス
set strFilePath to (POSIX path of aliasFilePath) as text
set ocidFilePathStr to (refMe's NSString's stringWithString:(strFilePath))
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
set strFileName to (ocidFilePathURL's lastPathComponent()) as text
########################
##テキスト読み込み
set listReadText to refMe's NSString's alloc()'s initWithContentsOfURL:(ocidFilePathURL) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)
set ocidReadText to (item 1 of listReadText)
####行毎のリストにしておく
set ocidChrSet to refMe's NSCharacterSet's newlineCharacterSet
set ocidReadTextArray to ocidReadText's componentsSeparatedByCharactersInSet:(ocidChrSet)
########################
##保存先パス
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
##保存ファイルパス
set strSaveFileName to (strFileName & ".ttml") as text
set ocidSaveFilePathURL to ocidDesktopDirPathURL's URLByAppendingPathComponent:(strSaveFileName)
########################
##TTMLの時間の初期化
set ocidDateComponents to refMe's NSDateComponents's alloc()'s init()
##時間を1でスタートする場合は1
ocidDateComponents's setHour:(numStartH)
ocidDateComponents's setMinute:0
ocidDateComponents's setSecond:0
###カレンダー初期化
set ocidCalendar to refMe's NSCalendar's currentCalendar()
###↑の時間をセット
set ocidTime to ocidCalendar's dateFromComponents:(ocidDateComponents)
###日付時間の書式設定
set ocidDateFormatter to refMe's NSDateFormatter's alloc()'s init()
(ocidDateFormatter's setLocale:(refMe's NSLocale's localeWithLocaleIdentifier:"en_US"))
(ocidDateFormatter's setDateFormat:"HH:mm:ss.SSS")
########################
##TTML生成開始
###【A】ROOT エレメント
set ocidRootElement to refMe's NSXMLElement's alloc()'s initWithName:("tt")
###【A-1】ROOT エレメントにネームスペース
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("ttp:frameRate") stringValue:(strFPS))
# smpte clock media から ビデオ編集用ならmediaが使いやすい
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("ttp:timeBase") stringValue:("media"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xml:lang") stringValue:("en"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xmlns") stringValue:("http://www.w3.org/ns/ttml"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xmlns:ttm") stringValue:("http://www.w3.org/ns/ttml#metadata"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xmlns:tts") stringValue:("http://www.w3.org/ns/ttml#styling"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xmlns:ttp") stringValue:("http://www.w3.org/ns/ttml#parameter"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xmlns:ittp") stringValue:("http://www.w3.org/ns/ttml/profile/imsc1#parameter"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xmlns:itts") stringValue:("http://www.w3.org/ns/ttml/profile/imsc1#styling"))
ocidRootElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("ttp:profile") stringValue:("http://www.w3.org/ns/ttml/profile/imsc1/text"))
##################
###【B】head エレメント
set ocidHeadElement to refMe's NSXMLElement's alloc()'s initWithName:("head")
###【B-1】styling エレメント
set ocidStylingElement to refMe's NSXMLElement's alloc()'s initWithName:("styling")
###【B-1-1】styling エレメント
set ocidStyleElement to refMe's NSXMLElement's alloc()'s initWithName:("style")
set strStyleID to (strID & "s")
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xml:id") stringValue:(strStyleID))
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:displayAlign") stringValue:(strDisplayAlign))
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:color") stringValue:(strTextColor))
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:opacity") stringValue:(strTextOpacity))
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:fontSize") stringValue:(strFontSize))
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:fontFamily") stringValue:(strFontFamily))
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:fontStyle") stringValue:(strFontStyle))
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:fontWeight") stringValue:(strFontWeight))
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:textOutline") stringValue:(strTextOutline))
ocidStyleElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:textAlign") stringValue:(strTextAlign))
## StyleをStylingにセット
(ocidStylingElement's addChild:(ocidStyleElement))
## Styling を Headにセット
(ocidHeadElement's addChild:(ocidStylingElement))
###【B-2】layout エレメント
set ocidLayoutElement to refMe's NSXMLElement's alloc()'s initWithName:("layout")
###【B-2-1】region エレメント
set ocidRegionElement to refMe's NSXMLElement's alloc()'s initWithName:("region")
set strRegionID to (strID & "r")
ocidRegionElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("xml:id") stringValue:(strRegionID))
ocidRegionElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:origin") stringValue:(strOrigin))
ocidRegionElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:extent") stringValue:("100% 0%"))
ocidRegionElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("tts:displayAlign") stringValue:("center"))
## RegionをLayoutにセット
(ocidLayoutElement's addChild:(ocidRegionElement))
## LayoutをHeadにセット
(ocidHeadElement's addChild:(ocidLayoutElement))
## Headをrootエレメントにセット
(ocidRootElement's addChild:(ocidHeadElement))
##################
###【C】Body エレメント
set ocidBodyElement to refMe's NSXMLElement's alloc()'s initWithName:("body")
###【C-1】div エレメント divは複数設定可能なので エレメント名に番号を入れる
set ocidDiv01Element to refMe's NSXMLElement's alloc()'s initWithName:("div")
ocidDiv01Element's addAttribute:(refMe's NSXMLNode's attributeWithName:("xml:id") stringValue:(strID))
ocidDiv01Element's addAttribute:(refMe's NSXMLNode's attributeWithName:("style") stringValue:(strStyleID))
ocidDiv01Element's addAttribute:(refMe's NSXMLNode's attributeWithName:("region") stringValue:(strRegionID))
###【C-1-1】ここが各行のテキストになる
repeat with itemReadText in ocidReadTextArray
  set ocidParagraphElement to (refMe's NSXMLElement's alloc()'s initWithName:("p"))
  set ocidSetNode to (refMe's NSXMLNode's textWithStringValue:(itemReadText))
  #各行のテキストデータ=NODEをPにセット
(ocidParagraphElement's addChild:(ocidSetNode))
  ###時間を書式でテキスト化
  set ocidDateStrings to (ocidDateFormatter's stringFromDate:(ocidTime))
  ##開始時間としてセット
(ocidParagraphElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("begin") stringValue:(ocidDateStrings)))
  ###日付時間の書式設定
  ###タイムインターバルをセット
  set ocidNewDate to (ocidTime's dateByAddingTimeInterval:(numTimeInterval))
  ###インターバル分追加した時間をテキストにして
  set ocidDateStrings to (ocidDateFormatter's stringFromDate:(ocidNewDate))
  ##end時間としてセット
(ocidParagraphElement's addAttribute:(refMe's NSXMLNode's attributeWithName:("end") stringValue:(ocidDateStrings)))
  ##加算された時間を次のリピートの開始時間とするためにセット
  set ocidTime to ocidNewDate
  ##1行分のPデータを親要素のDIVにセットする
(ocidDiv01Element's addChild:(ocidParagraphElement))
end repeat
##DIV要素をBODYにセット
(ocidBodyElement's addChild:(ocidDiv01Element))
##BODYをROOTエレメントにセット
(ocidRootElement's addChild:(ocidBodyElement))
##【D】保存
###【XML】↑からのROOTエレメントをセットしてXMLとする 【A】をXMLドキュメントにする
set ocidOutPutXML to refMe's NSXMLDocument's alloc()'s initWithRootElement:(ocidRootElement)
ocidOutPutXML's setVersion:"1.0"
ocidOutPutXML's setCharacterEncoding:"UTF-8"
###XML形式のテキストに出力
set ocidSaveStrings to ocidOutPutXML's XMLString()
###改行コードを指定して
ocidSaveStrings's appendString:"\n"
##上書きチェック
set ocidSaveFilePath to ocidSaveFilePathURL's |path|()
set boolDirExists to appFileManager's fileExistsAtPath:(ocidSaveFilePath) isDirectory:(false)

if boolDirExists = true then
  set strMes to "上書きします?" as text
  try
    ##ダイアログを前面に
    if strName is "osascript" then
      tell application "Finder" to activate
    else
      tell current application to activate
    end if
    set objResponse to (display alert strMes buttons {"上書きする", "処理を中止する"} default button "上書きする" cancel button "処理を中止する" as informational giving up after 10)
  on error
log "処理を中止しました"
return "処理を中止しました"
    error number -128
  end try
  if true is equal to (gave up of objResponse) then
return "時間切れですやりなおしてください"
    error number -128
  end if
  if "上書きする" is equal to (button returned of objResponse) then
log "上書き保存します"
  else if "処理を中止する" is equal to (button returned of objResponse) then
return "処理を中止しました"
  else
return "エラーしました"
    error number -128
  end if
else if boolDirExists = false then
log "そのままファイル生成"
end if

##保存
set listDone to ocidSaveStrings's writeToURL:(ocidSaveFilePathURL) atomically:true encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)

return




|

[TTML]TTMLの内容を縦書きにする(といってもBR入れるだけ)


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
# TTMLを縦書きにします→文字毎に改行入れるだけw
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application


##############################################
## ファイルパス関連
##############################################
####ダイアログで使うデフォルトロケーション
tell application "Finder"
  set aliasDefaultLocation to (path to desktop folder from user domain) as alias
end tell
####UTIリスト PDFのみ
set listUTI to {"dyn.ah62d4rv4ge81k7drru", "public.xml"}
####プロンプトテキスト
set strPromptText to "TTMLファイルを選んでください" as text
####ダイアログを出す
set aliasFilePath to (choose file with prompt strPromptText default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias

##############################################
## ファイルパス関連
##############################################
set strFilePath to (POSIX path of aliasFilePath) as text
set ocidFilePath to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePathURL to refMe's NSURL's fileURLWithPath:(ocidFilePath)
#
set ocidContainerDirPathURL to ocidFilePathURL's URLByDeletingLastPathComponent()
set ocidBaseFilePathURL to ocidFilePathURL's URLByDeletingPathExtension()
set strExtensionName to ocidFilePathURL's pathExtension() as text
set strBaseFileName to ocidBaseFilePathURL's lastPathComponent() as text
#保存先
set strSaveFileName to (strBaseFileName & "@縦書き." & strExtensionName) as text
set ocidSaveFilePathURL to ocidContainerDirPathURL's URLByAppendingPathComponent:(strSaveFileName)

##############################################
## XML関連
##############################################
####テキストで読み込み
set listReadDataString to refMe's NSString's stringWithContentsOfURL:ocidFilePathURL encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)
#####データ部
set ocidReadString to item 1 of listReadDataString
####エラー部
set ocidNSErrorData to item 2 of listReadDataString
if ocidNSErrorData is not (missing value) then
doGetErrorData(ocidNSErrorData)
end if
#####XML定義
set listReadXML to refMe's NSXMLDocument's alloc()'s initWithXMLString:ocidReadString options:(refMe's NSXMLNodePreserveWhitespace) |error|:(reference)
#####データ部
set ocidReadXML to item 1 of listReadXML
####エラー部
set ocidNSErrorData to item 2 of listReadXML
if ocidNSErrorData is not (missing value) then
doGetErrorData(ocidNSErrorData)
end if
################################
####ROOTエレメント
set ocidRootElement to ocidReadXML's rootElement()
####################
#####headエレメント
set ocidHeadElement to ocidRootElement's childAtIndex:0
#####stylingエレメント
set ocidStylingElement to ocidHeadElement's childAtIndex:0
#####layoutエレメント
set ocidLayoutElement to ocidHeadElement's childAtIndex:1
set ocidRegionElement to ocidLayoutElement's childAtIndex:0
#origin変更
ocidRegionElement's removeAttributeForName:("tts:origin")
set ocidAddNode to refMe's NSXMLNode's attributeWithName:("tts:origin") stringValue:("100% 20%")
ocidRegionElement's addAttribute:(ocidAddNode)
#extent変更
ocidRegionElement's removeAttributeForName:("tts:extent")
set ocidAddNode to refMe's NSXMLNode's attributeWithName:("tts:extent") stringValue:("45% 55%")
ocidRegionElement's addAttribute:(ocidAddNode)
####################
#####Bodyエレメント
set ocidBodyElement to ocidRootElement's childAtIndex:1
#####Bodyに2要素-->複数レイアウトある場合は停止
set numCntDiv to ocidBodyElement's childCount() as number
if numCntDiv > 1 then
return "処理停止 複数レイアウト非対応"
end if
##############################################
## R0データ取得
##############################################
#####BODYのR0エレメント
set ocidR0Element to ocidBodyElement's childAtIndex:0
#####R0に何行あるか
log ocidR0Element's childCount() as number
##P要素
set ocidR0ChildArray to ocidR0Element's children()
##改行
set ocidBR to refMe's NSString's stringWithString:("<br>")
##Pのテキストの値の数だけ繰り返し
repeat with itemR0Array in ocidR0ChildArray
  ##出力(再セット用)の文字列
  set ocidSetStringM to (refMe's NSMutableString's alloc()'s initWithCapacity:(0))
  set ocidStringValue to itemR0Array's stringValue
  set numCntString to ocidStringValue's |length| as integer
  repeat with itemChar from 0 to (numCntString - 1) by 1
    set ocidSetRange to (refMe's NSMakeRange(itemChar, 1))
    set ocidSubString to (ocidStringValue's substringWithRange:(ocidSetRange))
(ocidSetStringM's appendString:(ocidSubString))
(ocidSetStringM's appendString:(ocidBR))
  end repeat
(itemR0Array's setStringValue:(ocidSetStringM))
end repeat
##確認用
(*
repeat with itemR0Array in ocidR0ChildArray
log itemR0Array's stringValue as text
end repeat
*)
set ocidReadXMLStrings to ocidReadXML's XMLString()
##BR置換 youtube等改行の仕様によって置換 これはYoutube用
set ocidSaveStrings to (ocidReadXMLStrings's stringByReplacingOccurrencesOfString:("&lt;br&gt;") withString:("<br>"))
##縦書き対応文字置換(他にあれば追加) とりあえず長音→パイプ記号を利用
set ocidSaveStrings to (ocidSaveStrings's stringByReplacingOccurrencesOfString:("ー") withString:("|"))
set listDone to ocidSaveStrings's writeToURL:(ocidSaveFilePathURL) atomically:true encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)


return


##############################################
## エラー発生時のログ用
##############################################


to doGetErrorData(ocidNSErrorData)
  #####個別のエラー情報
log "エラーコード:" & ocidNSErrorData's code() as text
log "エラードメイン:" & ocidNSErrorData's domain() as text
log "Description:" & ocidNSErrorData's localizedDescription() as text
log "FailureReason:" & ocidNSErrorData's localizedFailureReason() as text
log ocidNSErrorData's localizedRecoverySuggestion() as text
log ocidNSErrorData's localizedRecoveryOptions() as text
log ocidNSErrorData's recoveryAttempter() as text
log ocidNSErrorData's helpAnchor() as text
  set ocidNSErrorUserInfo to ocidNSErrorData's userInfo()
  set ocidAllValues to ocidNSErrorUserInfo's allValues() as list
  set ocidAllKeys to ocidNSErrorUserInfo's allKeys() as list
  repeat with ocidKeys in ocidAllKeys
    if (ocidKeys as text) is "NSUnderlyingError" then
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedDescription() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedFailureReason() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedRecoverySuggestion() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedRecoveryOptions() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s recoveryAttempter() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s helpAnchor() as text
    else
      ####それ以外の値はそのままテキストで読める
log (ocidKeys as text) & ": " & (ocidNSErrorUserInfo's valueForKey:ocidKeys) as text
    end if
  end repeat
  
end doGetErrorData

|

[TTML] TTMLファイルにiTT (iTunes Timed Text)の要素の付与


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()

##############################################
## ファイルパス関連
##############################################
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
####UTIリスト PDFのみ
set listUTI to {"dyn.ah62d4rv4ge81k7drru", "public.xml", "com.apple.itunes-timed-text"}
####プロンプトテキスト
set strPromptText to "TTMLファイルを選んでください" as text
####ダイアログを出す
set aliasFilePath to (choose file with prompt strPromptText default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias

##############################################
## 入力ファイル パス
##############################################
set strFilePath to (POSIX path of aliasFilePath) as string
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
##############################################
## 出力ファイル パス
##############################################
set ocidBaseFilePathURL to ocidFilePathURL's URLByDeletingPathExtension()
set ocidItuneFilePathURL to ocidBaseFilePathURL's URLByAppendingPathExtension:("itune")
set ocidSaveFilePathURL to ocidItuneFilePathURL's URLByAppendingPathExtension:("ttml")
##############################################
## XML関連
##############################################
####テキストで読み込み
set listReadString to refMe's NSString's stringWithContentsOfURL:(ocidFilePathURL) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)
#データ部
set ocidReadString to (item 1 of listReadString)
#エラー部
set ocidNSErrorData to item 2 of listReadString
if ocidNSErrorData is not (missing value) then
doGetErrorData(ocidNSErrorData)
end if
#####XML定義
set listReadXML to refMe's NSXMLDocument's alloc()'s initWithXMLString:(ocidReadString) options:(refMe's NSXMLNodePreserveWhitespace) |error|:(reference)
#データ部
set ocidReadXML to item 1 of listReadXML
#エラー部
set ocidNSErrorData to item 2 of listReadXML
if ocidNSErrorData is not (missing value) then
doGetErrorData(ocidNSErrorData)
end if
####################################
####ROOTエレメント
set ocidRootElement to ocidReadXML's rootElement()
#rootエレメントにlyric-ttml-extensionsを追加
set ocidNameSpace to refMe's NSXMLNode's namespaceWithName:("itunes") stringValue:("http://itunes.apple.com/lyric-ttml-extensions")
ocidRootElement's addNamespace:(ocidNameSpace)
####################
#####headエレメント
set ocidHeadElement to ocidRootElement's childAtIndex:0
set ocidMetaElement to (refMe's NSXMLElement's alloc()'s initWithName:("metadata"))
#######曲名
set ocidTitleElement to (refMe's NSXMLElement's elementWithName:("ttm:title"))
ocidTitleElement's setStringValue:("■曲名")
(ocidMetaElement's addChild:(ocidTitleElement))
#######アーティスト名
set ocidAgentElement to (refMe's NSXMLElement's elementWithName:("ttm:agent"))
set ocidAttribute to refMe's NSXMLNode's attributeWithName:("type") stringValue:("■person or group")
ocidAgentElement's addAttribute:(ocidAttribute)
set ocidNameSpace to refMe's NSXMLNode's namespaceWithName:("id") stringValue:("v1")
ocidAgentElement's addNamespace:(ocidNameSpace)
##
set ocidNameElement to (refMe's NSXMLElement's elementWithName:("ttm:name"))
set ocidAttribute to refMe's NSXMLNode's attributeWithName:("type") stringValue:("full")
ocidNameElement's addAttribute:(ocidAttribute)
#
ocidNameElement's setStringValue:("■アーティスト名日本語表記")
(ocidAgentElement's addChild:(ocidNameElement))
##
set ocidNameElement to (refMe's NSXMLElement's elementWithName:("ttm:name"))
set ocidAttribute to refMe's NSXMLNode's attributeWithName:("type") stringValue:("full")
ocidNameElement's addAttribute:(ocidAttribute)
#
ocidNameElement's setStringValue:("■アーティスト名英語表記")
(ocidAgentElement's addChild:(ocidNameElement))
#
(ocidMetaElement's addChild:(ocidAgentElement))
(ocidHeadElement's addChild:(ocidMetaElement))
####################
#####Bodyエレメント
set ocidBodyElement to ocidRootElement's childAtIndex:1
#DIV子要素
set ocidDivArray to ocidBodyElement's children()
repeat with itemDiv in ocidDivArray
  set ocidAttribute to (refMe's NSXMLNode's attributeWithName:("itunes:song-part") stringValue:("Verse"))
(itemDiv's addAttribute:(ocidAttribute))
  (*
Verse
Chorus
PreChorus
Bridge
Intro
Outro
Refrain
Instrumental
*)
  #P 子要素
  set ocidParagraphArray to itemDiv's children()
  repeat with itemParagraph in ocidParagraphArray
    set ocidAttribute to (refMe's NSXMLNode's attributeWithName:("ttm:agent") stringValue:("v1"))
(itemParagraph's addAttribute:(ocidAttribute))
  end repeat
end repeat


##############################################
## 保存
##############################################
###XML形式のテキストに出力
set ocidSaveStrings to ocidReadXML's XMLString()
###改行コードを指定して
ocidSaveStrings's appendString:"\n"
##保存
set listDone to ocidSaveStrings's writeToURL:(ocidSaveFilePathURL) atomically:true encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)
#エラー部
set ocidNSErrorData to item 2 of listDone
if ocidNSErrorData is not (missing value) then
doGetErrorData(ocidNSErrorData)
end if


return


##############################################
## エラー発生時のログ用
##############################################


to doGetErrorData(ocidNSErrorData)
  #####個別のエラー情報
log "エラーコード:" & ocidNSErrorData's code() as text
log "エラードメイン:" & ocidNSErrorData's domain() as text
log "Description:" & ocidNSErrorData's localizedDescription() as text
log "FailureReason:" & ocidNSErrorData's localizedFailureReason() as text
log ocidNSErrorData's localizedRecoverySuggestion() as text
log ocidNSErrorData's localizedRecoveryOptions() as text
log ocidNSErrorData's recoveryAttempter() as text
log ocidNSErrorData's helpAnchor() as text
  set ocidNSErrorUserInfo to ocidNSErrorData's userInfo()
  set ocidAllValues to ocidNSErrorUserInfo's allValues() as list
  set ocidAllKeys to ocidNSErrorUserInfo's allKeys() as list
  repeat with ocidKeys in ocidAllKeys
    if (ocidKeys as text) is "NSUnderlyingError" then
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedDescription() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedFailureReason() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedRecoverySuggestion() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedRecoveryOptions() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s recoveryAttempter() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s helpAnchor() as text
    else
      ####それ以外の値はそのままテキストで読める
log (ocidKeys as text) & ": " & (ocidNSErrorUserInfo's valueForKey:ocidKeys) as text
    end if
  end repeat
  
end doGetErrorData

|

[TTML]TTMLからYoutube用のチャプターテキストを作成する(修正版)


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
# TTMLからYoutube用のチャプタテキストを作成します
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application



##############################################
## ファイルパス関連
##############################################
####ダイアログで使うデフォルトロケーション
tell application "Finder"
  set aliasDefaultLocation to (path to desktop folder from user domain) as alias
end tell
####UTIリスト PDFのみ
set listUTI to {"dyn.ah62d4rv4ge81k7drru", "public.xml"}
####プロンプトテキスト
set strPromptText to "TTMLファイルを選んでください" as text
####ダイアログを出す
set aliasFilePath to (choose file with prompt strPromptText default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias

##############################################
## ファイルパス関連
##############################################

set strFilePath to POSIX path of aliasFilePath
####ドキュメントのパスをNSString
set ocidFilePath to refMe's NSString's stringWithString:strFilePath
####ドキュメントのパスをNSURLに
set ocidFilePathURL to refMe's NSURL's fileURLWithPath:ocidFilePath


##############################################
## XML関連
##############################################
####テキストで読み込み
set listReadDataString to refMe's NSString's stringWithContentsOfURL:ocidFilePathURL encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)
#####データ部
set ocidReadString to item 1 of listReadDataString
####エラー部
set ocidNSErrorData to item 2 of listReadDataString
if ocidNSErrorData is not (missing value) then
doGetErrorData(ocidNSErrorData)
end if
#####XML定義
set listReadXML to refMe's NSXMLDocument's alloc()'s initWithXMLString:ocidReadString options:(refMe's NSXMLNodePreserveWhitespace) |error|:(reference)
#####データ部
set ocidReadXML to item 1 of listReadXML
####エラー部
set ocidNSErrorData to item 2 of listReadXML
if ocidNSErrorData is not (missing value) then
doGetErrorData(ocidNSErrorData)
end if
####ROOTエレメント
set ocidRootElement to ocidReadXML's rootElement()
####################
#####headエレメント
set ocidHeadElement to ocidRootElement's childAtIndex:0
#####stylingエレメント
set ocidStylingElement to ocidHeadElement's childAtIndex:0
#####layoutエレメント
set ocidLayoutElement to ocidHeadElement's childAtIndex:1
####################
#####Bodyエレメント
set ocidBodyElement to ocidRootElement's childAtIndex:1
#####Bodyに2要素-->複数レイアウトある場合は停止
set numCntDiv to ocidBodyElement's childCount() as number

if numCntDiv > 1 then
  ##return "処理停止 複数レイアウト非対応"
end if

##############################################
## R0データ取得
##############################################
#####BODYのR0エレメント
set ocidR0Element to ocidBodyElement's childAtIndex:0
#####R0に何行あるか
log ocidR0Element's childCount() as number

####出力用のテキスト
set ocidOutPutString to refMe's NSMutableString's alloc()'s initWithCapacity:0
####項番用
set numCntLineNo to 1 as number
#####本処理
repeat with objR0Element in ocidR0Element's children()
  #####行番号
  #set strCntLineNo to (text -2 through -1 of ("00" & numCntLineNo)) as text
  #(ocidOutPutString's appendString:strCntLineNo)
  ######スペース
  #(ocidOutPutString's appendString:" ")
  ####XMLテキスト
  set ocidR0ObjectValue to objR0Element's XMLString()
  set ocidXMLStringArray to (ocidR0ObjectValue's componentsSeparatedByString:"\"")
  set ocidStartTIme to item 2 of ocidXMLStringArray
  set ocidTimeArrayLong to (ocidStartTIme's componentsSeparatedByString:".")
  set ocidTimeArrayItem to ((item 1 of ocidTimeArrayLong)'s componentsSeparatedByString:":")
  set strNUMH to item 1 of ocidTimeArrayItem as text
  set numH to strNUMH as number
  set numH to numH - 1 as number
  set strH to (text -2 through -1 of ("00" & numH)) as text
  ####出力用に整形
  set strOutPutTime to strH & ":" & (item 2 of ocidTimeArrayItem as text) & ":" & (item 3 of ocidTimeArrayItem as text) & " "
  ####時間挿入
(ocidOutPutString's appendString:strOutPutTime)
  ####テキスト取得
  set strStringValue to objR0Element's stringValue()
  
  ####ハイフンを入れると打ち消しになるためハイフン取る
  ###########################
  ###↑文字数を数える
  set numCntSampleText to strStringValue's |length|()
  ###↑文字数全部でレンジにする
  set ocidNsRange to {location:0, |length|:numCntSampleText}
  ###改行コード置き換え(CR/LF)
(strStringValue's replaceOccurrencesOfString:"-" withString:"" options:0 range:ocidNsRange)
  ####ハイフン取ったテキストを格納
(ocidOutPutString's appendString:strStringValue)
  #####改行
(ocidOutPutString's appendString:"\n")
  
  
  set numCntLineNo to numCntLineNo + 1 as number
end repeat

if numCntDiv = 1 then
  ##############################################
  ##ファイル出力
  ##############################################
  ####ドキュメントのパスをNSString
  set ocidFilePath to refMe's NSString's stringWithString:strFilePath
  #####出力ファイル名付与
  set ocidOutFilePath to ocidFilePath's stringByAppendingString:".out.text"
  #####NSURLに
  set ocidSaveFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidOutFilePath
  ###別名出力
  set boolWritetoUrlArray to ocidOutPutString's writeToURL:ocidSaveFilePathURL atomically:true encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)
return
end if

#####ここからは 字幕項目が2つある場合用
(ocidOutPutString's appendString:"\n")
(ocidOutPutString's appendString:"\n")


##############################################
## R1データ取得
##############################################

#####BODYのR0エレメント
set ocidR0Element to ocidBodyElement's childAtIndex:1
#####R0に何行あるか
log ocidR0Element's childCount() as number


####項番用
set numCntLineNo to 1 as number
repeat with objR0Element in ocidR0Element's children()
  
  #####行番号
  ##set strCntLineNo to (text -2 through -1 of ("00" & numCntLineNo)) as text
  ##(ocidOutPutString's appendString:strCntLineNo)
  #####スペース
  ##(ocidOutPutString's appendString:" ")
  
  ####XMLテキスト
  set ocidR0ObjectValue to objR0Element's XMLString()
  set ocidXMLStringArray to (ocidR0ObjectValue's componentsSeparatedByString:"\"")
  set ocidStartTIme to item 2 of ocidXMLStringArray
  set ocidTimeArrayLong to (ocidStartTIme's componentsSeparatedByString:".")
  set ocidTimeArrayItem to ((item 1 of ocidTimeArrayLong)'s componentsSeparatedByString:":")
  set strNUMH to item 1 of ocidTimeArrayItem as text
  set numH to strNUMH as number
  set numH to numH - 1 as number
  set strH to (text -2 through -1 of ("00" & numH)) as text
  ####出力用に整形
  set strOutPutTime to strH & ":" & (item 2 of ocidTimeArrayItem as text) & ":" & (item 3 of ocidTimeArrayItem as text) & " "
  ####時間挿入
(ocidOutPutString's appendString:strOutPutTime)
  
  ####テキスト取得
  set strStringValue to objR0Element's stringValue()
(ocidOutPutString's appendString:strStringValue)
  #####改行
(ocidOutPutString's appendString:"\n")
  
  set numCntLineNo to numCntLineNo + 1 as number
end repeat


##############################################
##ファイル出力
##############################################
####ドキュメントのパスをNSString
set ocidFilePath to refMe's NSString's stringWithString:strFilePath
#####出力ファイル名付与
set ocidOutFilePath to ocidFilePath's stringByAppendingString:".out.text"
#####NSURLに
set ocidSaveFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidOutFilePath
###別名出力
set boolWritetoUrlArray to ocidOutPutString's writeToURL:ocidSaveFilePathURL atomically:true encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)



##############################################
## エラー発生時のログ用
##############################################


to doGetErrorData(ocidNSErrorData)
  #####個別のエラー情報
log "エラーコード:" & ocidNSErrorData's code() as text
log "エラードメイン:" & ocidNSErrorData's domain() as text
log "Description:" & ocidNSErrorData's localizedDescription() as text
log "FailureReason:" & ocidNSErrorData's localizedFailureReason() as text
log ocidNSErrorData's localizedRecoverySuggestion() as text
log ocidNSErrorData's localizedRecoveryOptions() as text
log ocidNSErrorData's recoveryAttempter() as text
log ocidNSErrorData's helpAnchor() as text
  set ocidNSErrorUserInfo to ocidNSErrorData's userInfo()
  set ocidAllValues to ocidNSErrorUserInfo's allValues() as list
  set ocidAllKeys to ocidNSErrorUserInfo's allKeys() as list
  repeat with ocidKeys in ocidAllKeys
    if (ocidKeys as text) is "NSUnderlyingError" then
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedDescription() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedFailureReason() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedRecoverySuggestion() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedRecoveryOptions() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s recoveryAttempter() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s helpAnchor() as text
    else
      ####それ以外の値はそのままテキストで読める
log (ocidKeys as text) & ": " & (ocidNSErrorUserInfo's valueForKey:ocidKeys) as text
    end if
  end repeat
  
end doGetErrorData

|

[TTML]Youtubeで縦書きCC字幕


使ったTTML

ダウンロード - chant.zip

ダウンロード -妙法蓮華経観世音菩薩.ttml



いわゆる、文字毎BRで改行です。
<p begin="01:00:01.159" end="01:00:05.019">世<br/>尊<br/>妙<br/>相<br/>具</p>
<p begin="01:00:05.460" end="01:00:08.380">我<br/>今<br/>重<br/>問<br/>彼</p>
<p begin="01:00:08.380" end="01:00:11.139">仏<br/>子<br/>何<br/>因<br/>縁</p>
<p begin="01:00:11.139" end="01:00:14.000">名<br/>為<br/>観<br/>世<br/>音</p>
<p begin="01:00:14.000" end="01:00:16.699">具<br/>足<br/>妙<br/>相<br/>尊</p>

|

TTMLからチャプター付与用のFFMETADATA1を作成する(Bash対応)


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
# TTMLからFFMETADATA1テキストを作成します
#ffprobe ffmpeg が必要です
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application

###設定項目 ffprobeへのパス
set strFfprobeFilePath to "~/bin/ffmpeg/ffprobe"
set strFfmpegBinPath to "~/bin/ffmpeg/ffmpeg"


##############################################
## TTMLファイルパス関連
##############################################
####ダイアログで使うデフォルトロケーション
tell application "Finder"
  set aliasDefaultLocation to (path to desktop folder from user domain) as alias
end tell
####UTIリスト PDFのみ
set listUTI to {"dyn.ah62d4rv4ge81k7drru", "public.xml"}
####プロンプトテキスト
set strPromptText to "TTMLファイルを選んでください" as text
####ダイアログを出す
set aliasFilePath to (choose file with prompt strPromptText default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias

##############################################
## ファイルパス関連
##############################################

set strFilePath to POSIX path of aliasFilePath
####ドキュメントのパスをNSString
set ocidFilePath to refMe's NSString's stringWithString:strFilePath
####ドキュメントのパスをNSURLに
set ocidFilePathURL to refMe's NSURL's fileURLWithPath:ocidFilePath

##############################################
#ムービーデータ関連
##############################################
####UTIリスト ビデオのみ
set listUTI to {"public.movie"}
####プロンプトテキスト
set strPromptText to "チャプタをつける\nビデオファイルを選んでください\nフレームレートの取得をします" as text
####ダイアログを出す
set aliasVideoFilePath to (choose file with prompt strPromptText default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias

##############################################
## ファイルパス関連
##############################################
set strVideoFilePath to POSIX path of aliasVideoFilePath
set ocidVideoFilePathStr to refMe's NSString's stringWithString:strVideoFilePath
set ocidVideoFilePath to ocidVideoFilePathStr's stringByStandardizingPath
set strExtensionName to ocidVideoFilePath's pathExtension() as text


##############################################
## ファイルパス関連
##############################################
##バイナリーへのパス
set ocidFfprobeFilePathStr to refMe's NSString's stringWithString:(strFfprobeFilePath)
set ocidFfprobeFilePath to ocidFfprobeFilePathStr's stringByStandardizingPath()
set ocidFfprobeFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFfprobeFilePath) isDirectory:false)
set strFfprobenPath to (ocidFfprobeFilePathURL's |path|()) as text

set strCommandText to ("\"" & strFfprobenPath & "\" -v 0 -of csv=p=0 -select_streams v:0 -show_entries stream=r_frame_rate \"" & strVideoFilePath & "\"") as text
set strReponse to (do shell script strCommandText) as text
set AppleScript's text item delimiters to "/"
set listReponse to every text item of strReponse
set AppleScript's text item delimiters to ""
set numFlameRate to (item 1 of listReponse as integer) / (item 2 of listReponse as integer) as number
set numFlameRate to numFlameRate as integer
set strFlameRateSup to numFlameRate as text
set strFlameRate to ("1/" & strFlameRateSup) as text



##############################################
## 出力用テキスト
##############################################
set ocidOutPutString to refMe's NSMutableString's alloc()'s initWithCapacity:0
ocidOutPutString's appendString:";FFMETADATA1\n"
ocidOutPutString's appendString:"title=\n"
ocidOutPutString's appendString:"artist=\n"
ocidOutPutString's appendString:"genre=\n"
ocidOutPutString's appendString:"description=\n"
ocidOutPutString's appendString:"comment=\n"
ocidOutPutString's appendString:"\n"


##############################################
## XML関連
##############################################
####テキストで読み込み
set listReadDataString to refMe's NSString's stringWithContentsOfURL:ocidFilePathURL encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)
#####データ部
set ocidReadString to item 1 of listReadDataString
####エラー部
set ocidNSErrorData to item 2 of listReadDataString
if ocidNSErrorData is not (missing value) then
doGetErrorData(ocidNSErrorData)
end if
#####XML定義
set listReadXML to refMe's NSXMLDocument's alloc()'s initWithXMLString:ocidReadString options:(refMe's NSXMLNodePreserveWhitespace) |error|:(reference)
#####データ部
set ocidReadXML to item 1 of listReadXML
####エラー部
set ocidNSErrorData to item 2 of listReadXML
if ocidNSErrorData is not (missing value) then
doGetErrorData(ocidNSErrorData)
end if
####ROOTエレメント
set ocidRootElement to ocidReadXML's rootElement()
####################
#####headエレメント
set ocidHeadElement to ocidRootElement's childAtIndex:0
#####stylingエレメント
set ocidStylingElement to ocidHeadElement's childAtIndex:0
#####layoutエレメント
set ocidLayoutElement to ocidHeadElement's childAtIndex:1
####################
#####Bodyエレメント
set ocidBodyElement to ocidRootElement's childAtIndex:1
#####Bodyに2要素-->複数レイアウトある場合は停止
set numCntDiv to ocidBodyElement's childCount() as number

if numCntDiv > 1 then
return "処理停止 複数レイアウト非対応"
end if

##############################################
## R0データ取得
##############################################
#####BODYのR0エレメント
set ocidR0Element to ocidBodyElement's childAtIndex:0
#####R0に何行あるか
log ocidR0Element's childCount() as number

####項番用
set numCntLineNo to 1 as number
#####本処理
repeat with objR0Element in ocidR0Element's children()
  set strStartTime to (objR0Element's attributeForName:"begin")'s stringValue()
  set strEndTime to (objR0Element's attributeForName:"end")'s stringValue()
  set strTitle to objR0Element's stringValue() as text
  
(ocidOutPutString's appendString:"[CHAPTER]\n")
(ocidOutPutString's appendString:"TIMEBASE=")
(ocidOutPutString's appendString:strFlameRate)
(ocidOutPutString's appendString:"\n")
  ############スタートタイム
  set ocidStarArray to (strStartTime's componentsSeparatedByString:":")
  set numIntH to (((ocidStarArray's objectAtIndex:0)'s intValue()) - 1) * 3600.0
  set numIntM to ((ocidStarArray's objectAtIndex:1)'s intValue()) * 60.0
  set numIntS to ((ocidStarArray's objectAtIndex:2)'s doubleValue())
  set numStartSec to numIntH + numIntM + numIntS
log numStartSec
  set numStartTimeFlame to numStartSec * numFlameRate as integer
(ocidOutPutString's appendString:"START=")
log numStartTimeFlame
(ocidOutPutString's appendString:(numStartTimeFlame as text))
(ocidOutPutString's appendString:"\n")
  #######エンドタイム
  set ocidEndArray to (strEndTime's componentsSeparatedByString:":")
  set numIntH to (((ocidEndArray's objectAtIndex:0)'s intValue()) - 1) * 3600.0
  set numIntM to ((ocidEndArray's objectAtIndex:1)'s intValue()) * 60.0
  set numIntS to ((ocidEndArray's objectAtIndex:2)'s doubleValue())
  set numEndTimeSec to numIntH + numIntM + numIntS
log numEndTimeSec
  set numEndTimeFlame to numEndTimeSec * numFlameRate as integer
log numEndTimeFlame
(ocidOutPutString's appendString:"END=")
(ocidOutPutString's appendString:(numEndTimeFlame as text))
(ocidOutPutString's appendString:"\n")
  
  
(ocidOutPutString's appendString:"title=")
(ocidOutPutString's appendString:strTitle)
(ocidOutPutString's appendString:"\n\n")
  
  set numCntLineNo to numCntLineNo + 1 as number
end repeat

if numCntDiv = 1 then
  ##############################################
  ##ファイル出力
  ##############################################
  ####ドキュメントのパスをNSString
  set ocidFilePath to refMe's NSString's stringWithString:(strFilePath)
  #####出力ファイル名付与
  set ocidOutFilePath to ocidFilePath's stringByAppendingString:(".FFMETADATA1.txt")
  #####NSURLに
  set ocidSaveTextFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidOutFilePath)
  ###別名出力
  set boolWritetoUrlArray to ocidOutPutString's writeToURL:(ocidSaveTextFilePathURL) atomically:true encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)
  set ocidSaveTextFilePathURL to (ocidSaveTextFilePathURL's |path|()) as text
  ###FFMPEGのパス
  set ocidFfmpegPathStr to refMe's NSString's stringWithString:(strFfmpegBinPath)
  set ocidFfmpegPath to ocidFfmpegPathStr's stringByStandardizingPath()
  set ocidFfmpegPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFfmpegPath) isDirectory:false)
  set strFfmpegPath to (ocidFfmpegPathURL's |path|()) as text
  ##
  set strOutMovieFilePath to (strVideoFilePath & ".out." & strExtensionName & "") as text
  ##############################################
  ##Bashファイル出力
  ##############################################
  set ocidBashFilePath to ocidFilePath's stringByAppendingString:(".FFMETADATA1.bash")
  set ocidBashPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidBashFilePath) isDirectory:false)
  
  set strCommandText to ("#!/bin/bash\n#com.cocolog-nifty.quicktimer.icefloe\n#################################################\nSTR_FFMPEG_PATH=\"" & strFfmpegPath & "\"\nSTR_INPUT_MOVIE_PATH=\"" & strVideoFilePath & "\"\nSTR_FFMETADATA1_PATH=\"" & ocidSaveTextFilePathURL & "\"\nSTR_PUTPUT_MOVIE_PATH=\"" & strOutMovieFilePath & "\"\n\"$STR_FFMPEG_PATH\" -i \"$STR_INPUT_MOVIE_PATH\" -i \"$STR_FFMETADATA1_PATH\" -map_metadata 1 -codec copy \"$STR_PUTPUT_MOVIE_PATH\"\n\nexit 0") as text
  set ocidCommandTextStr to refMe's NSString's stringWithString:(strCommandText)
  #保存
  set listDone to ocidCommandTextStr's writeToURL:(ocidBashPathURL) atomically:(refMe's NSNumber's numberWithBool:true) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)
  #実行権をつける
  set appFileManager to refMe's NSFileManager's defaultManager()
  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:(493) forKey:(refMe's NSFilePosixPermissions)
  set listDone to appFileManager's setAttributes:(ocidAttrDict) ofItemAtPath:(ocidBashPathURL's |path|) |error|:(reference)
  
  ##############################################
  ##AppleScriptファイル出力
  ##############################################
  ###ログ用
  set strCommandText to ("" & strFfmpegPath & " -i \"" & strVideoFilePath & "\" -i \"" & ocidSaveTextFilePathURL & "\" -map_metadata 1 -codec copy \"" & strOutMovieFilePath & "\"") as text
  
  ####新規Appleスクリプト用
  set strText to ("do shell script \"" & strFfmpegPath & " -i \\\"" & strVideoFilePath & "\\\" -i \\\"" & ocidSaveTextFilePathURL & "\\\" -map_metadata 1 -codec copy \\\"" & strOutMovieFilePath & "\\\"\"") as text
  
  
  tell application "Script Editor"
    set objActivDoc to make new document with properties {text:strText}
  end tell
  
  tell application "Script Editor"
activate
    tell objActivDoc
activate
    end tell
  end tell
  
  
return strCommandText
  
end if


##############################################
## エラー発生時のログ用
##############################################


to doGetErrorData(ocidNSErrorData)
  #####個別のエラー情報
log "エラーコード:" & ocidNSErrorData's code() as text
log "エラードメイン:" & ocidNSErrorData's domain() as text
log "Description:" & ocidNSErrorData's localizedDescription() as text
log "FailureReason:" & ocidNSErrorData's localizedFailureReason() as text
log ocidNSErrorData's localizedRecoverySuggestion() as text
log ocidNSErrorData's localizedRecoveryOptions() as text
log ocidNSErrorData's recoveryAttempter() as text
log ocidNSErrorData's helpAnchor() as text
  set ocidNSErrorUserInfo to ocidNSErrorData's userInfo()
  set ocidAllValues to ocidNSErrorUserInfo's allValues() as list
  set ocidAllKeys to ocidNSErrorUserInfo's allKeys() as list
  repeat with ocidKeys in ocidAllKeys
    if (ocidKeys as text) is "NSUnderlyingError" then
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedDescription() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedFailureReason() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedRecoverySuggestion() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s localizedRecoveryOptions() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s recoveryAttempter() as text
log (ocidNSErrorUserInfo's valueForKey:ocidKeys)'s helpAnchor() as text
    else
      ####それ以外の値はそのままテキストで読める
log (ocidKeys as text) & ": " & (ocidNSErrorUserInfo's valueForKey:ocidKeys) as text
    end if
  end repeat
  
end doGetErrorData



|

より以前の記事一覧

その他のカテゴリー

Acrobat Acrobat Annotation Acrobat Dialog Acrobat Form Acrobat JS Acrobat Open Acrobat Plugin Acrobat python Acrobat Reader Acrobat Sequ Acrobat Stamps Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin System Information Admin Tools Admin Users Admin Volumes Adobe Apple AppleScript AppleScript Guide AppleScript Accessibility AppleScript AppKit AppleScript Applications AppleScript AppStore AppleScript Archive AppleScript Attributes AppleScript Automator AppleScript AVAsset AppleScript AVconvert AppleScript AVFoundation AppleScript AVURLAsset AppleScript BackUp AppleScript Barcode AppleScript Bash AppleScript Basic AppleScript Basic Path AppleScript Bluetooth AppleScript BOX AppleScript Browser AppleScript Calendar AppleScript CD/DVD AppleScript Choose AppleScript Chrome AppleScript CIImage AppleScript CloudStorage AppleScript Color AppleScript com.apple.LaunchServices.OpenWith AppleScript Console AppleScript Contacts AppleScript CotEditor AppleScript CURL AppleScript current application AppleScript Date&Time AppleScript delimiters AppleScript Desktop AppleScript Device AppleScript Disk AppleScript do shell script AppleScript Dock AppleScript DropBox AppleScript eMail AppleScript Encode Decode AppleScript Error AppleScript EXIFData AppleScript ffmpeg AppleScript File AppleScript Finder AppleScript Firefox AppleScript Folder AppleScript Fonts AppleScript GIF AppleScript HTML AppleScript Icon AppleScript Illustrator AppleScript Image Events AppleScript Image2PDF AppleScript ImageOptim Applescript iWork AppleScript Javascript AppleScript Jedit AppleScript Json AppleScript Label AppleScript List AppleScript locationd AppleScript LRC AppleScript LSSharedFileList AppleScript m3u8 AppleScript MakePDF AppleScript Map AppleScript Math AppleScript Microsoft AppleScript Microsoft Edge AppleScript Microsoft Excel AppleScript Mobileconfig AppleScript Mouse AppleScript Movie AppleScript Music AppleScript NetWork AppleScript Notes AppleScript NSArray AppleScript NSBitmapImageRep AppleScript NSBundle AppleScript NSCFBoolean AppleScript NSCharacterSet AppleScript NSColor AppleScript NSColorList AppleScript NSData AppleScript NSDictionary AppleScript NSError AppleScript NSEvent AppleScript NSFileAttributes AppleScript NSFileManager AppleScript NSFont AppleScript NSFontManager AppleScript NSImage AppleScript NSIndex AppleScript NSKeyedArchiver AppleScript NSKeyedUnarchiver AppleScript NSLocale AppleScript NSMutableArray AppleScript NSMutableDictionary AppleScript NSMutableString AppleScript NSNotFound AppleScript NSNumber AppleScript NSOpenPanel AppleScript NSPasteboard AppleScript NSPDFImageRep AppleScript NSpoint AppleScript NSPredicate AppleScript NSRange AppleScript NSRegularExpression AppleScript NSRunningApplication AppleScript NSScreen AppleScript NSSize AppleScript NSString AppleScript NSStringCompareOptions AppleScript NSTask AppleScript NSTimeZone AppleScript NSURL AppleScript NSURL File AppleScript NSURLBookmark AppleScript NSURLComponents AppleScript NSURLResourceKey AppleScript NSUserDefaults AppleScript NSUUID AppleScript NSView AppleScript NSWorkspace AppleScript Numbers AppleScript OAuth AppleScript ObjC AppleScript OneDrive AppleScript Osax AppleScript PDF AppleScript PDFAnnotationWidget AppleScript PDFContext AppleScript PDFDisplayBox AppleScript PDFDocumentPermissions AppleScript PDFKit AppleScript PDFnUP AppleScript PDFOutline AppleScript Photos AppleScript Photoshop AppleScript Plist System Events AppleScript PostScript AppleScript prefPane AppleScript Preview AppleScript Python AppleScript QR AppleScript QR Decode AppleScript QuickLook AppleScript QuickTime AppleScript record AppleScript Regular Expression AppleScript Reminders AppleScript ReName AppleScript Repeat AppleScript RTF AppleScript Safari AppleScript SaveFile AppleScript ScreenCapture AppleScript ScreenSaver AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript Sort AppleScript Sound AppleScript Spotlight AppleScript SRT AppleScript StandardAdditions AppleScript stringByApplyingTransform AppleScript System Events AppleScript System Settings AppleScript TemporaryItems AppleScript Terminal AppleScript Text AppleScript Text CSV AppleScript Text TSV AppleScript TextEdit AppleScript Translate AppleScript Trash AppleScript Twitter AppleScript UI AppleScript Unit Conversion AppleScript UTType AppleScript valueForKeyPath AppleScript Video AppleScript VisionKit AppleScript Visual Studio Code AppleScript webarchive AppleScript webp AppleScript Wifi AppleScript XML AppleScript XML EPUB AppleScript XML OPML AppleScript XML Plist AppleScript XML RSS AppleScript XML SVG AppleScript XML TTML AppleScript XML webloc AppleScript YouTube AppleScript Zero Suppress Applications Barcode OnLine Tools CityCode Design iPhone List Logs lsappinfo Memo Music perl PlistBuddy pluginkit postalcode ReadMe SF Symbols character id SF Symbols Entity sips Skype Slack sqlite TCC Tools Typography Video Wacom zoom