UNPKG

@bililive-tools/manager

Version:
50 lines (49 loc) 2.36 kB
import { FFmpegDownloader } from "./FFmpegDownloader.js"; import { mesioDownloader } from "./mesioDownloader.js"; import { BililiveDownloader } from "./BililiveDownloader.js"; export { FFmpegDownloader } from "./FFmpegDownloader.js"; export { mesioDownloader } from "./mesioDownloader.js"; export { BililiveDownloader } from "./BililiveDownloader.js"; import type { IDownloader, FFMPEGRecorderOptions, MesioRecorderOptions, BililiveRecorderOptions } from "./IDownloader.js"; /** * 录制器类型 */ export type DownloaderType = "ffmpeg" | "mesio" | "bililive"; export type FormatName = "flv" | "ts" | "fmp4"; /** * 根据录制器类型获取对应的配置选项类型 */ export type RecorderOptions<T extends DownloaderType> = T extends "ffmpeg" ? FFMPEGRecorderOptions : T extends "mesio" ? MesioRecorderOptions : BililiveRecorderOptions; /** * 根据录制器类型获取对应的录制器实例类型 */ export type RecorderInstance<T extends DownloaderType> = T extends "ffmpeg" ? FFmpegDownloader : T extends "mesio" ? mesioDownloader : BililiveDownloader; type RecorderOpts = FFMPEGRecorderOptions | MesioRecorderOptions | BililiveRecorderOptions; export declare const DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36"; /** * 创建录制器的工厂函数 */ export declare function createBaseDownloader<T extends DownloaderType>(type: T, opts: RecorderOptions<T> & { onlyAudio?: boolean; }, onEnd: (...args: unknown[]) => void, onUpdateLiveInfo: () => Promise<{ title?: string; cover?: string; }>): IDownloader; /** * 选择录制器 */ export declare function selectRecorder(preferredRecorder: "auto" | DownloaderType | undefined): DownloaderType; /** * 判断原始录制流格式,flv, ts, m4s */ export declare function getSourceFormatName(streamUrl: string, formatName: FormatName | undefined): FormatName; type PickPartial<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>> & Partial<Pick<T, K>>; /** * 创建录制器的工厂函数 */ export declare function createDownloader(type: "auto" | DownloaderType | undefined, opts: PickPartial<RecorderOpts, "formatName"> & { onlyAudio?: boolean; }, onEnd: (...args: unknown[]) => void, onUpdateLiveInfo: () => Promise<{ title?: string; cover?: string; }>): IDownloader;