Skip to main content

A CLI for calculating YouTube playlist runtime statistics.

Project description

ytruntime

CI PyPI Version Python Versions

TL;DR

uv tool install git+https://github.com/Adityagaddhyan/ytruntime.git
ytruntime stats "https://www.youtube.com/playlist?list=PLAYLIST_ID"

ytruntime is a polished Python CLI for calculating YouTube playlist runtimes. It prints total videos, total runtime, average runtime, and a per-video duration table. It uses yt-dlp for metadata extraction and rich for terminal output.

Why ytruntime?

  • Quickly estimate how long a course, lecture series, or watchlist will take.
  • Select a playlist range with --start and --end.
  • Skip unavailable/private videos gracefully.
  • Export JSON or CSV reports for notes, scripts, and dashboards.
  • Install as a real global CLI with uv tool, pipx, or PyPI.

Installation

Method Command Status
uv tool from GitHub uv tool install git+https://github.com/Adityagaddhyan/ytruntime.git Works now
pipx from GitHub pipx install git+https://github.com/Adityagaddhyan/ytruntime.git Works now
uv tool from PyPI uv tool install ytruntime After PyPI release
pipx from PyPI pipx install ytruntime After PyPI release
pip from PyPI pip install ytruntime After PyPI release
Homebrew brew install ytruntime Planned

Requires Python 3.11+.

If uv tool install succeeds but ytruntime is not found, add uv's tool directory to your shell:

export PATH="$HOME/.local/bin:$PATH"

Or let uv update your shell configuration:

uv tool update-shell

Usage

Print playlist stats:

ytruntime stats "https://www.youtube.com/playlist?list=PLAYLIST_ID"

Select an inclusive 1-based range:

ytruntime stats "https://www.youtube.com/playlist?list=PLAYLIST_ID" --start 5 --end 20

Export while printing stats:

ytruntime stats "https://www.youtube.com/playlist?list=PLAYLIST_ID" --json report.json
ytruntime stats "https://www.youtube.com/playlist?list=PLAYLIST_ID" --csv report.csv

By default, stats also show playback-adjusted runtimes for 1x, 1.25x, 1.75x, and 2x.

Add custom playback speeds:

ytruntime stats "https://www.youtube.com/playlist?list=PLAYLIST_ID" --speed 1.5
ytruntime stats "https://www.youtube.com/playlist?list=PLAYLIST_ID" --speed 1.5 --speed 3

Use the dedicated export command:

ytruntime export "https://www.youtube.com/playlist?list=PLAYLIST_ID" --format json --output report.json
ytruntime export "https://www.youtube.com/playlist?list=PLAYLIST_ID" --format csv --output report.csv

Find the longest or shortest videos:

ytruntime longest "https://www.youtube.com/playlist?list=PLAYLIST_ID" --limit 10
ytruntime shortest "https://www.youtube.com/playlist?list=PLAYLIST_ID" --limit 10

Check the installed version:

ytruntime --version

Demo Screenshots

Screenshots should be added after the first tagged release.

Suggested captures:

  • ytruntime stats ...
  • ytruntime stats ... --json report.json
  • error output for an invalid playlist URL

Shell Completion

Install shell completion for your current shell:

ytruntime --install-completion

Restart your shell after installation.

Commands

  • stats: print playlist runtime statistics.
  • export: write JSON or CSV output.
  • longest: show the longest videos.
  • shortest: show the shortest videos.

Development

uv sync --extra dev
uv run ytruntime --help
uv run ruff check .
uv run pytest
uv build

Check global install behavior locally:

pipx install .
uv tool install .

Release

Releases are built by GitHub Actions when a tag like v0.1.0 is pushed. The release workflow runs tests, builds the wheel and source distribution, uploads the artifacts, publishes to PyPI, and creates a GitHub Release with generated release notes.

Maintainer setup:

  1. Create the ytruntime project on PyPI.
  2. Create a PyPI API token with permission to publish ytruntime.
  3. Add the token to this GitHub repository as a secret named PYPI_API_TOKEN.

Publish a new version:

uv sync --extra dev --frozen
uv run ruff check .
uv run pytest
uv build
git status
git tag v0.1.0
git push origin main
git push origin v0.1.0

Use a new tag for every release. PyPI does not allow replacing an already published version, so update version in pyproject.toml before tagging.

Homebrew Prep

Homebrew support should be added after the first GitHub release exists.

Planned flow:

brew tap Adityagaddhyan/tap
brew install ytruntime

The future tap repo should be named Adityagaddhyan/homebrew-tap and contain a formula that installs the released wheel or source archive from GitHub/PyPI.

License

MIT

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

ytruntime-0.1.1.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

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

ytruntime-0.1.1-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file ytruntime-0.1.1.tar.gz.

File metadata

  • Download URL: ytruntime-0.1.1.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ytruntime-0.1.1.tar.gz
Algorithm Hash digest
SHA256 137bba6e183e3f4ce5bc5c54c1ee8780365fdccc8b5ef15b1de1689e5d17f6ab
MD5 55e3dc5c31e1a882432a3efa83b37f61
BLAKE2b-256 ecf070a1e02ed993def55ffe9fa2a641fa7e736d72f030791db54600beebaca3

See more details on using hashes here.

File details

Details for the file ytruntime-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ytruntime-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ytruntime-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b2b1896387076ad66477f0266cd1a024ba529be7c30a28acc320607b638e08d8
MD5 d47a8183c8f591ad07502fecb0fe8887
BLAKE2b-256 786aaf801b55771a15f9f9169cd118350bb36932d39fa6492505424795f05b0f

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