Skip to content

Instantly share code, notes, and snippets.

@jmah
Created May 16, 2012 21:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmah/2714014 to your computer and use it in GitHub Desktop.
Save jmah/2714014 to your computer and use it in GitHub Desktop.
Suggest an unwatched movie from Delicious Library
tell front document of application "Delicious Library 2"
-- Choose a random unwatched movie
set unwatchedItems to every movie whose experienced is false
if (count of unwatchedItems) is 0 then
display dialog "You don't have any unwatched movies." buttons {"OK"} default button "OK"
return
end if
set randomIndex to random number from 1 to (count of unwatchedItems)
set candidateItem to item randomIndex of unwatchedItems
-- Select and suggest it
set selected shelves to first shelf whose name is "Movies"
set selected media to candidateItem
display dialog "How about watching " & name of candidateItem & "?" buttons {"Seen it", "Find Trailer", "Hmm"} default button "Hmm"
if button returned of the result is "Seen it" then
set experienced of candidateItem to true
else if button returned of the result is "Find Trailer" then
-- Search for a trailer in Safari. (It would be nice to instead use the default browser.)
tell application "Safari"
activate
search the web for (name of candidateItem & " movie trailer")
end tell
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment