Skip to Content
iPod and iTunes Hacks
book

iPod and iTunes Hacks

by Hadley Stern
October 2004
Beginner to intermediate
456 pages
12h 36m
English
O'Reilly Media, Inc.
Content preview from iPod and iTunes Hacks

Search for Lyrics on Google

Use info from the current or selected track to search for lyrics pages via Google in Safari.

There are tons of lyrics sites on the Web that are ready to provide you with the words to your favorite songs. This hack Googles for the lyrics of the currently playing or selected song in iTunes. You’ll be singing along by the second verse.

The Code

This script gets the name and artist of the currently playing track (or, if no track is playing, the selected track), tidies up the text, and incorporates it into a URL that is then used by Safari to search Google for sites containing the lyrics of that particular track:

    -- base of the URL string, includes the term "lyrics"
    property baseURL : "http//www.google.com/search?q=lyrics+"

    tell application "iTunes"

      -- get a reference to playing or selected track
      if player state is not stopped then
        set theTrack to current track
      else if selection is not {} then
        set theTrack to (item 1 of selection)
      else
        display dialog "Nothing is playing or selected." buttons {"Cancel"} ¬
          default button 1 with icon 0
      end if

      -- get the name and artist and replace "bad" characters
      tell theTrack
        set nom to my fixChars(name)
        set art to my fixChars(artist)

      end tell

      -- assemble URL string, replace spaces with "+"
      set theURL to (baseURL & ¬ (my replace_chars((art & "+" & nom), " ", "+"))) as text my open_location(theURL) end tell on fixChars(a) set myDelims ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

iPOD & ITUNES for Dummies Portable Edition

iPOD & ITUNES for Dummies Portable Edition

Tony Bove
Windows Server® 2008 Active Directory® Resource Kit

Windows Server® 2008 Active Directory® Resource Kit

Conan Kezema Stan Riemer Mike Mulcare, Byron Wright, and Microsoft Active Directory
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz

Publisher Resources

ISBN: 0596007787Supplemental ContentErrata Page