37 lines
814 B
TypeScript
37 lines
814 B
TypeScript
// src/routes/auth.ts
|
|
import { Router } from "express";
|
|
import { downloadMissing, LOCAL_DIR } from "../lib/nextcloud";
|
|
import path from "node:path";
|
|
import { encodeFrames } from "../lib/crateClip";
|
|
|
|
const router = Router();
|
|
|
|
router.get("/video", async (req, res) => {
|
|
const videoPath = path.resolve("./out.mp4");
|
|
res.sendFile(videoPath);
|
|
});
|
|
|
|
router.post("/createclip", async (req, res) => {
|
|
try {
|
|
encodeFrames({
|
|
inputPattern: `${LOCAL_DIR}/*.jpg`,
|
|
output: path.resolve("./out.mp4"),
|
|
fps: 12,
|
|
});
|
|
res.end(200);
|
|
} catch {
|
|
res.end(501);
|
|
}
|
|
})
|
|
|
|
router.post("/refreshfiles", async (req, res) => {
|
|
try {
|
|
await downloadMissing();
|
|
res.end(200);
|
|
} catch {
|
|
res.end(501);
|
|
}
|
|
})
|
|
|
|
export default router;
|