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

See What Other People Are Listening to

Monitor which of your shared iTunes audio files are being played by other machines on your network.

Which of your shared songs are being listened to by other users on the network right now? Run this hack and get the lowdown.

The Code

This script locates your designated Music folder and uses the Unix command lsofto list and display the names of files in it that are open. Open files will be the ones that are being accessed by other machines.

  -- locate Music folder
  set xmlFile to "iTunes:iTunes Music Library.xml"
  set musicFolder to ""
  try
    set musicFolder to ¬
	  parse_file((path to music folder as string) & ¬
        xmlFile) as string
  end try
  if musicFolder is "" then ¬
    set musicFolder to ¬
      parse_file((path to documents folder as string) & xmlFile)

  -- get open files in Music folder
  set song_list to paragraphs of ¬
    (do shell script "readout= lsof +D " & ¬
      (musicFolder as string) & ¬
      " | grep [mp3, m4p, m4a]; echo -n $readout;")

  -- format list of shared files for display
  try
    repeat with i from 1 to (count of song_list)
      set item i of song_list to ¬
        extract_data_from(item i of song_list)
    end repeat
  on error m
    display dialog "No songs being shared right now." buttons ¬
      {"Cancel"} default button 1
  end try

  -- display shared songs
  choose from list song_list with prompt ¬ "Currently sharing:" with empty selection allowed on extract_data_from(song_string) log song_string ...
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