The reference worker below turns any podcast MP4 or YouTube URL into 8 vertical 9:16 captioned shorts via ClipSDK, handles HTTP 202 long-polling cleanly, and prints ranked download URLs for MP4, JPG poster, SRT, and VTT files. Complete runnable templates are maintained in clipsdk-api-skills.
PYTHON | AUTOMATED PODCAST CLIPPING + KARAOKE CAPTIONSZero dependencies | Python 3.10+
import json, os, time, urllib.request, uuid
API_KEY = os.environ["CLIPSDK_KEY"]
BASE = "https://api.clipsdk.com"
def api_call(method, path, body=None, idem_key=None):
headers = {"Authorization": f"Bearer {API_KEY}", "Accept": "application/json"}
data = None
if body is not None:
headers["Content-Type"] = "application/json"
data = json.dumps(body).encode("utf-8")
if idem_key:
headers["Idempotency-Key"] = idem_key
req = urllib.request.Request(f"{BASE}{path}", data=data, headers=headers, method=method)
with urllib.request.urlopen(req, timeout=90) as resp:
return resp.status, json.loads(resp.read().decode("utf-8"))
_, res = api_call(
"POST",
"/v1/clips?wait=60",
{
"video_url": "https://cdn.example.com/podcast-ep104.mp4",
"clips": 8,
"min_seconds": 25,
"max_seconds": 60,
"aspect": "9:16",
"reframe": "auto",
"captions": {
"preset": "karaoke",
"font": "Montserrat",
"position": "bottom",
"keyword_color": "#22D3EE",
"pop_in": True,
},
"hook": {"template": "banner", "seconds": 4},
"bleep": True,
"prompt": "sharp guest stories and actionable takeaways",
},
idem_key=f"ep104-{uuid.uuid4().hex}",
)
job = res["job"]
while job["status"] in ("queued", "running"):
time.sleep(5)
_, res = api_call("GET", f"/v1/jobs/{job['id']}?wait=60")
job = res["job"]
if job["status"] != "succeeded":
raise RuntimeError(f"Clip job failed: {job['error']}")
for clip in job["result"]["clips"]:
print(f"#{clip['rank']} ({clip['score']}/100) {clip['title']} | mp4={clip['video']} | srt={clip['srt']}")
POST-RENDER WORD-LEVEL CAPTION FIX & TRIM (CLIPSDK)Paid accounts: up to 20 edits/clip, 100/day
# 1. Inspect exact word timestamps for rank-1 clip
curl -sS "https://api.clipsdk.com/v1/jobs/job_0123456789abcdefghij/clips/1/words" \
-H "Authorization: Bearer $CLIPSDK_KEY"
# 2. Trim 2.4s off the intro and switch captions to punch without re-transcribing the 1-hr episode
curl -sS -X POST "https://api.clipsdk.com/v1/jobs/job_0123456789abcdefghij/clips/1/edit" \
-H "Authorization: Bearer $CLIPSDK_KEY" \
-H "Content-Type: application/json" \
-d '{"trim":{"start_s":2.4,"end_s":48.0},"captions":"punch","hook":{"template":"pill","seconds":3}}'