Metadata-Version: 2.4
Name: polyhattrick
Version: 0.4.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: anyio (==4.12.0)
Requires-Dist: black (==25.12.0)
Requires-Dist: build (==1.3.0)
Requires-Dist: cachecontrol (==0.14.4)
Requires-Dist: certifi (==2025.11.12)
Requires-Dist: cffi (==2.0.0)
Requires-Dist: charset-normalizer (==3.4.4)
Requires-Dist: cleo (==2.1.0)
Requires-Dist: click (==8.3.1)
Requires-Dist: crashtest (==0.4.1)
Requires-Dist: cryptography (==46.0.3)
Requires-Dist: distlib (==0.4.0)
Requires-Dist: dulwich (==0.24.10)
Requires-Dist: fastjsonschema (==2.21.2)
Requires-Dist: filelock (==3.20.0)
Requires-Dist: findpython (==0.7.1)
Requires-Dist: h11 (==0.16.0)
Requires-Dist: httpcore (==1.0.9)
Requires-Dist: httpx (==0.28.1)
Requires-Dist: idna (==3.11)
Requires-Dist: installer (==0.7.0)
Requires-Dist: jaraco-classes (==3.4.0)
Requires-Dist: jaraco-context (==6.0.1)
Requires-Dist: jaraco-functools (==4.3.0)
Requires-Dist: jeepney (==0.9.0)
Requires-Dist: keyring (==25.7.0)
Requires-Dist: markdown-it-py (==4.0.0)
Requires-Dist: mdurl (==0.1.2)
Requires-Dist: more-itertools (==10.8.0)
Requires-Dist: msgpack (==1.1.2)
Requires-Dist: mypy-extensions (==1.1.0)
Requires-Dist: packaging (==25.0)
Requires-Dist: pathspec (==0.12.1)
Requires-Dist: pbs-installer (==2025.12.5)
Requires-Dist: pkginfo (==1.12.1.2)
Requires-Dist: platformdirs (==4.5.0)
Requires-Dist: poetry (==2.2.1)
Requires-Dist: poetry-core (==2.2.1)
Requires-Dist: pycparser (==2.23)
Requires-Dist: pygments (==2.19.2)
Requires-Dist: pyproject-hooks (==1.2.0)
Requires-Dist: pytokens (==0.3.0)
Requires-Dist: rapidfuzz (==3.14.3)
Requires-Dist: requests (==2.32.5)
Requires-Dist: requests-toolbelt (==1.0.0)
Requires-Dist: rich (==14.2.0)
Requires-Dist: secretstorage (==3.5.0)
Requires-Dist: shellingham (==1.5.4)
Requires-Dist: textual (>=8.2.8,<9.0.0)
Requires-Dist: tomlkit (==0.13.3)
Requires-Dist: trove-classifiers (==2025.12.1.14)
Requires-Dist: typer (==0.20.0)
Requires-Dist: typing-extensions (==4.15.0)
Requires-Dist: urllib3 (==2.5.0)
Requires-Dist: virtualenv (==20.35.4)
Requires-Dist: zstandard (==0.25.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
```

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`); `--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 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.

