CLI for YouTube channel analysis and transcript downloading
Project description
yt-metrics-cli
CLI tool that analyzes YouTube channels and downloads video transcripts, generating engagement metrics and structured reports.
Problem
YouTube Studio gives you analytics for your own channels. If you want to compare multiple channels, benchmark engagement rates, or bulk-download transcripts for research, you're stuck with manual work or fragmented browser extensions.
yt-metrics-cli solves this: point it at a list of channels, get CSV data, engagement reports, and transcript files in one command.
Quick Start
# Install
pip install yt-metrics-cli
# or
uv tool install yt-metrics-cli
# Set your API key
export YOUTUBE_API_KEY=your_key_here
# Get one at: https://console.cloud.google.com/apis/credentials
# Create channels.yml
cat > channels.yml << 'EOF'
- custom_url: "@mkbhd"
- custom_url: "@veritasium"
EOF
# Analyze
yt-metrics channels
Features
| Feature | Description |
|---|---|
| Multi-channel analysis | Analyze N channels in one run |
| Engagement metrics | View rate, like rate, comment rate, viral detection |
| CSV export | Raw data with all computed fields |
| Text reports | Channel stats, trends, top/latest video URLs |
| Transcript download | Multi-language with 3-level fallback chain |
| API resilience | Exponential backoff on rate limits (403/429) |
Usage
Analyze Channels
yt-metrics channels # Use defaults from .env
yt-metrics channels -c my_channels.yml # Custom channel list
yt-metrics channels -n 100 -o ./reports # 100 videos, custom output
Generates timestamped reports in output/<timestamp>/:
- CSV — Raw data with all metrics per video
- Channel Stats — Per-channel analysis with top 5 videos
- Engagement Trends — Cross-channel comparisons and rankings
- Best/Latest Videos — URL lists for quick access
- README — Index explaining all generated files
Download Transcripts
yt-metrics transcript -v dQw4w9WgXcQ # Specific video
yt-metrics transcript -v abc123 -l es,en # Language preference
Engagement Metrics
| Metric | Formula | Interpretation |
|---|---|---|
| Engagement Rate | (likes + comments) / views * 100 |
Overall audience interaction |
| View Rate | views / subscribers * 100 |
Reach beyond subscriber base (>100% = viral) |
| Like Rate | likes / views * 100 |
Content satisfaction signal |
| Comment Rate | comments / views * 100 |
Discussion engagement level |
Configuration
All settings can be set via environment variables or .env file:
| Variable | Default | Description |
|---|---|---|
YOUTUBE_API_KEY |
(required) | YouTube Data API v3 key |
MAX_RESULTS_PER_CHANNEL |
50 |
Videos to fetch per channel |
OUTPUT_DIR |
./output |
Report output directory |
CHANNELS_FILE |
channels.yml |
Channel list file path |
VIDEO_ID |
— | Default video for transcript mode |
TRANSCRIPT_LANGUAGES |
es,en |
Preferred transcript languages |
Development
git clone https://github.com/mlorentedev/yt-metrics-cli.git
cd yt-metrics-cli
make install # Create venv + install deps
make check # Lint + typecheck + test
make build # Full build
See CONTRIBUTING.md for details.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yt_metrics_cli-0.2.0.tar.gz.
File metadata
- Download URL: yt_metrics_cli-0.2.0.tar.gz
- Upload date:
- Size: 139.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
032065bba06bebd2cba5cc225bc90a361e2be2d4a19d2a88c340c08e3f2e5397
|
|
| MD5 |
f5b56fec37e3fc34d18befd9e83c5b6e
|
|
| BLAKE2b-256 |
ec2a1abbee4d5bae95daceaee3e50cdbebdfe87676d8f2a4209c7c9939471218
|
Provenance
The following attestation bundles were made for yt_metrics_cli-0.2.0.tar.gz:
Publisher:
release.yml on mlorentedev/yt-metrics-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yt_metrics_cli-0.2.0.tar.gz -
Subject digest:
032065bba06bebd2cba5cc225bc90a361e2be2d4a19d2a88c340c08e3f2e5397 - Sigstore transparency entry: 1106614620
- Sigstore integration time:
-
Permalink:
mlorentedev/yt-metrics-cli@8b87d70acc35809deaceeb7f3ddc35a91169aad0 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/mlorentedev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8b87d70acc35809deaceeb7f3ddc35a91169aad0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file yt_metrics_cli-0.2.0-py3-none-any.whl.
File metadata
- Download URL: yt_metrics_cli-0.2.0-py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c38110f1e94608893b0436055c0d6cb0d5d5809b1b4d43501859bfdeac5c84f5
|
|
| MD5 |
ac3e07e149d9e6a7b629fbccedffb99e
|
|
| BLAKE2b-256 |
1bb66576a91013026e579d5ddbff3428d1731b2b64b4084771ba2b1cf8026fd0
|
Provenance
The following attestation bundles were made for yt_metrics_cli-0.2.0-py3-none-any.whl:
Publisher:
release.yml on mlorentedev/yt-metrics-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yt_metrics_cli-0.2.0-py3-none-any.whl -
Subject digest:
c38110f1e94608893b0436055c0d6cb0d5d5809b1b4d43501859bfdeac5c84f5 - Sigstore transparency entry: 1106614624
- Sigstore integration time:
-
Permalink:
mlorentedev/yt-metrics-cli@8b87d70acc35809deaceeb7f3ddc35a91169aad0 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/mlorentedev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8b87d70acc35809deaceeb7f3ddc35a91169aad0 -
Trigger Event:
push
-
Statement type: