travisgoodspeed / md380tools

Python tools and patched firmware for the TYT-MD380
804 stars 245 forks source link

DMR-MARC user ID database changing to JSON #857

Closed nivex closed 6 years ago

nivex commented 6 years ago

I went to do some lookups on the DMR-MARC database this evening and was greeted with a warning:

THIS TOOL WILL BE REPLACED BY AN API, ONLY FORMAT WILL BE JSON, CHANGE YOUR SCRIPTS NOW!

Since the firmware has a dependency on the database being in CSV for easy lookup, I wrote up a simple piece of code to grab the current JSON from DMR-MARC and render it in the current CSV format:

#!/usr/bin/env python3
import requests
req = requests.get('http://www.dmr-marc.net/cgi-bin/trbo-database/datadump.cgi?table=users&format=json')

dmrdb = req.json()

for user in dmrdb['users']:
    print("{radio_id},{callsign},{name} {surname},{city},{state},,{country}".format(**user))

This will emit the CSV on stdout. There's not much in the way of error checking here, mostly a proof of concept.

travisgoodspeed commented 6 years ago

Thanks for noticing this. Any chance you'd be interested in writing a pull request to exclusively use the JSON source?