#NEWLINE# def discover( timeout = 1.5 ) : #NEWLINE# #INDENT# 'Crude SSDP discovery. Returns a list of RxvDetails objects\n       with data about Yamaha Receivers in local network' #NEWLINE# sock = socket . socket ( socket . AF_INET , socket . SOCK_DGRAM , socket . IPPROTO_UDP ) #NEWLINE# sock . setsockopt ( socket . IPPROTO_IP , socket . IP_MULTICAST_TTL , 2 ) #NEWLINE# sock . sendto ( SSDP_MSEARCH_QUERY . encode ( 'utf-8' ) , ( SSDP_ADDR , SSDP_PORT ) ) #NEWLINE# sock . settimeout ( timeout ) #NEWLINE# responses = [ ] #NEWLINE# try : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# responses . append ( sock . recv ( 10240 ) ) #NEWLINE# #UNINDENT# #UNINDENT# except socket . timeout : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# results = [ ] #NEWLINE# for res in responses : #NEWLINE# #INDENT# m = re . search ( 'LOCATION:(.+)' , res . decode ( 'utf-8' ) , re . IGNORECASE ) #NEWLINE# if ( not m ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# url = m . group ( 1 ) . strip ( ) #NEWLINE# res = rxv_details ( sock ) #NEWLINE# if res : #NEWLINE# #INDENT# results . append ( res ) #NEWLINE# #UNINDENT# #UNINDENT# return results