feat: separate Ollama text/image/think models + add YouTube downloader
Support OLLAMA_IMAGE_MODEL and new OLLAMA_THINK_MODEL (both default to OLLAMA_MODEL) Add /ollamathink command; validate thinking capability; disable image-analysis flow in think mode Make /ollama-get-model show Text/Image/Think blocks only when models differ Add /ytdl (/youtube) command + auto-detect YouTube URLs in messages Cache downloaded videos to data/video and schedule daily cleanup Move photo storage from data/temp to data/photo; improve env boolean parsing via ifTrue Update deps (youtubei.js, puppeteer*) and TS config (allowJs, allowSyntheticDefaultImports)
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import {logError} from "./utils";
|
||||
import fs from "node:fs";
|
||||
import {videoDir} from "../index";
|
||||
import path from "node:path";
|
||||
|
||||
export function clearUpVideoFolder() {
|
||||
fs.readdir(videoDir, (err, files) => {
|
||||
if (err) {
|
||||
logError(err);
|
||||
return;
|
||||
}
|
||||
|
||||
const filenamesToDelete: string[] = [];
|
||||
|
||||
files.forEach((filename, index) => {
|
||||
fs.stat(path.join(videoDir, filename), (err, stats) => {
|
||||
if (err) {
|
||||
logError(err);
|
||||
} else {
|
||||
const then = stats.mtime.getTime() / 1000;
|
||||
const now = Date.now() / 1000;
|
||||
const diff = Math.abs(now - then);
|
||||
const moreThanOneDay = diff >= 60 * 60 * 24;
|
||||
if (moreThanOneDay) {
|
||||
filenamesToDelete.push(filename);
|
||||
}
|
||||
|
||||
if (index === files.length - 1) {
|
||||
console.log("filenamesToDelete", filenamesToDelete);
|
||||
if (filenamesToDelete.length) {
|
||||
filenamesToDelete.forEach((filename) => {
|
||||
const fullPath = path.join(videoDir, filename);
|
||||
fs.rm(fullPath, logError);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user