UNPKG

@dan-uni/dan-any

Version:

A danmaku transformer lib, supporting danmaku from different platforms.

31 lines (30 loc) 1.16 kB
import type { Options as UniPoolOptions } from '..'; import type { RawConfig } from './ass/raw'; import type { CanvasCtx, SubtitleStyle } from './types'; import { UniPool } from '..'; export { CanvasCtx }; export type Options = { filename?: string; title?: string; substyle?: Partial<SubtitleStyle>; raw?: RawConfig; }; /** * 使用bilibili弹幕(XMl)生成ASS字幕文件 * @param {string} danmaku XML弹幕文件内容 * @param {Options} options 杂项 * @returns {string} 返回ASS字幕文件内容 * @description 杂项相关 `filename`: 还原文件为XML时使用的默认文件名 `title`: ASS [Script Info] Title 项的值,显示于播放器字幕选择 `substyle`: ASS字幕样式 * @example ```ts import fs from 'fs' const filename = 'example.xml' const xmlText = fs.readFileSync(filename, 'utf-8') const assText = generateASS(xmlText, { filename, title: 'Quick Example' }) fs.writeFileSync(`${filename}.ass`, assText, 'utf-8') ``` */ export declare function generateASS(danmaku: UniPool, options: Options, canvasCtx: CanvasCtx): string; export declare function parseAssRawField(ass: string, options?: UniPoolOptions): UniPool;