[pkg]: music stats archive
Saves your music listening history to a GitHub Gist. Supports Last.fm (which aggregates plays from Spotify, Tidal, Deezer, and other services) and YouTube Music directly.
Before you start, you will need:
- A public GitHub Gist created at https://gist.github.com (copy the Gist ID from the URL)
- A GitHub personal access token from https://github.com/settings/personal-access-tokens/new with the Gists permission
- At least one provider:
- Last.fm API key from https://www.last.fm/api and your username
- YouTube Music cookie from your browser
Setup
Create a repository from the template at https://github.com/new?template_name=music-stats&template_owner=totallynotdavid.
Open the repository's Actions secrets settings at https://github.com/[username]/[repo]/settings/secrets/actions and add:
GIST_IDGITHUB_TOKENCODECOV_TOKEN(optional — required for private repos to upload coverage)- At least one provider:
LASTFM_API_KEYandLASTFM_USERNAMEYOUTUBE_COOKIE
The action runs on the schedule defined in .github/workflows/gist.yml. Edit
the cron expression to change the update frequency, or trigger it manually from
the Actions tab.
Optional configuration:
DAYS: number of days to fetch (default: 7)TOP_N: number of top tracks to show (default: 5)
Manual usage
Install the binary with cargo:
Set the required environment variables and run:
# optional if using YouTube
# optional if using YouTube
# optional if using Last.fm
Optional configuration:
# number of days to fetch (default: 7)
# number of top tracks to show (default: 5)
Publishing
This crate supports Trusted Publishing to crates.io using GitHub Actions (OIDC). The repository includes a release workflow that publishes tagged releases (e.g., v1.0.0) to crates.io — see .github/workflows/release.yml.
Note: the initial publish requires a crates.io API token (use cargo publish --token or set CARGO_REGISTRY_TOKEN as a secret); after configuring Trusted Publishing in your crate's settings, subsequent publishes can use the OIDC-based workflow.
Local development
On WSL, install the required system dependencies:
Clone the repository and build:
Copy .env.example to .env and fill in your credentials.
Run the development build with cargo run, or build a release binary with
cargo build --release.