Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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"
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"
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
You can’t perform that action at this time.