Skip to main content

A CLI toolkit for DBB basketball league analysis

Project description

๐Ÿ€ korb
A CLI toolkit for DBB basketball league analysis

Python 3.10+ uv Zero dependencies DBB JSP


What is this?

A zero-dependency Python CLI that parses HTML from the DBB (Deutscher Basketball Bund) legacy JSP platform and gives you:

  • ๐Ÿ“Š Standings โ€” full league table with points, differentials, averages
  • ๐Ÿ€ Team drill-down โ€” game-by-game results, sparklines, quality metrics
  • ๐Ÿ“‹ Ergebnisse โ€” all completed game results with score differentials, optional team filter
  • ๐Ÿ“… Schedule โ€” with back-to-back detection, filtering, pending games
  • ๐Ÿ”ฎ Predictions โ€” efficiency-model-based final standings forecast
  • ๐Ÿฅ‡ Top N โ€” quick leaderboard with ASCII bar chart
  • ๐Ÿ“ฅ Download โ€” fetch fresh HTML data directly from basketball-bund.net
  • ๐Ÿค– Skills โ€” built-in AI skill prompts for team analysis & league prediction
  • ๐Ÿ”ง JSON output โ€” pipe-friendly --json flag for all commands

Finding your Liga ID

The --ligaid value comes from the liga_id parameter in the DBB league URL:

https://www.basketball-bund.net/index.jsp?Action=103&liga_id=51187
                                                           ^^^^^
                                                           this is your liga ID

Copy the number after liga_id= and pass it to --ligaid.


Quick Start

# Install with uv
uv sync

# Download league data
uv run korb --ligaid 51187 download

# View standings
uv run korb --ligaid 51187 standings

# Download fresh data + predict in one go
uv run korb --ligaid 51187 --download predict

Installation

# Clone and install
git clone https://github.com/malvavisc0/korb && cd korb
uv sync

# Install with dev tools (black, isort)
uv sync --group dev

After uv sync, the korb CLI is available inside the virtual environment. Use uv run korb to invoke it, or activate the venv with source .venv/bin/activate and run korb directly.


Commands

download โ€” Fetch HTML data

# Download results + schedule for a league
uv run korb --ligaid 12345 download

# Refresh all previously downloaded leagues at once
uv run korb download --all

Saves ergebnisse.html and spielplan.html into files/<ligaid>/.

The --all / -a flag scans the files/ directory for all previously downloaded league IDs and re-downloads each one. Useful for bulk-refreshing data across multiple leagues.

standings โ€” League table

uv run korb --ligaid 12345 standings
 #  Team                GP   W   L   D     PF    PA   Diff  Pts   Avg PF  Avg PA
----------------------------------------------------------------------------------
 1  Thunder Academy     12   9   3   0   1248   847   +401   18    104.0    70.6
 2  Riverside Hawks     11   9   2   0    952   668   +284   18     86.5    60.7
 3  Metro Wolves        11   8   3   0    813   694   +119   16     73.9    63.1
...

ergebnisse โ€” All game results

# All completed results
uv run korb --ligaid 12345 ergebnisse

# Filter by team (partial, case-insensitive)
uv run korb --ligaid 12345 ergebnisse --team "Hawks"

# JSON output
uv run korb --json --ligaid 12345 ergebnisse
======================================================================
  Ergebnisse โ€” MFR U12 mix Bezirksliga Nord
======================================================================

   Datum            Heim              Gast              Ergebnis    Diff
-----------------------------------------------------------------------
1  15.01.26 10:00   Team Alpha        Team Beta           79:75      +4
2  15.01.26 12:00   Team Gamma        Team Delta          60:60       0
3  22.01.26 15:00   Team Beta         Team Alpha          82:70     +12

team โ€” Deep dive on a single team

# Basic results
uv run korb --ligaid 12345 team "Thunder"

# With bar chart + quality metrics for last 5 games
uv run korb --ligaid 12345 team "Thunder" --bars --last-k 5 --metrics

