How to interface N1MM live score with WordPress

Enable Score broadcast

N1MM has this feature to broadcast many information via UDP datagrams.

Requirements

  • Own linux server
  • Python 2.7 (deprecated)
  • Python good knowledges
  • WordPress instance

  • Setup

    				
    					import socket
    import json
    import xmltodict
    port = XXXX
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.bind(("", port))
    print("waiting on port:", port)
    while 1:
    data, addr = s.recvfrom(1024)
    data_dict = xmltodict.parse(data)
    json_data=json.dumps(data_dict)
    f = open("score.json", "w")
    f.write(json_data)
    f.close()
    with open("score.json", "r") as f:
    data = json.load(f)
    qso=int(data['dynamicresults']['breakdown']['qso'][1]['#text'])
    multi=int(data['dynamicresults']['breakdown']['mult'][1]['#text'])
    pts=int(data['dynamicresults']['breakdown']['point'][1]['#text'])
    score=multi*pts
    d=open("final.json", "w")
    d.write(json.dumps({ 'sumar':'QSO='+str(qso)+" Multi="+str(multi)+" Points="+str(pts)+" Score="+str(score) }))