ThreadStates

Who is Listening to my iTunes Shared Music?

One of the features of iTunes allows you to share your music over your LAN. Under the sharing tab iTunes preferences, you can choose to share your entire library or any of your playlists. Unfortunately, iTunes provides no functionality to see who is listening to your music, nor what they are listening to.

We can get that information using the unix command lsof, which lists all files opened by a process, and some sed and awk to format the output.

The following bash function lists the ip address of everyone connected to your shared library and all currently playing songs:

whoislistening() {
    lsof -nP -Fn -i tcp:3689 | sed 's/^.*->\(.*\):.*$/\1/' | grep -v ^[a-zA-Z] | uniq
    lsof -Fn | awk -F/ '/iTunes Music/ {printf("%s/%s/%s\n", $7, $8, $9)}'
}

Adding it to your ~/.bashrc will allow you to determine who is listening to what the next time you share your music.