Skip to content

Instantly share code, notes, and snippets.

@Jxck-S
Created March 8, 2022 04:02
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jxck-S/e51fb6e52c929e4690ad6c8b1dcf803a to your computer and use it in GitHub Desktop.
Save Jxck-S/e51fb6e52c929e4690ad6c8b1dcf803a to your computer and use it in GitHub Desktop.
AAInflight Mini Status Program
import requests
import time
from geopy.distance import geodesic
last_coords = None
speed = None
time_btwn_change = 1
check_freq = 10
#https://server.ad.logic-prod.viasat.io/afr.php?zoneid=95&parameters=%7B%22origin%22:%22KMCO%22,%22destination%22:%22KDFW%22%7D&fid=N132AN-KMCO-KDFW-2022-03-05T01:56:12Z&fleetType=&isUSDomestic=true&guid=6f3003e9-9c27-11ec-927e-06df78a0305b&subtag=&source=https:%2F%2Fwww.aainflight.com%2F&origin=https:%2F%2Fwww.aainflight.com&li=0
#https://www.aainflight.com/iptv/channelList
#https://www.aainflight.com/iptv/programGuide/grid?channelId=12%2C13%2C14%2C15%2C16%2C17%2C19%2C24%2C26%2C27%2C34%2C35&startDateTime=20220305T0300Z&endDateTime=20220305T0700Z
while True:
for x in range(0, 100):
print("-", end="")
print("\n")
inflight_info = requests.get("https://www.aainflight.com/device?").json()
print(f"Flight Info for {inflight_info['flightNumber']}, Tail: {inflight_info['tailId']}")
print(f"Aircraft door: {inflight_info['doorState']}")
print(f"Inflight Entertainment Status:", inflight_info['ifeState'])
print(f"Route: {inflight_info['flightOrigin']} ---> {inflight_info['flightDestination']}")
print("Flight Time", int(inflight_info['flightMinutesRemaining']/60), "hour(s)", int(inflight_info['flightMinutesRemaining']%60), "minute(s) left")
print(f"Altitude: {int(inflight_info['altitude'])} ft, FL{int(inflight_info['altitude']/100)}")
coords = (inflight_info['latitude'], inflight_info['longitude'])
print(f"Coordinates: {coords}")
print(f"Heading: {inflight_info['heading']}")
if last_coords is not None:
distance_between_checks = float((geodesic(last_coords, coords).mi))
if distance_between_checks == 0 and speed is not None:
time_btwn_change += 15
print(f"No new coordinates so no new speed, last was {speed}")
else:
speed = (distance_between_checks / (check_freq* time_btwn_change)) *60 *60
time_btwn_change = 1
print(f"Latest speed check ~{speed}mph")
last_coords = coords
for x in range(0, 50):
print("-", end="")
print(f"\nDestination Info - {inflight_info['flightDestination']}")
print(f"Weather - {inflight_info['destinationConditions']}, {inflight_info['destinationTemperature']}F")
time.sleep(check_freq)
@upintheairsheep
Copy link

Did you do this out of boredom because you flew on the plane, and ran out of free wifi time, used a package capture program to reverse engineer the API, and make this script out of the JSON?

@Jxck-S
Copy link
Author

Jxck-S commented Jul 16, 2023

Did you do this out of boredom because you flew on the plane, and ran out of free wifi time, used a package capture program to reverse engineer the API, and make this script out of the JSON?

Yep pretty much lol. I also did it with Virgin Atlantic’s too recently, check my profile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment