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
  • ๐Ÿ“… 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

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

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
...

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 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,schedule,predict,top,download,skill} ...

Basketball league analysis tools

positional arguments:
  {standings,team,schedule,predict,top,download,skill}
    standings           Display league standings
    team                Display results for a team
    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., 'TV 1877 Lauf')

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)
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]

options:
  -h, --help  show this help message and exit

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
โ”‚   โ”œโ”€โ”€ 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.5.tar.gz (35.4 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.5-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: korb-0.2.5.tar.gz
  • Upload date:
  • Size: 35.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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.5.tar.gz
Algorithm Hash digest
SHA256 527dc794b6f52485fb7e093ac3734490881175383352fa0b0fa5c31d893a5c64
MD5 7a0ca254dc00b5f7af0aaf085ec89604
BLAKE2b-256 fe1f68d3463651b0424cfb13fcfea37f675b033bcdad6c1b480af91969ce78ba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: korb-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 29.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5d3ea77740ee9bf7a08d52b00a3f8b4aebc370f272b114c3e71d9bb463586dfd
MD5 c9402558d6b4102475ecf34d9968d0b5
BLAKE2b-256 c7cea7b195af2c7d139d572ab42d1ec544f773c44c16959717a09b33d8613cf4

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