Posts Tagged ‘applescript’

Linking Delicious Library to Your Movies

Friday, July 25th, 2008

If you’re like me, you value traveling light. If you’re like me, anything that can live in digital form does. I haven’t seen most of the actual DVD’s I own for quite some time now. But the movies on them all live on a hard drive that’s hooked up to my television. I love the instant gratification. I love that I can download a movie to my laptop and watch it on the plane.

Delicious Library makes this even cooler. As much as I love having everything digital, I miss being able to take a quick glance at 100 covers and recognize the one I want. I miss the association between images and memories. Delicious gives this back to me.

However, it’d be really cool if I could go browsing in my delicious “library”, find the movie I want, and double click it to play. Turns out you can easily extend the program with applescript, and a couple hours after I decided such a script didn’t already exist on the interweb, it now does.

This applescript will open vlc with the file associated to a media object in delicious. If there isn’t one already, it will prompt you for this file and then remember it for next time. It’s really simple, and happy :)

-- this will play the currently selected file in vlc using either 
-- the associated url or prompting you to find the file on disk
tell first document of application "Delicious Library 2"
    set selectedMedia to selected media
    repeat with selectedMedium in selectedMedia
        set movieUrl to associated URL of selectedMedium
        if movieUrl starts with "file://" then
            set movieFile to rich text 8 through end of movieUrl
            set movieFile to (choose file with prompt "Find the file for " \
                                            & name of selectedMedium & ":")
            set associated URL of selectedMedium to "file://" & movieFile
        end if
        tell application "VLC"
            open movieFile
        end tell
    end repeat
end tell

– thanks Wes for pointing me to such a cool program!