yt-to-post: one YouTube video into one WordPress draft

A WordPress plugin that turns a video's captions or a supplied transcript into a structured draft with the video embedded and the source credited. It never publishes, and it checks every quote against the transcript.

yt-to-post is a WordPress plugin for editors who cover video. It turns one YouTube video into one draft. The words come from captions downloaded through the official YouTube Data API under your own OAuth connection, or from a transcript you supply. A language model writes a structured article from them, with the video embedded and the source credited. An editor reads, fixes and publishes it. The code is at https://github.com/IndianOpinion/yt-to-post, licensed MIT. Version v0.1.0 was released on 19 November 2026.

We wrote it from scratch from an idea, not from any third-party plugin. It has not run against the real YouTube API or on a live site. The 47 utilities in this series were specified, built, reviewed and released between 11 and 19 November 2026 by language-model coding agents under the editor’s direction, in five roles: a spec writer, a spec reviewer, a builder that saw only the spec, an independent code reviewer and a releaser. The editor made the rulings on every open question.

The problem

Editors who cover interviews, speeches and briefings write the same article by hand each time: watch the video, find the quotes, note the timestamps, write it up, embed the player, add the credit. The obvious shortcuts are wrong or fragile. The PRD lists why:

  • Scraping a watch page or using an unofficial transcript library breaks YouTube’s terms, breaks when the page changes, and can get the server blocked.
  • Pasting a whole transcript into a chat model fills the context on long videos, invents quotes the speaker never said, answers in the wrong language, and forgets the embed and the credit.
  • Automatic captions have no punctuation, repeat lines and carry noise such as [Music].
  • Tools that publish straight away put unchecked text on the site.

What it does

  • Parses a video link to an 11-character id without any network call. The id is the identity, so a draft or running job for the same video is returned instead of a new one.
  • Reads metadata, then caption tracks, as WebVTT, then SRT, then the original format. It accepts a supplied transcript in WebVTT, SRT, SBV, TTML or plain text.
  • Cleans the transcript: annotations, rolling-caption repeats and tags.
  • Writes a structured article through a model chain: title, standfirst, sections that follow the video’s chapters, key points, quotes with timestamp links, and a credit line.
  • Puts a job in a “needs transcript” state when no usable captions exist, and resumes when you supply one.
  • Works through a settings screen, a Tools page, REST routes and wp yt-to-post commands.

How it works

Each job is a row that a runner advances one unit at a time, saving after every step. The steps are metadata, captions, normalise, map, reduce and draft. A short transcript takes one model call. A long one is split into chunks, on chapter starts when there are chapters. Each chunk becomes notes that are saved at once, and a reduce call writes the article from the notes. A failure therefore never pays twice for the same chunk.

Source text goes only in the user message, fenced as untrusted data. The model’s output must fit a JSON schema. A QuoteVerifier then checks every quote word for word against the transcript and takes its time from the cue where it begins. Quotes that are not found are dropped and counted in the draft notes. A LanguageCheck compares the article language with the requested one by looking at the letters, with one retry.

The draft is written as block markup with wp_insert_post, with the status forced to draft or pending after every filter has run.

define('YT_TO_POST_CLIENT_ID', '...apps.googleusercontent.com');
define('YT_TO_POST_CLIENT_SECRET', '...');
define('YT_TO_POST_LLM_API_KEY', '...');

With spend-meter present, each model call is checked first through spend_meter_pre_spend and reported afterwards through spend_meter_record. With gen-queue present, the plugin registers a job type and enqueues through the soft filter, and falls back to its own WP-Cron runner if no job id comes back. Neither is required.

Guard rails

  • It never publishes. Only draft and pending are possible.
  • It uses only the documented Data API and the public oEmbed endpoint. It does not fetch watch pages, timed-text endpoints or unofficial libraries. Caption calls need your OAuth consent.
  • Before every paid call it reads the kill switch, the daily caps and the yt_to_post_can_run filter fresh. Defaults are 10 videos and 200 model calls a day. A cap of 0 means no new work. A held job resumes on its own when the reason clears.
  • A video from a channel other than the connected one waits for a “I have the rights to use this video” tick, which is recorded with the user. The plugin does not decide whether you may use a video.
  • Live, upcoming, still-processing and other people’s private videos are refused. Age, kids and region limits become warnings in the draft notes.
  • Tokens are encrypted at rest. Every outbound request refuses private addresses, follows no redirects and caps the response body.
  • An out-of-credit answer holds jobs instead of failing them. An invalid_grant from Google asks you to reconnect rather than looping.

What review changed

The independent code review found and fixed these before the merge:

  • The spend-meter and gen-queue integrations used the wrong names and argument shapes. The code treated a null pre-spend answer as a deny, and called hooks that do not exist. It was rebuilt against the released contracts of both plugins.
  • Saving the settings form switched the plugin off, because every missing checkbox, including enabled, was forced to false. Fixed with a regression test.
  • Outbound requests could reach unsafe addresses and read unbounded bodies. Every request now refuses them and caps the body. The API key is redacted from network errors, and oEmbed answers are bounded.
  • An expired runner lock could be taken by two processes at once, letting daily caps race. It is now taken over with a compare-and-swap.

Limits and what is next

  • Caption download works only for videos the connected account owns or may edit. For other videos you supply the transcript.
  • No audio transcription and no video download.
  • No machine translation through YouTube. The model translates when the article language differs.
  • The token estimate is bytes divided by three, adjustable per model.
  • The client secret, API key and model key sit in plain text in the settings option when not set by constants. The screen recommends the constants and never prints them back. The review noted this and left it.

There are no open issues. This is v0.1.0, tested on stubs, mocks and fakes: 148 PHPUnit tests against fakes for the network and the clock, with a mock model. Static analysis and code style checks passed. In the suite, a 60-minute captioned talk becomes a draft in 4 mock model calls, with every quote found word for word in the transcript. The suite did not exercise the live API. CI has not yet run on GitHub: the commit adding the workflow stayed local because the token lacked the workflow scope.

Install

It needs WordPress 6.4 or later, PHP 8.1 or later, with json, mbstring, dom and libxml, and sodium or WordPress’s polyfill. The model caller comes from llm-json-php, a Composer dependency that is never bundled.

composer config repositories.llm-json-php vcs https://github.com/IndianOpinion/llm-json-php
composer config repositories.yt-to-post vcs https://github.com/IndianOpinion/yt-to-post
composer require indianopinion/yt-to-post

Without Composer, run composer install --no-dev inside the plugin folder, or plug in your own model caller with the yt_to_post_model_caller filter.

All 47 utilities · yt-to-post on GitHub

Search Trending
Loading

Signing-in 3 seconds...

Signing-up 3 seconds...

All fields are required.