React when a transcript is imported
Your add-on wants to know how a transcript arrived, not only that its text changed: a migration tool reporting which episodes kept their transcripts, say, or a workflow tile marking an episode’s transcript done. Re-indexing does not need this: benecaster_transcript_updated fires for imports too, with imported.
- It fires after the transcript is stored and the episode’s transcript URL is written, so
benecaster_get_episode_transcript_text( $episode_id )already returns the new text, unless the transcript is Hidden. - It fires for a Replace with the same text too;
benecaster_transcript_updateddoes not. - A
txtimport has no timestamps: anything that needs them (chapter suggestions, click-to-jump) is not available for that episode. - The window’s routes are documented under Transcript import routes; they are for the add-on’s own screen. Another add-on importing a transcript never calls them or writes the table: it calls
benecaster_import_episode_transcript(), which fires this action with the$import_methodit was given,rss_feedby default.
Code
<?php
add_action( 'benecaster_transcript_imported', function ( int $transcript_id, int $episode_id, string $format, string $source ): void {
// $format: 'srt', 'vtt', 'txt' (no timestamps) or 'json' (Whisper JSON).
// $source: 'file', 'paste' or 'rss_feed'.
if ( 'rss_feed' === $source ) {
update_post_meta( $episode_id, '_my_addon_transcript_carried_over', 1 );
}
}, 10, 4 );
Hooks Used
Need this built rather than just documented? See our services →