chzzk-z
Version:
chzzk-z is naver streaming platform Chzzk Library
50 lines • 2.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const lib_1 = require("./lib");
const axios_1 = require("axios");
const m3u8Parser = require("m3u8-parser");
const stream_recorder_1 = require("./lib/chzzk/stream/stream-recorder");
const node_path_1 = require("node:path");
const node_fs_1 = require("node:fs");
const test = async () => {
const chzzk = new lib_1.ChzzkModule();
const live = await chzzk.live.findDetailByChannelId("554e99695decc451d57788b1fd5d5c07");
const media = live.livePlayback.media;
const hls = media.find((media) => media.mediaId === "HLS");
if (hls) {
const originalUrl = hls.path.split("/").slice(0, 7).join("/");
const indexPlayList = await axios_1.default.get(hls.path, {
responseType: "arraybuffer",
});
const parser = new m3u8Parser.Parser();
parser.push(indexPlayList.data);
parser.end();
const hlsUrl = originalUrl + "/" + parser.manifest.playlists[0].uri;
const outputDir = (0, node_path_1.join)(process.cwd(), "output", `${live.channel.channelId}_${live.liveId}`);
if (!(0, node_fs_1.existsSync)(outputDir)) {
(0, node_fs_1.mkdirSync)(outputDir, { recursive: true });
}
const recorder = new stream_recorder_1.StreamRecorder(hlsUrl, outputDir);
console.log("Recording started...");
await recorder.start();
setTimeout(() => {
recorder.stop();
console.log("Recording stopped");
}, 30000);
}
};
const { exec } = require("child_process");
function transcribeVideo(filePath) {
exec(`whisper ${filePath} --model medium`, (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.error(`stderr: ${stderr}`);
});
}
console.log("start test");
test().catch(console.error);
console.log("end test");
//# sourceMappingURL=test.js.map