211 lines
5.5 KiB
Markdown
211 lines
5.5 KiB
Markdown
# myice
|
||
|
||
## introduction
|
||
|
||
With this tool, you can fetch kids' schedules from MyIce and generate
|
||
the PDFs you need.
|
||
|
||
## install
|
||
|
||
with [uv](https://docs.astral.sh/uv/getting-started/installation/):
|
||
|
||
```shell
|
||
uv tool install --extra-index-url https://gitea.parano.ch/api/packages/herel/pypi/simple/ myice
|
||
```
|
||
|
||
with [pipx](https://pipx.pypa.io/stable/installation/):
|
||
|
||
```shell
|
||
pipx install --extra-index-url https://gitea.parano.ch/api/packages/herel/pypi/simple/ myice
|
||
```
|
||
|
||
## configuration
|
||
|
||
Create a `myice.ini` file with your credentials:
|
||
|
||
```ini
|
||
[default]
|
||
username = your_email@example.com
|
||
password = your_password
|
||
userid = 12345
|
||
token = your_api_token
|
||
club_id = 172
|
||
```
|
||
|
||
You can also create multiple sections for different users:
|
||
|
||
```ini
|
||
[default]
|
||
username = user1@example.com
|
||
password = password1
|
||
userid = 12345
|
||
token = token1
|
||
club_id = 172
|
||
|
||
[second_kid]
|
||
username = charlie@example.com
|
||
password = password2
|
||
userid = 67890
|
||
token = token2
|
||
club_id = 186
|
||
```
|
||
|
||
Note: The `userid`, `token`, and `club_id` fields are optional. If you don't
|
||
have them, the tool can fetch them automatically using the mobile-login
|
||
command (see below).
|
||
|
||
To fetch the `token` and `club_id` using mobile-login:
|
||
|
||
```shell
|
||
myice mobile-login
|
||
```
|
||
|
||
This will output the necessary information that you can add to your `myice.ini` file.
|
||
|
||
## web interface
|
||
|
||
The tool includes a web interface that can be accessed by running the web API server:
|
||
|
||
```shell
|
||
uv run fastapi run myice/webapi.py
|
||
```
|
||
|
||
Then open your browser at `http://localhost:8000`. The web interface allows you to:
|
||
|
||
- Select between different configured accounts
|
||
- View upcoming games and practices
|
||
- See detailed information about events including player rosters
|
||
|
||
### Authentication
|
||
|
||
The web interface supports two authentication methods:
|
||
|
||
1. **Infomaniak OpenID Connect (Recommended)**: Click the "Se connecter avec Infomaniak" button to authenticate using Infomaniak's OIDC provider. Only users in the allowed list will be granted access.
|
||
|
||
2. **Static API Key**: For development purposes, you can still use `abc` as the token.
|
||
|
||
### Environment Variables
|
||
|
||
To configure OIDC authentication, set the following environment variables:
|
||
|
||
- `CLIENT_ID`: Your OIDC client ID (default: 8ea04fbb-4237-4b1d-a895-0b3575a3af3f)
|
||
- `CLIENT_SECRET`: Your OIDC client secret
|
||
- `REDIRECT_URI`: The redirect URI (default: http://localhost:8000/callback)
|
||
- `ALLOWED_USERS`: Comma-separated list of allowed email addresses (e.g., "user1@example.com,user2@example.com")
|
||
|
||
The web API provides the following endpoints:
|
||
|
||
- `/schedule` - Get the schedule for a specific account
|
||
- `/game/{game_id}` - Get details for a specific game
|
||
- `/accounts` - Get a list of available accounts
|
||
- `/health` - Health check endpoint
|
||
- `/login` - Initiate OIDC login flow
|
||
- `/callback` - Handle OIDC callback
|
||
- `/userinfo` - Get user information
|
||
|
||
All endpoints (except `/health`, `/login`, and `/callback`) require an Authorization header with a Bearer token.
|
||
|
||
## mobile functions
|
||
|
||
The tool includes several mobile API functions that interact with MyIce's
|
||
mobile API:
|
||
|
||
- `myice mobile-login` - Authenticate and get authentication tokens
|
||
- `myice mobile` - Fetch game data using the mobile API
|
||
- `myice mobile-game {game_id}` - Get detailed information about a specific game
|
||
|
||
These functions can be useful for debugging or when the regular web
|
||
interface is not available.
|
||
|
||
## fetch schedule
|
||
|
||
```shell
|
||
myice schedule -o schedule.json
|
||
```
|
||
|
||
To use a specific configuration section:
|
||
|
||
```shell
|
||
myice schedule -o schedule.json --config-section isaac
|
||
```
|
||
|
||
## data
|
||
|
||
### listing
|
||
|
||
To fetch events for U13 Elite for example:
|
||
|
||
```shell
|
||
❯ myice search "U13 (Elite)"
|
||
[576653] 2024-11-04 practice 17:00-> 17:00
|
||
practice: Off-Ice Patinoire des Vernets - Patinoire Extérieure
|
||
|
||
[572066] 2024-11-04 practice 18:00-> 18:00
|
||
practice: On-Ice Patinoire des Vernets - Patinoire Extérieure
|
||
|
||
[576652] 2024-11-05 practice 18:00-> 18:00
|
||
practice: Off-Ice Patinoire des Vernets - Patinoire Extérieure
|
||
|
||
[572068] 2024-11-05 practice 19:15-> 19:15
|
||
practice: On-Ice Patinoire des Vernets - Patinoire Extérieure
|
||
|
||
[576655] 2024-11-08 practice 18:00-> 18:00
|
||
practice: Off-Ice Patinoire des Vernets - Patinoire Extérieure
|
||
|
||
[572073] 2024-11-08 practice 19:15-> 19:15
|
||
practice: On-Ice Patinoire des Vernets - Patinoire Extérieure
|
||
|
||
[117015] 2024-11-02 game 12:15-> 12:15
|
||
game: Saison HC Ajoie
|
||
```
|
||
|
||
And we retrieve the match roster:
|
||
|
||
### match
|
||
|
||
To get the roster for the match against Ajoie, the ID is 117015:
|
||
|
||
```shell
|
||
❯ myice game 117015
|
||
Opening file game_117015.pdf
|
||
|
||
```
|
||
|
||
To use a specific configuration section:
|
||
|
||
```shell
|
||
❯ myice game 117015 --config-section isaac
|
||
```
|
||
|
||
### practice
|
||
|
||
And for a practice roster:
|
||
|
||
```shell
|
||
❯ myice practice 561855
|
||
Opening file practice_561855.pdf
|
||
|
||
```
|
||
|
||
To use a specific configuration section:
|
||
|
||
```shell
|
||
❯ myice practice 561855 --config-section isaac
|
||
```
|
||
|
||
### AI
|
||
|
||
```text
|
||
❯ myice ai
|
||
> prochain match u13 top ?
|
||
< Le prochain match de l'équipe U13 Top se déroulera le dimanche 10 novembre 2024 contre HC Ajoie à la Raffeisen Arena de Porrentruy. Le match débutera à 14h00 et se terminera à 16h15.
|
||
> et les u13 a ?
|
||
< Le prochain match de l'équipe U13 A se déroulera le samedi 9 novembre 2024 contre HC Vallorbe à P. du Frézillon, 1337 Vallorbe VD. Le match débutera à 13h00 et se terminera à 15h00. Le prochain match à domicile de l'équipe U13 A se déroulera le dimanche 10 novembre 2024 contre CP Meyrin à Les Vernets, Glace extérieure, 1227 Les Acacias GE. Le match débutera à 13h00 et se terminera à 15h00.
|
||
```
|
||
|
||
To use a specific configuration section:
|
||
|
||
```shell
|
||
❯ myice ai --config-section isaac
|
||
```
|