Initial Commit
Some checks are pending
Build Docker Image / docker (push) Waiting to run
Test / test (push) Waiting to run

This commit is contained in:
Lillith Rose (Device: Lucia) 2025-06-08 14:33:19 -04:00
commit fdeba8fd41
17 changed files with 2290 additions and 0 deletions

54
src/index.ts Normal file
View file

@ -0,0 +1,54 @@
import ffmpeg from "fluent-ffmpeg";
import { Event, getCurrentEvent, loadEvents } from "setlist";
const commandBase = ffmpeg()
.input("rtsp://stream.furality.online/live/club")
.seekInput("0:01")
.audioCodec("copy")
.videoCodec("copy")
.outputOption("-y");
async function runCommand(event: Event) {
const eventEnd = new Date(event.end);
const now = new Date();
const secondsUntilEventEnd = Math.max(
0,
Math.floor((eventEnd.getTime() - now.getTime()) / 1000)
);
const command = commandBase.clone().duration(5);
const filename = event.name.replace(/ /g, "_");
console.log(`Saving ${secondsUntilEventEnd}s of 1440p to ${filename}.mkv`);
console.log(process.cwd());
command.save(`./output/${filename}.mkv`);
await new Promise<void>((res) => {
command.on("start", console.log);
command.on("error", (err) => {
throw err;
});
command.on("end", (cmd) => {
console.log(cmd);
res();
});
});
console.log("Command Done");
}
async function main() {
await loadEvents();
while (true) {
// find next
const event = getCurrentEvent();
if (!event?.name) {
console.error("No more sets!");
process.exit(0);
}
await runCommand(event);
// sleep 5s
await new Promise((res) => setTimeout(res, 5000));
}
}
main();

43
src/setlist.ts Normal file
View file

@ -0,0 +1,43 @@
export interface Event {
id: string;
name: string;
start: string;
end: string;
description?: string;
subtitle?: string;
type: string;
imageUrl: string;
questCompatible: boolean;
pcCompatible: boolean;
livestream: boolean;
status: string;
supporter: boolean;
rsvp: boolean;
vote: any;
}
export let events: Event[] | null = null;
export async function loadEvents() {
console.log("Loading Events");
const { data }: { data: Event[] } = await fetch(
"https://api.fynn.ai/v2/event"
).then((i) => i.json());
events = data.filter((i) => i.type === "dj");
console.log(`Loaded ${events.length} DJ events`);
return events;
}
export function getCurrentEvent(): Event | null {
if (!events) return null;
const now = new Date();
return (
events.find((event) => {
const start = new Date(event.start);
const end = new Date(event.end);
return now >= start && now <= end;
}) || null
);
}