schedule โ€” Game calendar

# All upcoming games
uv run korb --ligaid 12345 schedule --pending

# Filter by team + mark back-to-back โšก fixtures
uv run korb --ligaid 12345 schedule --team "Hawks" --pending --b2b

# Include cancelled games
uv run korb --ligaid 12345 schedule --all

predict โ€” Forecast final standings

uv run korb --ligaid 12345 predict

Uses a multiplicative efficiency model with recency weighting, recent form blending, home advantage, and back-to-back fatigue modelling.

top โ€” Quick leaderboard

uv run korb --ligaid 12345 top -n 5

skill โ€” Print AI skill prompts

# List available skills
uv run korb skill --list

# Print a specific skill prompt
uv run korb skill analysis
uv run korb skill prediction

Ships two built-in skills: analysis (team deep-dive) and prediction (league top-N forecast).

--download โ€” Fetch fresh data before any command

# Download + show standings in one step
uv run korb --ligaid 12345 --download standings

# Download + predict
uv run korb --ligaid 12345 -d predict

--json โ€” Machine-readable output

Add --json before any subcommand to get JSON instead of tables:

uv run korb --json --ligaid 12345 standings
uv run korb --json --ligaid 12345 team "Hawks"
uv run korb --json --ligaid 12345 ergebnisse
uv run korb --json --ligaid 12345 ergebnisse --team "Hawks"
uv run korb --json --ligaid 12345 schedule --pending
uv run korb --json --ligaid 12345 predict
uv run korb --json --ligaid 12345 top -n 3

CLI Reference

$ uv run korb --help

usage: korb [-h] [--version] [--results RESULTS] [--schedule SCHEDULE]
            [--json] [--ligaid LIGAID] [--download]
            {standings,team,ergebnisse,schedule,predict,top,download,skill} ...

Basketball league analysis tools

positional arguments:
  {standings,team,ergebnisse,schedule,predict,top,download,skill}
    standings           Display league standings
    team                Display results for a team
    ergebnisse          Display game results
    schedule            Display game schedule
    predict             Predict final standings
    top                 Show top teams from standings
    download            Download results & schedule HTML
    skill               Print a skill prompt or list available skills

options:
  -h, --help            show this help message and exit
  --version, -V         show program's version number and exit
  --results, -r RESULTS HTML results file path
  --schedule, -s SCHEDULE
                        HTML schedule file path
  --json                Output as JSON instead of formatted tables
  --ligaid, -l LIGAID  Liga ID (e.g. 51491)
  --download, -d        Download latest data before running the command
standings --help
usage: korb standings [-h]

options:
  -h, --help  show this help message and exit
team --help
usage: korb team [-h] [--bars] [--last-k LAST_K] [--metrics] name

positional arguments:
  name             Team name (e.g., 'Hawks')

options:
  -h, --help       show this help message and exit
  --bars, -b       Show point differential bar chart
  --last-k LAST_K  Analyze only the most recent K games
  --metrics        Show win-rate + margin quality metrics
schedule --help
usage: korb schedule [-h] [--all] [--pending] [--team TEAM] [--b2b]

options:
  -h, --help       show this help message and exit
  --all, -a        Show cancelled games
  --pending, -p    Show only pending games
  --team, -t TEAM  Filter by team name (partial match)
  --b2b            Mark back-to-back fixtures (โ‰ค36h)
ergebnisse --help
usage: korb ergebnisse [-h] [--team TEAM]

options:
  -h, --help       show this help message and exit
  --team, -t TEAM  Filter by team name (partial match)
predict --help
usage: korb predict [-h]

options:
  -h, --help  show this help message and exit
top --help
usage: korb top [-h] [-n N]

options:
  -h, --help  show this help message and exit
  -n N        How many teams to show (default: 3)
download --help
usage: korb download [-h] [--all]

options:
  -h, --help  show this help message and exit
  --all, -a   Refresh all previously downloaded leagues

How Predictions Work

The predict command estimates final standings using a multiplicative efficiency model:

