benecaster_import_episode_transcript()
benecaster_import_episode_transcript( int $episode_id, string $content, string $format, string $import_method = 'rss_feed', string $language = '' ): int|WP_Error
Imports a transcript into an episode through the same parse and store as the Import transcript window. Call this rather than writing the transcript table or the episode’s transcript meta yourself.
It never replaces a finished transcript, so a migration run twice changes nothing. A failed transcription is replaced, and an episode whose transcription is pending or processing returns benecaster_transcription_import_busy.
It checks no capability: decide whether the current request may import before calling it. It does check the show: Transcription must be switched on for the episode’s show. It fetches nothing, so the caller supplies the content.
Parameters
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
$episode_id |
int |
— | Yes | The episode. |
$content |
string |
— | Yes | The transcript file's content, as fetched. At most 10 MB. |
$format |
string |
— | Yes | srt, vtt, txt or json (OpenAI Whisper JSON); auto, which never reads JSON; or a ` type as the feed gives it. application/json` is refused: in a feed it is the Podcasting 2.0 JSON transcript, which is not Whisper JSON. |
$import_method |
string |
'rss_feed' |
No | rss_feed, file or paste. |
$language |
string |
'' |
No | The ` tag's language`, passed unchanged. A WebVTT or Whisper JSON file's own language wins over it. SRT and plain text have no field of their own, so theirs comes only from here. |
Return Value
Type:
int|WP_Error
The transcript id, or a WP_Error carrying a translated message and a status. benecaster_transcription_import_exists means the episode already has a finished transcript and nothing changed.
Example
if ( function_exists( 'benecaster_import_episode_transcript' ) ) {
$result = benecaster_import_episode_transcript( $episode_id, $body, $tag['type'], 'rss_feed', $tag['language'] ?? '' );
}
Hooks Fired
Need this built rather than just documented? See our services →