@yemreak/yt-dlp
Version:
Downloading videos and subtitles using yt-dlp, with utilities for extracting text from subtitles
59 lines (58 loc) • 1.8 kB
TypeScript
import type { Language, MediaInfo, YtDlpOptionals } from "./types.js";
export type YtDlpConfig = {
workdir: string;
cookies?: string;
};
export declare class YtDlp {
readonly config: YtDlpConfig;
readonly filename: string;
readonly binaryPath: string;
constructor(config: YtDlpConfig);
/**
* Downloads the latest release of yt-dlp from GitHub
*/
downloadLatestReleaseIfNotExists(): Promise<void>;
/**
* Returns multiple {@link MediaInfo} objects if contains multiple videos
*/
retrieveMediaInfoList(url: string): Promise<MediaInfo[]>;
exec(optionals: YtDlpOptionals & {
url: string;
}): Promise<{
stdout: string;
stderr: string;
}>;
downloadAudio(params: {
url: string;
} & YtDlpOptionals): Promise<string[]>;
download(params: {
url: string;
} & YtDlpOptionals): Promise<string[]>;
retrieveMediaInfoFromSource(source: MediaSource): Promise<MediaInfo[]>;
/**
* Downloads the subtitle file of a video
*/
downloadSubtitle(params: {
info: MediaInfo;
lang?: Language;
}): Promise<string>;
/**
* Downloads the subtitle file of a video without using yt-dlp
*/
downloadSubtitleWithoutYtDlp(params: {
info: MediaInfo;
lang?: Language;
}): Promise<string | undefined>;
/**
* Extracts the text from a `json3`, `vtt` or `srt` subtitle file
*/
extractTextFromSubtitles(subtitlePath: string): string;
/**
* Downloads and extracts the text from a subtitle file
* - If `source` is a video URL, retrieves the {@link MediaInfo} from the video URL
*/
downloadSubtitleText(params: {
info: MediaInfo;
lang?: Language;
}): Promise<string | undefined>;
}