-- collect recording parameters set current_date to current date tell application "iCal" set rr_calendar to the first calendar whose title is "Freebox TV" set current_event to the last event of rr_calendar whose start date is less than or equal to current_date and end date is greater than or equal to current_date set event_properties to the properties of current_event set radio_station to the summary of event_properties set radio_URL to the url of event_properties set start_date to the start date of event_properties set end_date to the end date of event_properties quit end tell set mon_instant to current date log mon_instant set mon_jour_semaine to weekday of mon_instant set mon_jour to day of mon_instant set mon_mois to month of mon_instant set mon_annee to year of mon_instant set mes_heures to (time of mon_instant) div 3600 set mes_minutes to ((time of mon_instant) mod 3600) div 60 set mes_secondes to (time of mon_instant) mod 60 set mon_decalage_horaire to ((((time to GMT) / 3600) as integer) as string) & " heure(s)" if radio_station = "2" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/201" else if radio_station = "3" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/202" else if radio_station = "5" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/203" else if radio_station = "6" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/205" else if radio_station = "7" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/204" else if radio_station = "8" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/372" else if radio_station = "9" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/373" else if radio_station = "11" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/374" else if radio_station = "12" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/382" else if radio_station = "13" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/226" else if radio_station = "14" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/376" else if radio_station = "15" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/418" else if radio_station = "16" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/417" else if radio_station = "17" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/416" else if radio_station = "18" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/419" else if radio_station = "21" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/210" else if radio_station = "22" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/211" else if radio_station = "23" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/206" else if radio_station = "24" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/238" else if radio_station = "37" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/220" else if radio_station = "44" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/219" else if radio_station = "52" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/218" else if radio_station = "60" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/209" else if radio_station = "63" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/222" else if radio_station = "64" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/216" else if radio_station = "75" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/207" else if radio_station = "77" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/208" else if radio_station = "79" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/355" else if radio_station = "80" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/223" else if radio_station = "81" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/224" else if radio_station = "82" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/225" else if radio_station = "83" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/227" else if radio_station = "84" then set radio_URL to "rtsp://mafreebox.freebox.fr/freeboxtv/221" end if --check URL and start recording if radio_URL is missing value then error number -100 end if set nom to (radio_station as string) & "_" & (mon_jour as string) & (mon_mois as string) & (mes_heures as string) & (mes_minutes as string) set tempfile to (system attribute "HOME") & "/Movies/" & nom & ".mpg" set tempfilereal to tempfile do shell script "/Applications/VLC.app/Contents/MacOS/VLC -vvv " & radio_URL & " --sout file/ts:" & tempfilereal & " &> /dev/null &" -- sleep till end_date set duration to (end_date - (current date)) delay duration -- stop recording tell application "VLC" stop -- wait 80 seconds to let saving finishes delay 80 quit end tell quit