1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
|
--
-- AppDelegate.applescript
-- BOOMERANG14AOUT2
--
-- Created by samy samy on 14/08/2014.
-- Copyright (c) 2014 IN THE SOCKS OF FCP X. All rights reserved.
--
script AppDelegate
propertyparent : class"NSObject"
-- IBOutlets
property window : missing value
property textFieldITW : "ITW"
property textFieldLIVE : "LIVE"
property textFieldILL : "ILL"
property textFieldAMB : "AMB"
property textFieldAutre1 : ""
property textFieldAutre2 : ""
property textFieldAutre3 : ""
property textFieldAutre4 : ""
property textFieldAutre5 : ""
property cocherFav : false
property cocherMotcle : false
property cocherMarqueur : false
property cocherRole : false
property textFieldCote : "*"
property textFieldNiveauCote : "5"
property source : ""
property Guil : ASCII character 34 -- 34 est un guillement
property CROCHET : ASCII character 60 -- 60 est un chevron <
property PROLE : ""
on buttonClicked_(sender)
-- pour verifier que les valeurs entrée dans les champs sont prise en compte ((à supprimer ensuite)
display alert "Hello there " & textFieldITW & textFieldLIVE & textFieldAutre1 & textFieldAutre2 & textFieldAutre3 & textFieldAutre4 & textFieldAutre5 & textFieldCote & textFieldNiveauCote
-- pour verifier que les cases cochées sont prise en compte (à supprimer ensuite)
if cocherFav then
display alert "les favoris sont cochés "
end if
if cocherMotcle then
display alert "les Mots clés sont cochés "
end if
if cocherMarqueur then
display alert "les Marquers sont cochés "
end if
if cocherRole then
display alert "les Roles sont cochés "
end if
-- fenetre pour choisir le fichier xml
set source to choose file of type {"fcpxml"} with prompt "Choissez le fichier .fcpxml:"
-- lancer le programme principal
ProgPrincipal_(source)
end buttonClicked_
-- programme principal
on ProgPrincipal_(source)
-- créer le nouveau nom de fichier "nom orginal _NEW"
tell application"Finder"
set Nom to name of source
set NouvNom to (text 1 thru ((length of Nom) - 7) of Nom) & "_NEW.fcpxml"
-- alerte pour dire que le fichier est créé ( à supprimer ensuite)
display alert "your NEW fcpxml is ready" giving up after 5
end tell
-- Initialisation des variables
set MesLignes to paragraphs of (read source) -- lecture des lignes source
try
open for access file Destination with write permission -- crée le fichier destination et l'ouvre en écriture
endtry
repeat with LaLigne in MesLignes -- boucle sur les lignes du fichier
if (LaLigne contains "<rating start") then
LRatingkeyword(LaLigne, Destination)
LRatingmarker(LaLigne, Destination)
else if LaLigne contains "</event>" then
L_Events(LaLigne, Destination)
else if LaLigne contains "<clip name=" then
set PROLE to LClipName(LaLigne, Destination)
else if LaLigne contains "<video name=" then
LVideoName(LaLigne, Destination, PROLE)
else if LaLigne contains "<audio name=" then
L_Audio_Name(LaLigne, Destination, PROLE)
set PROLE to ""
else
write (LaLigne & return) to file Destination starting at eof
end if
end repeat
close access file Destination
display alert "your NEW fcpxml is ready" giving up after 5
end ProgPrincipal
-- ********************************* traite les lignes commençant par "raiting start"
on LRatingkeyword(Ligne, Fichier)
set TStart to CROCHET & "rating start=" & Guil
set TFavorite to "value=" & Guil & "favorite" & Guil
set TNote to "note="
set TName to "name="
set Ligne2 to text of Ligne
write (Ligne & return) tofile Fichier starting at eof -- on réécrit en premier la ligne telle qu'elle est
-- rechercher si la ligne contient value="favorite", mais ne contient ni * ni ** ni *** dans une note
if (Ligne contains TFavorite) then
set Asterix to ""
set PNote to (text ((offset of TNote in Ligne) + 6) thru ((length of Ligne) - 3) of Ligne)
if (Ligne contains"name=") then
set PStart to (text ((offset of TStart in Ligne) + 14) thru ((offset of TName in Ligne) - 1) of Ligne)
else
set PStart to (text ((offset of TStart in Ligne) + 14) thru ((offset of TFavorite in Ligne) - 1) of Ligne)
end if
if (PNote contains"***") then
set Asterix to "***"
else if (PNote contains "**") then
set Asterix to "**"
else if (PNote contains "*") then
set Asterix to "*"
end if
if Asterix is not "" then
set Ligne to CROCHET & "keyword start=" & PStart & "value=" & Guil & Asterix & Guil & " note=" & Guil & PNote & Guil & "/>"
write (Ligne & return) to file Fichier starting at eof
end if
end if
end LRatingkeyword
-- ********************************* traite les lignes commençant par "raiting start"
on L_Rating_marker(Ligne, Fichier)
set T_Start to CROCHET & "rating start=" & Guil
set T_Favorite to "value=" & Guil & "favorite" & Guil
set T_Note to "note="
set T_Name to "name="
set T_Duration to "duration="
--write (Ligne & return) to file Fichier starting at eof -- on réécrit en premier la ligne telle qu'elle est
-- rechercher si la ligne contient value="favorite", mais ne contient ni * ni ** ni *** dans une note
if (Ligne contains T_Favorite) then
set Asterix to ""
set P_Note to (text ((offset of T_Note in Ligne) + 6) thru ((length of Ligne) - 3) of Ligne)
set P_Start to (text ((offset of T_Start in Ligne) + 14) thru ((offset of T_Duration in Ligne) - 1) of Ligne)
if (Ligne contains"name=") then
set P_FinP_Duration to (text ((offset of T_Name in Ligne) - 8) thru ((offset of T_Name in Ligne) - 1) of Ligne)
else
set P_FinP_Duration to (text ((offset of T_Favorite in Ligne) - 8) thru ((offset of T_Favorite in Ligne) - 1) of Ligne)
end if
if (P_Note contains "***") then
set Asterix to "***"
else if (P_Note contains "**") then
set Asterix to "**"
else if (P_Note contains "*") then
set Asterix to "*"
end if
if Asterix is not "" then
set Ligne to CROCHET & "marker start=" & P_Start & T_Duration & Guil & "100" & P_FinP_Duration & "value=" & Guil & P_Note & Guil & "/>"
write (Ligne & return) to file Fichier starting at eof
end if
end if
end L_Rating_marker
-- ********************************* traite les lignes commençant par "</event>" en écrivant d'abord 3 lignes différentes, puis la ligne elle-même
on L_Events(Ligne, Fichier)
set L_Key to"<keyword-collection name=" & Guil & "*" & Guil & "/>"
write (L_Key & return) to file Fichier starting at eof
set L_Key to"<keyword-collection name=" & Guil & "**" & Guil & "/>"
write (L_Key & return) to file Fichier starting at eof
set L_Key to"<keyword-collection name=" & Guil & "***" & Guil & "/>"
write (L_Key & return) to file Fichier starting at eof
write (Ligne & return) to file Fichier starting at eof
end L_Events
-- ********************************* traite les lignes començant par "<clip name=" : les écrit en extrayant le code P_Role si il existe
on L_Clip_Name(Ligne, Fichier)
set T_INTERVIEW to Interview of Mes_pref
set T_AMBIANCES to "AMB"
set T_ILLUSTRATION to "ILL"
set T_LIVE to "LIVE"
set L_P_ROLE to ""
if (Ligne contains T_INTERVIEW) then
set L_P_ROLE to T_INTERVIEW
else if (Ligne contains T_ILLUSTRATION) then
set L_P_ROLE to T_ILLUSTRATION
else if (Ligne contains T_AMBIANCES) then
set L_P_ROLE to T_AMBIANCES
else if (Ligne contains T_LIVE) then
set L_P_ROLE to T_LIVE
end if
write (Ligne & return) to file Fichier starting at eof
return L_P_ROLE -- renvoie la valeur L_P_Role (ITW, LIVE,ILL,AMB)
end L_Clip_Name
-- ********************************* traite les lignes commençant par <video name= et ajoute à la fin "role=video." & L_P_Roll & >
on L_Video_Name(Ligne, Fichier, L_P_ROLE)
set T_ROLE to "role="
if L_P_ROLE is not "" then
if (Ligne contains T_ROLE) then
set Ligne to (text 1 thru ((offset of T_ROLE in Ligne) - 1) of Ligne) & T_ROLE & Guil & "video." & L_P_ROLE & Guil & ">"
else
set Ligne to (text 1 thru -2 of Ligne) & " " & T_ROLE & Guil & "video." & L_P_ROLE & Guil & ">"
end if
end if
write (Ligne & return) to file Fichier starting at eof
end L_Video_Name
-- ********************************* traite les lignes commençant par <audio name= et ajoute à la fin "role=audio." & L_P_Roll & >
on L_Audio_Name(Ligne, Fichier, L_P_ROLE)
set T_ROLE to "role="
set T_CANAUX to "srcCh="
if L_P_ROLE is not "" then
set T_FinoLigne to (text ((offset of T_CANAUX in Ligne) - 1) thru ((length of Ligne) - 2) of Ligne)
set Ligne to (text 1 thru ((offset of "role=" in Ligne) + 4) of Ligne) & Guil & "dialogue" & "." & "audio" & L_P_ROLE & Guil & " " & T_FinoLigne & "/>"
end if
write (Ligne & return) to file Fichier starting at eof
end L_Audio_Name
on applicationWillFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
end applicationWillFinishLaunching_
on applicationShouldTerminate_(sender)
-- Insert code here to do any housekeeping before your application quits
return current application's NSTerminateNow
end applicationShouldTerminate_
endscript
|
Partager