Basic ADSBX single icao vs entire globe json conf
This commit is contained in:
parent
fa3c637d07
commit
99122d48c2
|
@ -0,0 +1,18 @@
|
|||
[DATA]
|
||||
#Source to pull data from
|
||||
#SHOULD BE ADSBX which is ADS-B Exchange or OPENS which is OpenSky
|
||||
#By default configured with OpenSky which anyone can use without a login
|
||||
#ADS-B Exchange has better data but is not avalible unless you feed their network or pay.
|
||||
SOURCE = OPENS
|
||||
|
||||
|
||||
#ADS-B Exchange https://www.adsbexchange.com/data/
|
||||
[ADSBX]
|
||||
API_KEY = apikey
|
||||
|
||||
#OpenSky https://opensky-network.org/apidoc/index.html
|
||||
#When using without your own login user and pass should be None
|
||||
[OPENSKY]
|
||||
USERNAME = None
|
||||
PASSWORD = None
|
||||
|
|
@ -2,27 +2,42 @@ import requests
|
|||
import configparser
|
||||
import json
|
||||
main_config = configparser.ConfigParser()
|
||||
main_config.read('config.ini')
|
||||
url = "https://adsbexchange.com/api/aircraft/json/"
|
||||
headers = {
|
||||
'api-auth': main_config.get('ADSBX', 'API_KEY'),
|
||||
'Content-Encoding': 'gzip'
|
||||
}
|
||||
main_config.read('mainconf.ini')
|
||||
import os
|
||||
#Set ADSBX URL Based off amount of Conf files
|
||||
if main_config.get('DATA', 'SOURCE') == "ADSBX":
|
||||
for filename in os.listdir(os. getcwd()):
|
||||
if filename.endswith(".ini") and filename != "mainconf.ini":
|
||||
plane_config = configparser.ConfigParser()
|
||||
plane_config.read(filename)
|
||||
plane_config.get('DATA', 'ICAO')
|
||||
icao_list = []
|
||||
icao_list.append(plane_config.get('DATA', 'ICAO'))
|
||||
if len(icao_list) > 1:
|
||||
url = "https://adsbexchange.com/api/aircraft/json/"
|
||||
elif len(icao_list) == 1:
|
||||
url = "https://adsbexchange.com/api/aircraft/icao/" + icao_list[0].upper() + "/"
|
||||
|
||||
response = requests.get(url, headers = headers)
|
||||
data = response.text
|
||||
data = json.loads(data)
|
||||
headers = {
|
||||
'api-auth': main_config.get('ADSBX', 'API_KEY'),
|
||||
'Content-Encoding': 'gzip'
|
||||
}
|
||||
if main_config.get('DATA', 'SOURCE') == "OPENS":
|
||||
|
||||
#Test Parse
|
||||
for plane in data['ac']:
|
||||
if plane['icao'] == "4074B8":
|
||||
while True:
|
||||
if main_config.get('DATA', 'SOURCE') == "ADSBX":
|
||||
response = requests.get(url, headers = headers)
|
||||
data = response.text
|
||||
data = json.loads(data)
|
||||
for plane in data['ac']:
|
||||
if plane['icao'] == "4074B8":
|
||||
print(plane)
|
||||
#print(json.dumps(data, indent=2))
|
||||
print("done")
|
||||
#Initate Each Plane Object from their configs
|
||||
import os
|
||||
for filename in os.listdir(os. getcwd()):
|
||||
if filename.endswith(".ini") and filename != "mainconf.ini":
|
||||
|
||||
|
||||
|
||||
plane_config = configparser.ConfigParser()
|
||||
plane_config.read(filename)
|
||||
print(filename)
|
||||
|
|
Loading…
Reference in New Issue