@playzone/youtube-transcript
Version:
A JavaScript API which allows you to get the transcripts/subtitles for a given YouTube video. It also works for automatically generated subtitles and it does not require a headless browser.
88 lines • 2.92 kB
TypeScript
import { FetchedTranscript } from '../transcripts/models';
/**
* Base formatter class
*/
export declare abstract class Formatter {
/**
* Format a single transcript
*/
abstract formatTranscript(transcript: FetchedTranscript, options?: any): string;
/**
* Format multiple transcripts
*/
abstract formatTranscripts(transcripts: FetchedTranscript[], options?: any): string;
}
/**
* Pretty print formatter
*/
export declare class PrettyPrintFormatter extends Formatter {
formatTranscript(transcript: FetchedTranscript, options?: any): string;
formatTranscripts(transcripts: FetchedTranscript[], options?: any): string;
}
/**
* JSON formatter
*/
export declare class JSONFormatter extends Formatter {
formatTranscript(transcript: FetchedTranscript, options?: any): string;
formatTranscripts(transcripts: FetchedTranscript[], options?: any): string;
}
/**
* Plain text formatter
*/
export declare class TextFormatter extends Formatter {
formatTranscript(transcript: FetchedTranscript, options?: any): string;
formatTranscripts(transcripts: FetchedTranscript[], options?: any): string;
}
/**
* Base class for text-based formatters with timestamps
*/
export declare abstract class TextBasedFormatter extends TextFormatter {
/**
* Format timestamp in specific format
*/
protected abstract formatTimestamp(hours: number, mins: number, secs: number, ms: number): string;
/**
* Format transcript header
*/
protected abstract formatTranscriptHeader(lines: string[]): string;
/**
* Format individual transcript line
*/
protected abstract formatTranscriptLine(index: number, timeText: string, snippet: any): string;
/**
* Convert seconds to timestamp
*/
protected secondsToTimestamp(time: number): string;
formatTranscript(transcript: FetchedTranscript, options?: any): string;
}
/**
* SRT formatter
*/
export declare class SRTFormatter extends TextBasedFormatter {
protected formatTimestamp(hours: number, mins: number, secs: number, ms: number): string;
protected formatTranscriptHeader(lines: string[]): string;
protected formatTranscriptLine(index: number, timeText: string, snippet: any): string;
}
/**
* WebVTT formatter
*/
export declare class WebVTTFormatter extends TextBasedFormatter {
protected formatTimestamp(hours: number, mins: number, secs: number, ms: number): string;
protected formatTranscriptHeader(lines: string[]): string;
protected formatTranscriptLine(index: number, timeText: string, snippet: any): string;
}
/**
* Formatter loader
*/
export declare class FormatterLoader {
private static readonly TYPES;
/**
* Load formatter by type
*/
load(formatterType?: string): Formatter;
/**
* Get all supported formatter types
*/
static getSupportedTypes(): string[];
}
//# sourceMappingURL=index.d.ts.map