-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathalarm clock.applescript
34 lines (31 loc) · 1.31 KB
/
alarm clock.applescript
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
-- two variables to set
set podcastToUse to "NPR: 7AM ET News Summary Podcast"
-- this is from the album field
set timeToWakeUp to date "7:00 am" of (current date)
-- this will be fixed to be tomorrow if necessary
if timeToWakeUp is less than the (current date) then
set timeToWakeUp to timeToWakeUp + 1 * days
end if
delay timeToWakeUp - (current date)
tell application "iTunes"
set podcastPlaylist to the playlist "Podcasts"
set iTunesDJ to the playlist "iTunes DJ"
updatePodcast (first track of podcastPlaylist whose album is podcastToUse)
set finishedUpdating to false
repeat while finishedUpdating is false
try
set newTrack to the first track of podcastPlaylist whose album is podcastToUse and date added is greater than ((current date) - 12 * hours)
set finishedUpdating to true
set trackOnPlaylist to duplicate (a reference to newTrack) to iTunesDJ
set theDate to current date
set theTime to time string of theDate
set firstColon to offset of ":" in theTime
set timeString to text 1 through (firstColon + 2) of theTime & text (firstColon + 6) through end of theTime
say "Good morning. Today is " & date string of theDate & "; the time is " & timeString
tell iTunesDJ to play trackOnPlaylist
on error the errorMessage
set finishedUpdating to false
delay 10
end try
end repeat
end tell