More RadioID compatibilty
Fixing this to agree with the ever changing formats over at RadioID and to be more tolerant of missing data.
This commit is contained in:
parent
c1b7edfcc4
commit
66a082dbb8
@ -101,10 +101,14 @@ def mk_id_dict(_path, _file):
|
||||
_dict = {}
|
||||
try:
|
||||
with open(_path+_file, 'rU') as _handle:
|
||||
records = jload(_handle)['results']
|
||||
records = jload(_handle)
|
||||
records = records[records.keys()[0]]
|
||||
_handle.close
|
||||
for record in records:
|
||||
_dict[int(record['id'])] = record['callsign'].encode('ascii','ignore')
|
||||
try:
|
||||
_dict[int(record['id'])] = record['callsign'].encode('ascii','ignore')
|
||||
except:
|
||||
pass
|
||||
return _dict
|
||||
except IOError:
|
||||
return _dict
|
||||
@ -115,36 +119,46 @@ def mk_full_id_dict(_path, _file, _type):
|
||||
_dict = {}
|
||||
try:
|
||||
with open(_path+_file, 'rU') as _handle:
|
||||
records = jload(_handle)['results']
|
||||
records = jload(_handle)
|
||||
records = records[records.keys()[0]]
|
||||
_handle.close
|
||||
if _type == 'peer':
|
||||
for record in records:
|
||||
_dict[int(record['id'])] = {
|
||||
'CALLSIGN': record['callsign'],
|
||||
'CITY': record['city'],
|
||||
'STATE': record['state'],
|
||||
'COUNTRY': record['country'],
|
||||
'FREQ': record['frequency'],
|
||||
'CC': record['color_code'],
|
||||
'OFFSET': record['offset'],
|
||||
'LINKED': record['ts_linked'],
|
||||
'TRUSTEE': record['trustee'],
|
||||
'NETWORK': record['ipsc_network']
|
||||
}
|
||||
try:
|
||||
_dict[int(record['id'])] = {
|
||||
'CALLSIGN': record['callsign'],
|
||||
'CITY': record['city'],
|
||||
'STATE': record['state'],
|
||||
'COUNTRY': record['country'],
|
||||
'FREQ': record['frequency'],
|
||||
'CC': record['color_code'],
|
||||
'OFFSET': record['offset'],
|
||||
'LINKED': record['ts_linked'],
|
||||
'TRUSTEE': record['trustee'],
|
||||
'NETWORK': record['ipsc_network']
|
||||
}
|
||||
except:
|
||||
pass
|
||||
elif _type == 'subscriber':
|
||||
for record in records:
|
||||
_dict[int(record['id'])] = {
|
||||
'CALLSIGN': record['callsign'],
|
||||
'NAME': (record['fname'] + ' ' + record['surname']),
|
||||
'CITY': record['city'],
|
||||
'STATE': record['state'],
|
||||
'COUNTRY': record['country']
|
||||
}
|
||||
try:
|
||||
_dict[int(record['id'])] = {
|
||||
'CALLSIGN': record['callsign'],
|
||||
'NAME': (record['fname'] + ' ' + record['surname']),
|
||||
'CITY': record['city'],
|
||||
'STATE': record['state'],
|
||||
'COUNTRY': record['country']
|
||||
}
|
||||
except:
|
||||
pass
|
||||
elif _type == 'tgid':
|
||||
for record in records:
|
||||
_dict[int(record['id'])] = {
|
||||
'NAME': record['callsign']
|
||||
}
|
||||
try:
|
||||
_dict[int(record['id'])] = {
|
||||
'NAME': record['callsign']
|
||||
}
|
||||
except:
|
||||
pass
|
||||
return _dict
|
||||
except IOError:
|
||||
return _dict
|
||||
@ -191,12 +205,17 @@ if __name__ == '__main__':
|
||||
user file: ('callsign', 'city', 'country', 'fname', 'radio_id', 'remarks', 'state', 'surname')
|
||||
'''
|
||||
|
||||
#PEER_URL = 'https://www.radioid.net/api/dmr/repeater/?country=united%20states'
|
||||
#SUBSCRIBER_URL = 'https://www.radioid.net/api/dmr/user/?country=united%20states'
|
||||
PEER_URL = 'https://www.radioid.net/static/rptrs.json'
|
||||
SUBSCRIBER_URL = 'https://www.radioid.net/static/users.json'
|
||||
|
||||
# Try updating peer aliases file
|
||||
result = try_download('/tmp/', 'peers.json', 'https://www.radioid.net/api/dmr/repeater/?country=united%20states', 0)
|
||||
result = try_download('/tmp/', 'peers.json', PEER_URL, 0)
|
||||
print(result)
|
||||
|
||||
# Try updating subscriber aliases file
|
||||
result = try_download('/tmp/', 'subscribers.json', 'https://www.radioid.net/api/dmr/user/?country=united%20states', 0)
|
||||
result = try_download('/tmp/', 'subscribers.json', SUBSCRIBER_URL, 0)
|
||||
print(result)
|
||||
|
||||
# Make Dictionaries
|
||||
|
2
setup.py
2
setup.py
@ -7,7 +7,7 @@ def readme():
|
||||
return file.read()
|
||||
|
||||
setup(name='dmr_utils',
|
||||
version='0.1.24',
|
||||
version='0.1.25',
|
||||
description='ETSI DMR (Digital Mobile Radio) Tier II Utilities',
|
||||
long_description='Modules to disassemble and assemble DMR packets, including generating and decoding various FEC routines',
|
||||
classifiers=[
|
||||
|
Loading…
Reference in New Issue
Block a user