Sto usando un registratore TV online per registrare programmi TV. Tali registrazioni vengono scaricate come podcast su iTunes. Il mio seguente Applescript dovrebbe semplicemente prendere quei podcast, aggiornare alcuni campi informativi e infine contrassegnarli come "programma TV" per farli apparire in "Programmi TV" in iTunes.
Funziona molto bene, solo la parte in cui voglio impostare il tipo di video su programma TV non sembra funzionare.
set video kind of aTrack to TV show
Ho anche dato un'occhiata alla sceneggiatura di Doug che fa qualcosa di simile e non riesco a trovare alcuna differenza.
Ecco il mio copione completo:
on matchRegExp(regex, txt, |caseSensitive?|)
if |caseSensitive?| then
set ci to "i"
else
set ci to ""
end if
set theRubyOneLiner to quote & "s = '" & txt & "'; s =~ /" & regex & "/" & ci & "; puts Regexp.last_match.to_a" & quote
set theCommand to "ruby -e " & theRubyOneLiner
set theMatchData to do shell script theCommand
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to character id 13 -- new line
set theMatchData to the text items of theMatchData
set AppleScript's text item delimiters to tid
theMatchData
end matchRegExp
tell application "iTunes"
set myLib to library playlist 1
set pods to every track of library playlist 1 whose genre is "Podcast" and album is "Online Videorecorder"
set ofi to fixed indexing
set fixed indexing to true
with timeout of 3000 seconds
repeat with aTrack in pods
set desc to long description of aTrack
try
set episode to last item of my matchRegExp("(Folge|Episode) (\\d+)", desc, true)
set season to last item of my matchRegExp("(Staffel|Season) (\\d+)", desc, true)
end try
set series to name of aTrack
set title to description of aTrack
set cat to category of aTrack
try
set video kind of aTrack to TV show
on error m
log m
end try
set episode number of aTrack to episode
set season number of aTrack to season
set show of aTrack to series
set episode ID of aTrack to title
set description of aTrack to desc
end repeat
end timeout
set fixed indexing to ofi
end tell