Metadata-Version: 2.4
Name: polyhattrick
Version: 0.5.0
Summary: Live Hattrick scores in your terminal and polybar
License-Expression: MIT
License-File: LICENSE
Author: Peter Toth
Author-email: work@petertoth.de
Requires-Python: >=3.12,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Requires-Dist: requests (>=2.32.5,<3.0.0)
Requires-Dist: rich (>=14.2.0,<15.0.0)
Requires-Dist: textual (>=8.2.8,<9.0.0)
Requires-Dist: typer (>=0.20.0,<0.21.0)
Description-Content-Type: text/markdown

# polyhattrick

Your [Hattrick](https://www.hattrick.org) club in the terminal: team, league
table, squad, players, training, staff and matches, as tables, as JSON for
scripts, or in a full-screen interface. It also puts your live match score in
`polybar`.

polyhattrick only reads your data; it cannot change anything in your club.

---

## Installation

```bash
pip install polyhattrick
```

## Logging in

```bash
polyhattrick login start
```

Open the page it prints, allow polyhattrick to read your data, and copy the
PIN Hattrick shows you. Then:

```bash
polyhattrick login finish PIN
```

The login stays valid until you revoke it on Hattrick. `polyhattrick logout`
removes it from this machine.

## Commands

```bash
polyhattrick team list                # your teams
polyhattrick team show                # league, series, cup, power rating
polyhattrick series show              # your series table, with promotion and relegation places
polyhattrick series fixtures          # every match of your series this season (--season -1, --round N)
polyhattrick players list             # the squad with skills
polyhattrick player show PLAYER_ID    # one player in full
polyhattrick training show            # this week's and last week's training
polyhattrick club show                # staff levels and youth academy
polyhattrick matches list             # recent and upcoming matches
polyhattrick matches history          # every match of this season (--season -1 for the last one, --type league)
polyhattrick match show MATCH_ID      # ratings, key moments and both lineups (--events, --no-lineups, --team ID)
polyhattrick challenges list          # friendly challenges made and received
polyhattrick cups list                # your league's cups and the round each has reached
polyhattrick cup show                 # your cup round, starting at your match (CUP_ID, --round, --after for the next page)
polyhattrick browse                   # the full-screen interface
```

### Youth

```bash
polyhattrick youth team show          # your youth team, its series and its scouts
polyhattrick youth players list       # the youth squad: skills as current/maximum, promotion, last match
polyhattrick youth player show ID     # one youth player: skills, scout report, last match
polyhattrick youth series show        # your youth series table
polyhattrick youth series fixtures    # every match of the youth series (--season -1, --round N)
polyhattrick youth matches list       # recent and upcoming youth matches
polyhattrick youth matches history    # played youth matches Hattrick still keeps (about three months)
```

They use your primary club's youth team; `--team TEAM_ID` picks another of
your senior teams, `--youth-team ID` any youth team (another club's shows no
skills or scout reports). In the skill columns yellow means fully trained,
green means the maximum is shown but there are still sub-levels to gain.

Commands about a team use your primary club; pass `--team TEAM_ID` for
another one (`polyhattrick team list` shows the identifiers). The match
lists show each match's identifier for `match show`. Tournament and ladder
matches have their own numbering, so their identifiers carry a prefix
(`hto-41870715`), and so do youth matches (`youth-145407283`); `--json`
output has the plain number with `"source_system"` instead.

### In scripts

Every read command takes `--json` and then prints the server's response
unchanged on stdout. Errors go to stderr, and the exit code tells what went
wrong: `0` success, `1` something to fix on your side (not logged in, wrong
identifier, not your team), `2` the server or Hattrick failed.

```bash
polyhattrick players list --json | jq '.[] | {name: .last_name, playmaking: .skills.playmaking}'
```

### The full-screen interface

`polyhattrick browse` shows the same sections on one screen. Arrow keys
move, enter on a section moves into it, enter on a player (senior or youth) or a
played match opens it, escape goes back, `r` refreshes, `t`
switches to your next team, `q` quits.

## Integration with polybar

```bash
polyhattrick match live watch
```

prints the first match on your Hattrick live ticker as one line, and nothing
at all if something fails, so the bar never fills with error text. Add it as
a module:

```
[module/hattrick]
type = custom/script
exec = polyhattrick match live watch
```

To show a different match, reorder your live ticker on the Hattrick website.

## Configuration

Optional, in `~/.config/polyhattrick/configuration.toml`:

```toml
server = "https://api.polyhattrick.sesamemonster.de"   # the polyhattrick server to use
```

`POLYHATTRICK_SERVER` overrides `server` for a single run.

## Notes

- Made for Linux.
- The `polyhattrick login authenticate` and `login exchange` commands from
  version 0.1.0 still work.