Factor How it works
Offensive rating Team's scored points vs. league average (>1.0 = above avg)
Defensive rating Points allowed vs. league average (>1.0 = worse defense)
Recency weighting 60-day half-life โ€” recent games count more
Recent form Last 5 games blended at 30% weight into ratings
Home advantage 3% scoring boost applied symmetrically
B2B fatigue โ‰ค36h between games โ†’ 5% offense/defense penalty
New teams <3 games โ†’ ratings blended toward league average
No draws Ties broken by home advantage (basketball has OT)
No double-counting Already-played games excluded from schedule scan

๐Ÿง  Skills

The skills/ directory contains reusable AI skill definitions โ€” structured prompts that can be loaded by an AI assistant (e.g. Roo/Cline) to run analysis workflows using the CLI.

Skill Output Description
SKILL_TEAM_ANALYSIS.md Paragraph Short team summary (position, identity, form, outlook) โ€” ready for a webpage card
SKILL_LEAGUE_TOP_N_ANALYSIS.md Table + paragraph Predicted final standings table with a brief explanation

Both skills accept a LANGUAGE parameter (en/de/es) and return output directly (no file saved). To use a skill, point your AI assistant at the markdown file or load it as a skill definition.


Project Structure

โ”œโ”€โ”€ korb/
โ”‚   โ”œโ”€โ”€ __init__.py      # Package marker
โ”‚   โ”œโ”€โ”€ __main__.py      # CLI entry point & download command
โ”‚   โ”œโ”€โ”€ core.py          # Shared models, HTML parsing, utilities
โ”‚   โ”œโ”€โ”€ ergebnisse.py    # Game results viewer & filter
โ”‚   โ”œโ”€โ”€ predict.py       # Multiplicative efficiency prediction model
โ”‚   โ”œโ”€โ”€ schedule.py      # HTML schedule parser & filters
โ”‚   โ”œโ”€โ”€ standings.py     # Standings calculator
โ”‚   โ””โ”€โ”€ team.py          # Team results viewer & metrics
โ”œโ”€โ”€ skills/              # AI skill definitions for automated analysis
โ”œโ”€โ”€ files/               # Downloaded HTML data (git-ignored)
โ”œโ”€โ”€ tests/               # Tests
โ”œโ”€โ”€ pyproject.toml       # Project metadata & uv config
โ””โ”€โ”€ README.md

Requirements: Python 3.10+ ยท uv ยท No runtime dependencies

Note: Downloaded HTML files and --ligaid paths resolve relative to your current working directory (files/<ligaid>/). Run korb from the project root or pass explicit --results / --schedule paths.

Dev tools

# Format code
uv run black korb/

# Sort imports
uv run isort korb/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

korb-0.2.7.tar.gz (37.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

korb-0.2.7-py3-none-any.whl (31.3 kB view details)

Uploaded Python 3

File details

Details for the file korb-0.2.7.tar.gz.

File metadata

  • Download URL: korb-0.2.7.tar.gz
  • Upload date:
  • Size: 37.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.10 {"installer":{"name":"uv","version":"0.11.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for korb-0.2.7.tar.gz
Algorithm Hash digest
SHA256 fae4a37a2488b5d42dcb07a8be60d46097b92c0319fcbe6691b266881f0257eb
MD5 6342006398d8b725031ce662e29d7e03
BLAKE2b-256 92d2dd8b2adcef4c9516c3f52b9988403d4f68f3c08fb53e6e5f9ffab4a9bb57

See more details on using hashes here.

File details

Details for the file korb-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: korb-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 31.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.10 {"installer":{"name":"uv","version":"0.11.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for korb-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 72a5792dda1e8add27eb229d63038c4c83e80a22b5b7a1bf4c1a5e086a264cca
MD5 7f8e870615410aca22e6d7abce05c628
BLAKE2b-256 1bb6e77773f2f9920e82d4e8e7a81a44583d1f1c503f24423857f9af0140b353

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page