#!/usr/bin/env python2
from scapy.all import *

def airplay_callback(pkt):
	try:
		if pkt['Raw'].load[0:5] == 'SETUP':
			# Someone is starting to play! Add them to the list yo
			with open('/tmp/playing.txt', 'w') as f:
				f.write(pkt[IP].src)
			print "Updated playing.txt to " + pkt[IP].src
		elif pkt['Raw'].load[0:5] == 'TEARD':
			# Someone is getting *off* those speakers, yo
			with open('/tmp/playing.txt', 'w') as f:
				pass # Rewrite it with nothing
			print "Updated playing.txt to be blank"
	except:
		pass # meh
sniff(filter="tcp and port 5000", store=0, prn=airplay_callback);

#!/usr/bin/env python2
from scapy.all import *

cur_ip = False

def airplay_callback(pkt):
	try:
		if pkt[IP].sprintf('%proto%') == 'tcp':
			# This could be anything! Parse further
			if pkt['Raw'].load[0:5] == 'TEARD':
				# Anyone can teardown, only remove the IP if it's the currently playing person
				global cur_ip
				if cur_ip == pkt[IP].src:
					# Someone is getting *off* those speakers, yo
					with open('/tmp/playing.txt', 'w') as f:
						pass # Rewrite it with nothing
					print "Updated playing.txt to be blank"
		else:
			# Should be UDP
			if cur_ip != pkt[IP].src:
				# A new person!
				with open('/tmp/playing.txt', 'w') as f:
					f.write(pkt[IP].src)
				cur_ip = pkt[IP].src
				print "Updated playing.txt to " + pkt[IP].src
	except:
		pass # meh
sniff(filter="port 5000 or port 6001", store=0, prn=airplay_callback);

Change sniffing to be more robust