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)
Metadata
Release files for shorts-trends 5.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| shorts_trends-5.0.0.tar.gz | 682.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| shorts_trends-5.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.1 MB
Release files / shorts_trends-5.0.0.tar.gz
| Download URL | shorts_trends-5.0.0.tar.gz |
|---|---|
| Size | 682.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ccd32497ec212474065f9f412cd7352683bea486b59795bdba159ce4b0159a5
|
|
BLAKE2b-256 checksum How to use checksums |
2d90ac100581da3cac29ccb7fd565c417ef696a70fb2c9bc0d8bc4cd38f9bb82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 16, 2026.
Transparency logRelease files / shorts_trends-5.0.0-py3-none-any.whl
| Download URL | shorts_trends-5.0.0-py3-none-any.whl |
|---|---|
| Size | 464.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
779f7602223c3e5dc3715b2b667788f8c1e567aaab5b64ca32f326cc6c8241bf
|
|
BLAKE2b-256 checksum How to use checksums |
32f2251db6113a091170669a6fd4be7e0aed1b7758acafbbafa5f97a40d1517c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 16, 2026.
Transparency log