import socket

msg = \
    'M-SEARCH * HTTP/1.1\r\n' \
    'HOST:239.255.255.250:1900\r\n' \
    'ST:urn:schemas-upnp-org:device:MediaRenderer:1\r\n' \
    'MX:2\r\n' \
    'MAN:"ssdp:discover"\r\n' \
    '\r\n'

# Set up UDP socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
s.settimeout(2)
s.sendto(msg.encode(), ('239.255.255.250', 1900) )

try:
    while True:
        data, addr = s.recvfrom(65507)
        print(addr, '[%s]' % data.decode('utf-8'))
except socket.timeout:
    pass

343603fb3f70900fcc0f0b9e49973e145d204d9d
<mask token>

<mask token>
s.settimeout(2)
s.sendto(msg.encode(), ('239.255.255.250', 1900))
try:
    while True:
        data, addr = s.recvfrom(65507)
        print(addr, '[%s]' % data.decode('utf-8'))
except socket.timeout:
    pass

<mask token>
msg = (
    'M-SEARCH * HTTP/1.1\r\nHOST:239.255.255.250:1900\r\nST:urn:schemas-upnp-org:device:MediaRenderer:1\r\nMX:2\r\nMAN:"ssdp:discover"\r\n\r\n'
    )
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
s.settimeout(2)
s.sendto(msg.encode(), ('239.255.255.250', 1900))
try:
    while True:
        data, addr = s.recvfrom(65507)
        print(addr, '[%s]' % data.decode('utf-8'))
except socket.timeout:
    pass

import socket
msg = (
    'M-SEARCH * HTTP/1.1\r\nHOST:239.255.255.250:1900\r\nST:urn:schemas-upnp-org:device:MediaRenderer:1\r\nMX:2\r\nMAN:"ssdp:discover"\r\n\r\n'
    )
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
s.settimeout(2)
s.sendto(msg.encode(), ('239.255.255.250', 1900))
try:
    while True:
        data, addr = s.recvfrom(65507)
        print(addr, '[%s]' % data.decode('utf-8'))
except socket.timeout:
    pass

import socket

msg = \
    'M-SEARCH * HTTP/1.1\r\n' \
    'HOST:239.255.255.250:1900\r\n' \
    'ST:urn:schemas-upnp-org:device:MediaRenderer:1\r\n' \
    'MX:2\r\n' \
    'MAN:"ssdp:discover"\r\n' \
    '\r\n'

# Set up UDP socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
s.settimeout(2)
s.sendto(msg.encode(), ('239.255.255.250', 1900) )

try:
    while True:
        data, addr = s.recvfrom(65507)
        print(addr, '[%s]' % data.decode('utf-8'))
except socket.timeout:
    pass
