Silme hatası giderildi.

This commit is contained in:
2025-10-27 06:14:58 +03:00
parent 43b21f02cc
commit bfb99aaea2

View File

@@ -649,6 +649,64 @@ async function downloadImage(url, targetPath) {
} }
} }
function guessPrimaryVideo(rootFolder) {
const safe = sanitizeRelative(rootFolder);
if (!safe) return null;
const baseDir = path.join(DOWNLOAD_DIR, safe);
if (!fs.existsSync(baseDir)) return null;
let bestRelPath = null;
let bestSize = 0;
const stack = [""];
while (stack.length) {
const currentRel = stack.pop();
const currentDir = path.join(baseDir, currentRel);
let dirEntries = [];
try {
dirEntries = fs.readdirSync(currentDir, { withFileTypes: true });
} catch (err) {
console.warn(`⚠️ Klasör okunamadı (${currentDir}): ${err.message}`);
continue;
}
for (const entry of dirEntries) {
const name = entry.name;
if (name.startsWith(".")) continue;
if (name === INFO_FILENAME) continue;
const relPath = path.join(currentRel, name);
const absPath = path.join(currentDir, name);
if (entry.isDirectory()) {
stack.push(relPath);
continue;
}
if (!entry.isFile()) continue;
const ext = path.extname(name).toLowerCase();
if (!VIDEO_EXTS.includes(ext)) continue;
let size = 0;
try {
size = fs.statSync(absPath).size;
} catch (err) {
console.warn(`⚠️ Dosya boyutu alınamadı (${absPath}): ${err.message}`);
continue;
}
if (size >= bestSize) {
bestSize = size;
bestRelPath = relPath;
}
}
}
return bestRelPath ? bestRelPath.replace(/\\/g, "/") : null;
}
async function ensureMovieData( async function ensureMovieData(
rootFolder, rootFolder,
displayName, displayName,