jianshuo/claude-skills / wjs-creating-video-book
wjs-creating-video-book
VerifiedUse when the user wants a book turned into YouTube chapter videos — 每章用 VoiceDrop 读书的有声书 mp3 做音轨,配 GPT Image 2 画面和中心思想大字,输出 1920×1080 横屏视频发 YouTube。Triggers — "把这本书做成视频", "有声书做成视频", "讲书视频", "book video", "/wjs-creating-video-book <书名>".
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 11.6 KB |
| scripts/post-transcript-comments.py | script | 4.4 KB |
| scripts/reauth-youtube.py | script | 920 B |
| scripts/render-chapter.py | script | 6.0 KB |
scripts/post-transcript-comments.py
View on GitHub#!/usr/bin/env python3
"""Post a chapter's transcript as YouTube comments under its video:
one top-level comment (part 1/N) + the remaining parts as replies.
Run: uvx --with google-auth --with requests python post-transcript-comments.py \
<video_id> <chapter.md> [--header "《书名》第X章 全文文稿"]
Needs ~/.config/youtube/token.json with scope youtube.force-ssl.
Proxy: honors https_proxy/HTTPS_PROXY env (requests default behavior).
"""
import argparse
import json
import re
import sys
import time
from pathlib import Path
import requests
from google.oauth2.credentials import Credentials
from google.auth.transport.requests import Request
CHUNK = 4200 # chars per comment (YouTube hard limit ~10k; keep readable)
TOKEN = Path.home() / ".config/youtube/token.json"
API = "https://www.googleapis.com/youtube/v3"
def get_access_token() -> str:
creds = Credentials.from_authorized_user_file(str(TOKEN))
if not creds.valid:
creds.refresh(Request())
TOKEN.write_text(creds.to_json())
if "youtube.force-ssl" not in " ".join(creds.scopes or []):
sys.exit("token lacks youtube.force-ssl scope — re-auth first "
"(scripts/reauth-youtube.py)")
return creds.token
def clean_transcript(md: str) -> str:
"""Strip site nav junk from an extracted chapter.md."""
# start at first section heading
m = re.search(r'^## ', md, re.M)
if m:
md = md[m.start():]
# cut trailing nav (下一章/目录/听本章 footer)
for marker in ("\n下一章 →", "\n← 上一章", "\n目录\n", "\n🎧"):
i = md.find(marker)
if i > 0:
md = md[:i]
md = re.sub(r'\n{3,}', '\n\n', md).strip()
return md
def split_chunks(text: str, limit: int = CHUNK):
"""One chunk per '## ' section (readable comment-sized pieces);
oversized sections fall back to paragraph packing; tiny ones merge."""
sections = re.split(r'\n(?=## )', text)
chunks = []
for sec in sections:
sec = sec.strip()
if not sec:
continue
if len(sec) <= limit:
# merge very short sections into the previous chunk
if chunks and len(sec) < 300 and len(chunks[-1]) + len(sec) < limit:
chunks[-1] += "\n\n" + sec
else:
chunks.append(sec)
continue
cur = ""
for p in sec.split("\n\n"):
cand = (cur + "\n\n" + p).strip()
if len(cand) > limit and cur:
chunks.append(cur)
cur = p
else:
cur = cand
if cur:
chunks.append(cur)
# a bare title-only first chunk joins the next section
if len(chunks) > 1 and len(chunks[0]) < 300 and len(chunks[0]) + len(chunks[1]) < limit:
chunks[1] = chunks[0] + "\n\n" + chunks[1]
chunks.pop(0)
return chunks
def post(url, token, payload, proxies=None):
r = requests.post(url, headers={"Authorization": f"Bearer {token}",
"Content-Type": "application/json"},
data=json.dumps(payload), timeout=60)
if r.status_code >= 300:
sys.exit(f"API error {r.status_code}: {r.text[:400]}")
return r.json()
def main():
ap = argparse.ArgumentParser()
ap.add_argument("video_id")
ap.add_argument("chapter_md")
ap.add_argument("--header", default="📖 本章全文文稿")
args = ap.parse_args()
text = clean_transcript(Path(args.chapter_md).read_text())
chunks = split_chunks(text)
n = len(chunks)
token = get_access_token()
first = f"{args.header}(1/{n},其余在本条回复里)\n\n{chunks[0]}"
top = post(f"{API}/commentThreads?part=snippet", token, {
"snippet": {"videoId": args.video_id,
"topLevelComment": {"snippet": {"textOriginal": first}}}})
parent = top["snippet"]["topLevelComment"]["id"]
print(f"top comment posted ({len(first)} chars), id={parent}")
for k, c in enumerate(chunks[1:], start=2):
body = f"({k}/{n})\n\n{c}"
post(f"{API}/comments?part=snippet", token,
{"snippet": {"parentId": parent, "textOriginal": body}})
print(f"reply {k}/{n} posted ({len(body)} chars)")
time.sleep(2) # be gentle; avoid spam-detection on rapid replies
print(f"✓ {n} comment(s) posted on {args.video_id}")
if __name__ == "__main__":
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |