Skip to main content

benecaster_transcript_url_generated

Action Free

Fires when an episode gains a Podcasting 2.0 transcript by something other than the podcaster typing it — the media picker, the benecaster_podcast2_transcript_autodetect auto-detection scan, a PowerPress import bringing across a transcript PowerPress publishes, or the Transcription Service add-on finishing a transcription. Transcription Service fires it with its WebVTT address and text/vtt when a completed transcription writes a new address to the episode; not when the address is unchanged (a transcript finished again), nor when the podcaster’s own URL is kept.

The negatives are the contract and must be read as such. It does NOT fire on a hand-typed URL, NOR when the written URL equals the stored one, NOR when the field is cleared, NOR when detection finds nothing or finds several files. That is what lets a listener read it as “this episode just acquired a transcript.”

$mime_type is the type as stored, not as requested, so a callback writing it back cannot persist a value the save path rejects.

The source is deliberately NOT a fourth parameter — an add-on’s origin would be a value Benecaster has never heard of. Add-ons that write the field fire this hook themselves via \Benecaster\Episode\TranscriptUrlSource::announce().

It fires during the save, before the response is returned (for Transcription Service, inside its background job) — keep the callback cheap and schedule anything slow rather than doing it inline.

Parameters

Name Type Default Description
$episode_id int — ID of the episode that gained a transcript.
$url string — The transcript URL, as stored.
$mime_type string — The transcript's MIME type, as stored (not necessarily as requested).

Examples

React when an episode gains a transcript

add_action(
    'benecaster_transcript_url_generated',
    function ( int $episode_id, string $url, string $mime_type ): void {
        wp_schedule_single_event(
            time() + 30,
            'my_addon_process_transcript',
            [ $episode_id, $url, $mime_type ]
        );
    },
    10,
    3
);

Notes

If your add-on writes the field itself, fire this same hook so every listener has one thing to hook regardless of where the transcript came from:

``php $meta = new \Benecaster\Episode\EpisodeMeta( $episode_id ); $meta->set_podcast2_transcript_url( $url ); $meta->set_podcast2_transcript_type( $mime_type ); \Benecaster\Episode\TranscriptUrlSource::announce( $episode_id, $url, $mime_type ); ``

If you write the field through the REST API instead, declare the source and Benecaster fires the hook for you: PUT /benecaster/v1/episodes/{id} accepts an optional podcast2_transcript_url_source of media_picker or autodetect. Absent, manual, or anything unrecognised means a manual write and fires nothing.

Need this built rather than just documented? See our services →