Created
May 16, 2012 21:16
-
-
Save jmah/2714014 to your computer and use it in GitHub Desktop.
Suggest an unwatched movie from Delicious Library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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