# ruff: noqa
# mypy: disable-error-code="top-level-await, no-redef"
# %%
# --8<-- [start:script0]
import httpx
from fr24.grpc import PlaybackFlightParams, playback_flight
from fr24.proto.v1_pb2 import PlaybackFlightResponse
from fr24.proto import parse_data
from fr24.proto.headers import get_grpc_headers


async def playback_flight_data() -> PlaybackFlightResponse:
    headers = httpx.Headers(get_grpc_headers(auth=None))
    async with httpx.AsyncClient() as client:
        message = PlaybackFlightParams(
            flight_id=0x3C500FDB, timestamp=1758467125
        )
        response = await playback_flight(client, message, headers)
        return parse_data(response.content, PlaybackFlightResponse).unwrap()


data = await playback_flight_data()
data
# --8<-- [end:script0]
# %%
"""
# --8<-- [start:output0]
aircraft_info {
  icao_address: 7866977
  reg: "B-KQM"
  type: "B77W"
  icon: B777
  full_description: "Boeing 777-367(ER)"
  images_list {
    url: "https://www.jetphotos.com/photo/11825817"
    copyright: "ZSHC_Linzx"
    thumbnail: "https://cdn.jetphotos.com/200/5/1291679_1756473618_tb.jpg"
    medium: "https://cdn.jetphotos.com/400/5/1291679_1756473618.jpg"
    large: "https://cdn.jetphotos.com/640/5/1291679_1756473618.jpg"
  }
  images_list {
    url: "https://www.jetphotos.com/photo/11813969"
    copyright: "CAN-Eric"
    thumbnail: "https://cdn.jetphotos.com/200/5/967682_1755532162_tb.jpg"
    medium: "https://cdn.jetphotos.com/400/5/967682_1755532162.jpg"
    large: "https://cdn.jetphotos.com/640/5/967682_1755532162.jpg"
  }
  images_list {
    url: "https://www.jetphotos.com/photo/11803561"
    copyright: "cc12214"
    thumbnail: "https://cdn.jetphotos.com/200/6/585221_1754572527_tb.jpg"
    medium: "https://cdn.jetphotos.com/400/6/585221_1754572527.jpg"
    large: "https://cdn.jetphotos.com/640/6/585221_1754572527.jpg"
  }
  msn_available: true
  age_available: true
  registered_owners: "Cathay Pacific (Oneworld Livery)"
  is_country_of_reg_available: true
}
schedule_info {
  flight_number: "CX251"
  operated_by_id: 57
  painted_as_id: 57
  origin_id: 1366
  destination_id: 1942
  scheduled_departure: 1758465600
  scheduled_arrival: 1758516000
  actual_departure: 1758466901
  arr_terminal: "3"
}
flight_info {
  flightid: 1011879899
  lat: 22.2923298
  lon: 114.087372
  track: 173
  alt: 6325
  speed: 242
  timestamp_ms: 1758467118710
  callsign: "CPA251"
  ems_availability {
    qnh_availability: true
    amcp_availability: true
    oat_availability: true
    ias_availability: true
    tas_availability: true
    mach_availability: true
    agps_availability: true
    agpsdiff_availability: true
    wind_dir_availability: true
    wind_speed_availability: true
    rs_availability: true
  }
  squawk_availability: true
  vspeed_availability: true
  airspace_availability: true
  server_time_ms: 1758467148386
}
flight_trail_list {
  snapshot_id: 1758465991
  lat: 22.3132782
  lon: 113.934616
  heading: 70
}
...
flight_trail_list {
  snapshot_id: 1758467147
  lat: 22.2578888
  lon: 114.087273
  altitude: 6800
  spd: 267
  heading: 180
}
"""
