@bililive-tools/manager
Version:
Batch scheduling recorders
79 lines (78 loc) • 2.37 kB
JavaScript
// forked from https://github.com/WhiteMinds/LiveAutoRecord
import ffmpeg from "@renmu/fluent-ffmpeg";
import { omit, pick } from "lodash-es";
import utils from "./utils.js";
export * from "./common.js";
export * from "./recorder.js";
export * from "./manager.js";
export * from "./cache.js";
export * from "./downloader/FFmpegDownloader.js";
export { createDownloader } from "./downloader/index.js";
export { checkTitleKeywordsWhileRecording, checkTitleKeywordsBeforeRecord } from "./utils.js";
export { utils };
/**
* 提供一些 utils
*/
export function defaultFromJSON(provider, json) {
return provider.createRecorder(omit(json, ["providerId"]));
}
export function defaultToJSON(provider, recorder) {
// @ts-ignore
return {
providerId: provider.id,
...pick(recorder, [
"id",
"channelId",
"remarks",
"disableAutoCheck",
"quality",
"streamPriorities",
"sourcePriorities",
"extra",
"segment",
"saveSCDanma",
"saveCover",
"convert2Mp4",
"saveGiftDanma",
"disableProvideCommentsWhenRecording",
"liveInfo",
"uid",
"titleKeywords",
// "recordHandle",
]),
};
}
// 目前是假设使用环境的规模都比较小,不太容易遇到性能问题,所以用 string uuid 作为 id 来简化开发的复杂度。
// 后面如果需要再高一些的规模,可以优化成分布式 id 生成器,或者其他的异步生成 id 的方案。
export function genRecorderUUID() {
return utils.uuid();
}
export function genRecordUUID() {
return utils.uuid();
}
let ffmpegPath = "ffmpeg";
export function setFFMPEGPath(newPath) {
ffmpegPath = newPath;
}
export const createFFMPEGBuilder = (...args) => {
ffmpeg.setFfmpegPath(ffmpegPath);
return ffmpeg(...args);
};
// Mesio path management
let mesioPath = "mesio";
export function setMesioPath(newPath) {
mesioPath = newPath;
}
export function getMesioPath() {
return mesioPath;
}
let bililivePath = "BililiveRecorder.Cli";
export function setBililivePath(newPath) {
bililivePath = newPath;
}
export function getBililivePath() {
return bililivePath;
}
export function getDataFolderPath(provider) {
return "./" + provider.id;
}