YouTube Shorts trend analyzer with local dashboard
Project description
YouTube Shorts Trend Analyzer
Local Python pipeline that ingests YouTube Shorts data, identifies early viral candidates, scores them with AI-driven content evaluation, and surfaces repeatable viral formats.
Quickstart
python -m venv .venv
.venv\Scripts\activate # Windows
pip install -r requirements.txt
python main.py --input data/sample_videos.csv
Default scorer is MockScorer (no API key needed) so the pipeline runs out of the box.
AI Features (Claude Code)
The --script, --ideas, and SCORER=claude features authenticate via a signed-in Claude Code CLI session.
Prerequisites
-
Install the Claude Code CLI:
npm install -g @anthropic-ai/claude-code
-
Sign in with your Claude Max plan:
claude loginComplete the OAuth flow in the browser using the account that holds your Max plan subscription.
-
Verify your sign-in:
claude /status
Running AI features
python main.py --input data/sample_videos.csv --script # generates 3 production-ready scripts
python main.py --input data/sample_videos.csv --ideas # generates 2-3 video ideas
All AI usage is billed against your Claude Max plan. No additional API key is required.
Note: API-key fallback (
ANTHROPIC_API_KEY-based auth) is NOT supported in this version. Future versions may revisit this if there is demand.
The YOUTUBE_API_KEY environment variable is only needed for --query and --channel (live YouTube fetching), not for AI features.
Async usage (FastAPI)
All three generators expose native async methods (ascore, agenerate) usable directly from async hosts without RuntimeError:
from fastapi import FastAPI
from ai_analysis.claude_scorer import ClaudeScorer
from output.ideas import IdeaGenerator
app = FastAPI()
scorer = ClaudeScorer()
idea_gen = IdeaGenerator()
@app.post("/analyze")
async def analyze(videos: list[dict]):
# Convert request payload into Video objects (omitted)
scored = await scorer.ascore(video_list)
ideas = await idea_gen.agenerate(
archetypes=detected_archetypes,
top_videos=scored,
)
return {"scores": scored, "ideas": ideas}
The sync entry methods (score_batch, generate) are preserved as thin wrappers and remain safe to call from any host — including async ones — via internal sync-from-async dispatch.
Pipeline
CSV input
│
▼
data_collection → list[Video]
│
▼
feature_extraction → metrics: views/hour, age_hours
│
▼
ai_analysis → hook_strength, curiosity_gap, viral_potential (0-10 each)
│
▼
scoring → composite 0-100
│
▼
output → ranked table + pattern report
Modules
| Module | Purpose |
|---|---|
config/ |
Weights, thresholds, model settings |
data_collection/ |
CSV loader (v1), YouTube API client (v2) |
feature_extraction/ |
Numeric metrics (views/hour, age) |
ai_analysis/ |
Pluggable LLM scorers (Mock / Claude) |
scoring/ |
Combine metrics + AI scores into composite |
output/ |
Rank, print, extract patterns |
Production Pipeline (v5.0)
The v5.0 production pipeline turns a generated script into an upload-ready YouTube Shorts bundle:
shorts-trends produce --from-script <script.json> [--variant N] [--length 15s|30s|60s] [--out <dir>]
The bundle directory <out>/<run_id>/ contains:
<run_id>.mp4— final 1080×1920 stitched shortmetadata.json— title (≤95 chars), description (first line contains#Shorts), tags (within YouTube's 500-char budget),category_id: 22,privacy_status: "private",thumbnail_kind: "auto"<run_id>_thumbnail.png— auto-extracted midpoint framecredits.json— Pexels attribution list<run_id>.srt— sidecar captions (YouTube CC parity)upload_instructions.txt— step-by-step manual upload guide
Manual upload boundary
v5.0 produces an upload-ready bundle. Manual upload via
studio.youtube.com is the supported
path. Programmatic upload (--upload flag, OAuth flow, credentials cache)
is on the v5.1 roadmap (UPLOAD-V51-01).
Following each shorts-trends produce run, open upload_instructions.txt
in the bundle directory for the exact YouTube Studio steps. The
metadata.json fields are designed to be copy-pasted directly into the
YouTube Studio upload form.
Roadmap
- v1 (this scaffold): CSV → mock scoring → ranked output
- v2: Plug in Claude (
claude-agent-sdk) — auth delegates to a signed-in Claude Code CLI session. - v3: YouTube Data API v3 collector replacing CSV
- v4: Scheduling (cron / Windows Task Scheduler) + persistence (SQLite)
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 shorts_trends-5.0.0.tar.gz.
File metadata
- Download URL: shorts_trends-5.0.0.tar.gz
- Upload date:
- Size: 682.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ccd32497ec212474065f9f412cd7352683bea486b59795bdba159ce4b0159a5
|
|
| MD5 |
ce89724c52347e82a16aa27c5f434d20
|
|
| BLAKE2b-256 |
2d90ac100581da3cac29ccb7fd565c417ef696a70fb2c9bc0d8bc4cd38f9bb82
|
Provenance
The following attestation bundles were made for shorts_trends-5.0.0.tar.gz:
Publisher:
release.yml on steleo16/yt-shorts-trends1
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shorts_trends-5.0.0.tar.gz -
Subject digest:
5ccd32497ec212474065f9f412cd7352683bea486b59795bdba159ce4b0159a5 - Sigstore transparency entry: 1552949126
- Sigstore integration time:
-
Permalink:
steleo16/yt-shorts-trends1@199293dec42b1b4568672767530a251729adc65a -
Branch / Tag:
refs/tags/v5.0.0 - Owner: https://github.com/steleo16
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@199293dec42b1b4568672767530a251729adc65a -
Trigger Event:
release
-
Statement type:
File details
Details for the file shorts_trends-5.0.0-py3-none-any.whl.
File metadata
- Download URL: shorts_trends-5.0.0-py3-none-any.whl
- Upload date:
- Size: 464.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
779f7602223c3e5dc3715b2b667788f8c1e567aaab5b64ca32f326cc6c8241bf
|
|
| MD5 |
7dda31b82cf821dcbd4c8143e5655aa3
|
|
| BLAKE2b-256 |
32f2251db6113a091170669a6fd4be7e0aed1b7758acafbbafa5f97a40d1517c
|
Provenance
The following attestation bundles were made for shorts_trends-5.0.0-py3-none-any.whl:
Publisher:
release.yml on steleo16/yt-shorts-trends1
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shorts_trends-5.0.0-py3-none-any.whl -
Subject digest:
779f7602223c3e5dc3715b2b667788f8c1e567aaab5b64ca32f326cc6c8241bf - Sigstore transparency entry: 1552949131
- Sigstore integration time:
-
Permalink:
steleo16/yt-shorts-trends1@199293dec42b1b4568672767530a251729adc65a -
Branch / Tag:
refs/tags/v5.0.0 - Owner: https://github.com/steleo16
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@199293dec42b1b4568672767530a251729adc65a -
Trigger Event:
release
-
Statement type: