Metadata-Version: 2.4
Name: skywatch-mp
Version: 1.0.0
Summary: Live, free, global flight tracker for the terminal (no API key required)
Author: SkyWatch contributors
License: Public-domain data; MIT-style source
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: rich<16,>=13.0
Requires-Dist: requests<3,>=2.28
Provides-Extra: timezonefinder
Requires-Dist: timezonefinder>=6; extra == "timezonefinder"
Provides-Extra: test
Requires-Dist: pytest>=7; extra == "test"

# SkyWatch

A live, free, full-screen flight tracker for the terminal. It shows aircraft
worldwide, dead-reckons between global snapshots, overlays a live regional
feed, resolves routes/aircraft metadata, and displays local time for every
country. **No API key, account or payment is ever required.**

```
./run.sh                         # interactive TUI
python3 -m skywatch_mp --demo       # offline animated demo fleet
python3 -m skywatch_mp --demo --demo-seed 42   # a specific alternate fleet
python3 -m skywatch_mp --once --query 'alt>35000 country:DE'
python3 -m skywatch_mp --export flights.csv --query 'mil or squawk:7700'
python3 -m skywatch_mp --screenshot map.svg --view map --demo
```

## Requirements

Python 3.10+, `rich`, `requests`. Optional: `timezonefinder` for more precise
oceanic timezone lookup.

```bash
pip install skywatch-mp       # PyPI distribution name (once published)
pip install .                 # install from this checkout
pip install -e .              # editable development install
skywatch --demo --once        # console script installed by pip
skywatch-mp --demo --once     # same app, distribution-name alias
swmp --demo --once            # short alias
```

`./run.sh` is also provided: it creates a local virtualenv on first run and
installs `requirements.txt` into it. For development, `pip install -e '.[test]'`
adds pytest; `pip install '.[timezonefinder]'` adds the optional timezone
lookup.

## Data sources

| Purpose | Source | Cost |
|---|---|---|
| Global snapshot (every aircraft) | OpenSky Network anonymous `/states/all` | free, rate-limited per IP |
| Live regional overlay | adsb.lol `/v2/point/{lat}/{lon}/{radius}` | free, no key |
| Route & aircraft metadata | adsbdb.com `/v0/callsign`, `/v0/aircraft` | free, cached locally |
| Maps, countries, airports, airlines, timezones | bundled Natural Earth, mledoze, ISO 3166, IANA tzdb, OpenFlights data | public domain / ODbL |

Optional **free** OpenSky credentials raise the daily budget from 400 to
4,000 credits (a global snapshot costs 4 credits). Create a client on your
OpenSky account page, then either set environment variables:

```bash
export OPENSKY_CLIENT_ID=your_client_id
export OPENSKY_CLIENT_SECRET=your_client_secret
skywatch
```

or pass them per run with the new options:

```bash
skywatch --api-key CLIENT_ID:CLIENT_SECRET
skywatch --opensky-id CLIENT_ID --opensky-secret CLIENT_SECRET
skywatch --credentials /path/to/credentials.json
skywatch --credentials /path/to/credentials.json --persist-credentials
```

The JSON file can use any of these shapes:

```json
{"client_id": "...", "client_secret": "..."}
```

```json
{"api_key": "CLIENT_ID:CLIENT_SECRET"}
```

Camel-case keys `clientId`/`clientSecret` (as in the example in `BDCS/`), plus
`open_sky_id`/`open_sky_secret`, `id`/`secret` and a nested
`"opensky": {...}` object, are also accepted. With `--persist-credentials`,
the path is remembered in `~/.config/skywatch-mp/config.json` and reloaded on
every start; without it, credentials are used for that run only and are
**never written to disk**. You can also set them inside the TUI with
`:credentials /path/to/credentials.json` (saved) or clear them with
`:credentials clear`.

The API uses two values (client ID + secret), not a single key; `--api-key`
is just a shortcut for `ID:SECRET`. Tokens expire after 30 minutes and are
refreshed automatically. The app works fully without them. All responses are cached in
`~/.cache/skywatch-mp/cache.json`; if a service is unavailable the last snapshot
is kept, positions are dead-reckoned, and cached metadata is reused.

## Views

Keys `1`–`9` and `0`, `Tab`/`Shift-Tab`, or `:view <name>`:

1. Dashboard — KPIs, world map, world clock, alerts, altitude/country bars
2. Flights — sortable, paged flight table
3. World map — braille/ASCII map with altitude colours, trails, day/night
4. Globe — orthographic projection with rotation and auto-spin
5. World clock — local time, date, UTC offset and DST for every country
6. Routes — busiest city pairs, airlines and pending lookups
7. Statistics — altitude/speed/heading distributions, trends, data health
8. Alerts — emergencies, military, stale/ground anomalies
9. Details — identity, position, local time, flight data, route, track
0. Search — presets, saved searches and quick result browsing
`?` help.

## Controls

| Key | Action |
|---|---|
| `/` | edit search query (`Ctrl-S` saves it) |
| `1`–`0`, `Tab` | switch view |
| `↑↓←→`, `PgUp/PgDn`, `Home/End` | navigate rows/pages, pan map, rotate globe |
| `Enter` | open flight details / expand country / apply preset |
| `s`, `S` | cycle sort / choose sort field |
| `+ - 0` | zoom in / out / reset |
| `f`, `b`, `n`, `v`, `y` | follow, grid, labels, trails, day/night |
| `r`, `p`/`Space` | refresh now / pause live updates |
| `R` | reshuffle the demo fleet (demo mode only; `:reshuffle [seed]`) |
| `u`, `T` | cycle units / theme |
| `o`, `i` | look up route / aircraft metadata |
| `e` | export prompt |
| `:` | command prompt (`:help`, `:goto`, `:zoom`, `:export`, `:filter`, …) |
| `q`, `Ctrl-C` | quit |

## Search language

Free text matches callsign, registration, type, owner, airline, country, hex
and route. Combine with `and`, `or`, `not`, parentheses and a leading `-`.
Examples:

```
emirates alt>30000 country:Germany
mil or squawk:7700
alt:30000..40000 speed>400 country:DE,FR -ground:true
route:EDDF-KJFK callsign:UAL* ~"787" sort:-speed limit:250
near:51.47,-0.45,250 localtime:08:00-12:00 has:route
```

Fields: `callsign`, `reg`, `type`, `airline`, `owner`, `country`, `regcountry`,
`hex`, `squawk`, `route`, `origin`, `destination`, `alt`, `speed`, `vs`,
`heading`, `lat`, `lon`, `dist`, `age`, `flightlevel`, `localtime`, `hour`,
`sun`, `mil`, `emergency`, `ground`, `stale`, `spi`, `has`, `source`, `zone`.
Numeric fields accept `>`, `>=`, `<`, `<=`, `=`, `!=` and `..` ranges;
string fields accept `:`/`=`, `!=`, `*` wildcards and `~` regex. `sort:` and
`limit:` may appear anywhere. Press `?` for the full in-app syntax help.

## Exports and static output

`e` in the app, `--export PATH`, or `:export PATH` support
`csv`, `json`, `geojson`, `md`, `kml`. Exports contain the full record set
(local time, timezone, route, sun data, source flags), not just visible rows.
`--once` prints one static render; `--screenshot FILE.{svg,txt,html}` records
one screen. `--width/--height` control static output size.

## Configuration

Settings live in `~/.config/skywatch-mp/config.json` and are editable in-app
(theme, units, page size, refresh intervals, home location, saved searches).
Theme names: `aurora`, `amber`, `matrix`, `ice`, `sunset`, `mono`.
`--no-color`, `--ascii`, `--no-live`, `--source`, `--bbox`, `--interval` and
`--live-interval` override settings for a single run.

## Development

```
python3 -m pytest                          # unit tests
python3 tools/build_data.py                # rebuild bundled geodata
python3 -m skywatch_mp --demo --once --view search
```

The demo fleet is deterministic (`--demo`), so every view and export can be
tested offline. Data build cache is kept in `.build-cache/`.
