Who are the clients of my shared iTunes library?

Is it possible to see who is currently connected and listening to a shared iTunes library? Is it possible to see which songs they listen to and how many/often?

It's not really important; I'm just curious about it. Would be nice to know which colleagues love my music…


Solution 1:

From Macworld:

Keeping tabs on who’s listening

The Sharing pane in iTunes’ preferences will tell you how many users are connected to your shared library. But what it won’t tell you is what they’re actually listening to. To find out, open Activity Monitor (/Applications/Utilities), highlight the iTunes entry, and then click on the Inspect button in the toolbar. Now click on the Open Files And Ports tab and then scroll to the bottom of the list in the window below. If you’re listening to something in iTunes, your current song will show up first, but anything someone connected to you is viewing or listening to will show up like this:

192.168.1.3:daap->192.168.1.8:56089
/Volumes/Backup/iTunes Music/Brian Eno/Another Day On Earth/01 This.m4a

In this example, the person is connected from IP address 192.168.1.8 and is listening to Brian Eno’s “This.”

Solution 2:

A simple one-liner in the terminal will give you the info.

$ lsof +D ~/Music/iTunes/iTunes\ Media/ -i | grep iTunes

will return something along the lines of

iTunes     5631 Bryson   23r   DIR              14,12      102 3747082 /Users/Bryson/Music/iTunes/iTunes Media/Automatically Add to iTunes.localized
iTunes     5631 Bryson   24r   DIR              14,12      170 3747080 /Users/Bryson/Music/iTunes/iTunes Media
iTunes     5631 Bryson   42u  IPv4 0xffffff80178d0c00      0t0     TCP bryson.hostname.com:51447->10.20.1.5:daap (ESTABLISHED)
iTunes     5631 Bryson   43u  IPv4 0xffffff80178d1a40      0t0     TCP *:daap (LISTEN)
iTunes     5631 Bryson   44u  IPv6 0xffffff802572f240      0t0     TCP *:daap (LISTEN)
iTunes     5631 Bryson   47u  IPv4 0xffffff8015f7c500      0t0     TCP bryson.hostname.com:daap->james-win7.lvpp.local:49509 (ESTABLISHED)
iTunes     5631 Bryson   48u  IPv4 0xffffff801722ca40      0t0     TCP bryson.hostname.com:daap->james-win7.lvpp.local:51393 (ESTABLISHED)

The first few lines are my local connection to those files. The last two lines, to the right side of their data, say:

bryson.hostname.com:daap->james-win7.lvpp.local:51393 (ESTABLISHED)

This indicates that the computer named james-win7.lvpp.local (in this example, that would be a computer on my office's internal Windows Server domain) is connected to your library. Because I know the people in my office, I know that's my buddy james one office over.

Solution 3:

If you are curious, you can tell who’s connected to your computer and find out their IP Address, but that’s all you can find.

Open Terminal (/Applications/Utilities/Terminal.app)

And type:

netstat | grep daap

The output will look like this (albeit with other IP addresses):

tcp4       0      0  your.ip.address.daap      x.y.z.w.49195     ESTABLISHED

Being x.y.z.w the ip addresses of those who are connected to your library. That user above is not listening to anything (but it’s connected to your library).

You might see duplicated entires for the same IP, for example:

tcp4       0 131768  your.ip.address.daap      x.y.z.w.49198     ESTABLISHED
tcp4       0      0  your.ip.address.daap      x.y.z.w.49195     ESTABLISHED

That means that computer from ip x.y.z.w is listening to something. I believe the ports (49195 and 49198) are not static and might change, but I really don’t remember now. The important part is the daap which stands for Direct Audio Access Protocol.

Essentially your asking nestat to list all your connections to/from your computer and filtering the (rather large) output to those lines which contain ‘daap’ in them.

If you get no output or it seems to be “hung”, try using ’netstat’ alone and then scroll up to manually find them. Please note that the command may take a few (sometimes more than 20-30 secs) to produce output, depending upon your network.

The ESTABLISHED part means the connection is still alive.

For more information about netstat, don’t hesitate typing:

man netstat

in the Terminal.

You might also see your own computer “listening” (iTunes Sharing enabled), it should look like this:

tcp6       0      0  *.daap                 *.*                    LISTEN
tcp4       0      0  *.daap                 *.*                    LISTEN

Notice that is one for ipv4 and one for ipv6 and the LISTEN part. :)

An alternative that I am not sure if it’s still working, is Doug’s Applescripts for iTunes: What Are People Listening 2, which will theoretically find out who/what are they listening. I haven’t tried that one and it seems to be from 2004, however it may still work and you might want to check that out.

Applet displays the name and artist of shared songs being listened to by others on the local network.

Solution 4:

The iTunes Connection Monitor Widget appears to do what you want, but it may be out of date. The comments indicate it might need modification to work with the latest Mac OS.

Anyway, it's a start. Give it a try. The good news is that since it's a widget, you'll be able to look at the innards.