Outre la prise en charge conventionnelle d'AppleScript, EyeTV 3 offre
la possibilité d'utiliser des scripts déclenchés par des événements.
Leur déclenchement est automatique dès que l’événement correspondant se
produit. EyeTV propose les événements de déclenchement suivants :
ScheduleCreated
: les scripts utilisant ce déclencheur démarrent après la création
d'une programmation.
RecordingDone
: les scripts utilisant ce déclencheur démarrent après l'achèvement
d'un enregistrement.
ExportDone
: les scripts utilisant ce déclencheur démarrent après l'exportation
complète d'un enregistrement.
RecordingDeleted
: les scripts utilisant ce déclencheur démarrent après la suppression
d'un enregistrement.
Vous trouverez des exemples de scripts déclenchés commentés sur le CD
d'installation d'EyeTV, plus bas dans cet article et également
sur notre Espace
EyeTV. Pour pouvoir exécuter ces scripts, EyeTV doit les
trouver dans le dossier /Bibliothèque/Application
Support/EyeTV/Scripts/TriggeredScripts
Si ce répertoire n'existe pas, créez-le manuellement. Remarque : le
répertoire TriggeredScripts et son contenu n'apparaissent pas dans le
menu Script d’EyeTV, puisque les scripts déclenchés ne sont jamais
lancés manuellement.
Exemples de scripts pour RecordingDone
Ce script permet
de mettre le Mac en veille après qu'un enregistrement soit terminé.
-- RecordingDone.scpt
-- Sleep:This script sleeps your mac after EyeTV completes a recording.
on
RecordingDone(RecordingID)
tell application "System Events" to sleep
end RecordingDone
Ce script permet
d'éteindre le Mac après qu'un enregistrement soit terminé.
-- RecordingDone.scpt
-- Shut Down: This script shuts down your mac after EyeTV completes a
recording.
on
RecordingDone(RecordingID)
tell application "System Events" to shut down
end RecordingDone
Ce script permet
d'éteindre le Mac après qu'un enregistrement soit terminé.
Avant l'extinction, le
script affichera un dialogue pour vous indiquer que le Mac s'éteindra
dans trois minutes si vous n'annulez pas le dialogue en cours.
-- RecordingDone.scpt
-- Shut Down:This script shuts down your mac after EyeTV completes a
recording. At the completion of a recording, this script will raise a
dialog box stating that it will shut down your Mac in 3 minutes unless
the dialog box is dismissed.
on
RecordingDone(RecordingID)
set myapp to "EyeTV"
tell application myapp to quit
delay 10
with timeout of 300 seconds
display dialog "This mac will shut down in 3 minutes unless you click
Stop!" with icon 0 buttons {"Stop!"} giving up after 180 default button
"Stop!"
set theresults to the result
if gave up of theresults is true then
tell application "System Events" to shut down
end if
end timeout
end RecordingDone
Ce script permet de
renommer sélectivement un enregistrement terminé de façon à ce que le
nom consiste en la date, suivie du nom de votre choix ("myshortname").
-- RecordingDone.scpt
-- Selective Rename: This script will selectively rename a finished
recording so that the name consists of the date, followed by
"myshortname". So if you were recording "Sesame Street", you could
replace myshortname with "Ernie", and the script would rename the
recordings to "YYYY-MM-DD-Ernie
on
RecordingDone(RecordingID)
tell application "EyeTV"
set newrecording to (RecordingID as integer)
set isshow to get the title of recording id newrecording
--mysearch should be specified to the particular show you are
selectively renaming.
set mysearch to "happy"
if isshow contains mysearch then
--replace "myshortname" with the short name of your choice.
set the title of recording id newrecording to ((year of (current date)
as number) & "-" & (month of (current date) as number)
& "-" & (day of (current date) as number) & "-"
& "myshortname" as text)
end if
end tell
end RecordingDone
Exemples de scripts
pour ExportDone
Ce script permet
de mettre le Mac en veille après qu'une exportation soit terminée.
-- ExportDone.scpt
-- Sleep:This script sleeps your mac after EyeTV completes an export.
on ExportDone(RecordingID)
tell application "System Events" to sleep
end ExportDone
Ce script permet
d'éteindre le Mac après qu'une exportation soit terminée.
-- ExportDone.scpt
-- Shut Down: This script shuts down your mac after EyeTV completes an
export.
on ExportDone(RecordingID)
tell application "System Events" to shut down
end ExportDone
Ce script compare la
durée de l'enregistrement original avec la durée du fichier exporté
correspondant. Si la différence de durée est inférieure à 1 %,
l'enregistrement original est supprimé. Attention, une fois activé, ce
script pourra supprimer des enregistrements sans confirmation de votre
part.
-- ExportDone.scpt
-- Delete Original After Export With File Duration Check: This script
attempts to compare the original EyeTV recording duration to the
exported file's duration of the same name. If they are within 1% of
each other, then the script deletes the recording. Warning: This
script, when enabled, will automatically delete content without a
prompt.
on ExportDone(recordingID)
set myid to recordingID as integer
tell application "EyeTV"
set origdur to get the actual duration of recording id myid
set myshortname to get the name of recording id myid
end tell
delay 5 -if the script does not seem to work, try increasing this delay
slightly.
tell application "iTunes"
tell playlist "TV Shows"
set mytv to (get the location of every track whose name is myshortname)
if the (count of mytv) is 1 then
set mylocation to item 1 of mytv as string
else
display dialog "There were multiple iTunes tracks named " &
myshortname & ". No EyeTV recordings were deleted."
end if
end tell
end tell
tell application "QuickTime Player"
if mylocation is not {} then
open file mylocation
set exportdur to get the (duration of document myshortname) / (get the
time scale of document myshortname)
quit
end if
end tell
if origdur > exportdur then
set thediff to (origdur - exportdur)
else
set thediff to (exportdur - origdur)
end if
--Small discrepancies between the original file duration and the
exported file duration can occur during exports. To compensate for
this, the script assumes that if the difference in file duration is
less than 1% of the total duration, then the export was successful.
if thediff < origdur * (0.01) then
--uncomment the line below to enable file deleting.
--tell application "EyeTV" to delete recording id myid
end if
end ExportDone
Exemple de script
pour ScheduleCreated
Ce script lit la taille
de l'espace disque disponible sur le disque contenant l'archive EyeTV
et la compare à la taille approximative de la programmation
d'enregistrement que vous venez d'effectuer. Si la taille résultante
sur le disque après enregistrement est inférieure à 2 Go, une boite de
dialogue vous avertira.
-- ScheduleCreated.scpt
-- Free Space Check: This script checks the available disk space on the
drive containing the "EyeTV Archive" and compares that to the
approximate size of the scheduled recording that you have just made. If
you would end up with less than 2 GB of free space afterwards, it will
raise a dialog box to warn you.
on
ScheduleCreated(programID)
tell application "EyeTV"
get the name of program id programID
set mydur to (get the duration of program id programID) / 3600
--MyQual is the approximate GB/hour of your current recording quality.
Adjust this value as necessary. For standard resolution recordings,
this will be about 1.8 - 2.7. For 720p recordings, it is about 6. For
1080i, about 8.
set myqual to 2
set mysize to mydur * myqual
set AppleScript's text item delimiters to {":"}
set mydrive to (text items 1 thru 1 of (get the repository url as
string)) as alias
end tell
tell application "Finder"
set myspace to (get free space of disk mydrive) / (1024 * 1024 * 1024)
if mysize > (myspace - 2) then
display dialog "This schedule will take approximately " &
mysize & "GB of space. This may cause your EyeTV Archive drive
to run out of space." buttons {"Ok"}
end if
end tell
end ScheduleCreated
Exemple de script
pour RecordingDeleted
Bientôt disponible.