1
0

Compare commits

..

2 Commits

Author SHA1 Message Date
unfr
b82a71b9e7 Amelioration auto-update 2025-08-13 21:58:04 +02:00
unfr
0ea759b490 Amélioration check 2025-08-13 17:27:57 +02:00
2 changed files with 11 additions and 8 deletions

View File

@ -126,7 +126,7 @@ const LP_TIMEOUT_MS = 25000;
function lpNotify(source, filePath) { function lpNotify(source, filePath) {
lpVersion += 1; lpVersion += 1;
console.log('[LP] notify', { version: lpVersion, source, file: filePath }); //console.log('[LP] notify', { version: lpVersion, source, file: filePath });
for (const waiter of lpWaiters) { for (const waiter of lpWaiters) {
clearTimeout(waiter.timer); clearTimeout(waiter.timer);
try { waiter.res.json({ version: lpVersion }); } catch (_) {} try { waiter.res.json({ version: lpVersion }); } catch (_) {}
@ -159,12 +159,13 @@ autopostRouter.get('/updates', (req, res) => {
}); });
// Watcher fichiers (JSON / BDINFO) + fallback scan // Watcher fichiers (JSON / BDINFO) + fallback scan
const infoDir = path.resolve(config.infodirectory); const infoDir = path.resolve(config.logdirectory);
const watchPatterns = [ const watchPatterns = [
path.join(infoDir, '*.json'), path.join(infoDir, '*.json'),
path.join(infoDir, '*.JSON'), path.join(infoDir, '*.JSON'),
path.join(infoDir, '*.bdinfo.txt'), path.join(infoDir, '*.bdinfo.txt'),
path.join(infoDir, '*.BDINFO.TXT') path.join(infoDir, '*.BDINFO.TXT'),
path.join(infoDir, '*.log')
]; ];
const lpWatcher = chokidar.watch(watchPatterns, { const lpWatcher = chokidar.watch(watchPatterns, {
@ -179,7 +180,7 @@ const lpWatcher = chokidar.watch(watchPatterns, {
lpWatcher.on('add', (filePath) => lpNotify('add', filePath)); lpWatcher.on('add', (filePath) => lpNotify('add', filePath));
lpWatcher.on('change', (filePath) => lpNotify('change', filePath)); lpWatcher.on('change', (filePath) => lpNotify('change', filePath));
lpWatcher.on('ready', () => console.log('[LP] watcher ready on', watchPatterns)); //lpWatcher.on('ready', () => console.log('[LP] watcher ready on', watchPatterns));
lpWatcher.on('error', (err) => console.error('[LP] watcher error:', err)); lpWatcher.on('error', (err) => console.error('[LP] watcher error:', err));
// Fallback scan (toutes les 2s) : signature (nb fichiers + dernier mtime) // Fallback scan (toutes les 2s) : signature (nb fichiers + dernier mtime)
@ -189,7 +190,7 @@ let lastSig = null;
async function computeSignature() { async function computeSignature() {
try { try {
const names = await fsp.readdir(infoDir); const names = await fsp.readdir(infoDir);
const files = names.filter(n => /\.json$/i.test(n) || /\.bdinfo\.txt$/i.test(n)); const files = names.filter(n => /(?:\.json|\.log|\.bdinfo\.txt)$/i.test(n));
let latest = 0; let latest = 0;
await Promise.all(files.map(async (n) => { await Promise.all(files.map(async (n) => {
try { try {
@ -423,7 +424,7 @@ autopostRouter.get('/', async (req, res) => {
default: default:
statusText = 'INCONNU'; statusText = 'INCONNU';
} }
let logLink = (parseInt(row.status) === 1 || parseInt(row.status) === 2) let logLink = (parseInt(row.status) === 1 || parseInt(row.status) === 2 || parseInt(row.status) === 4)
? ' | <a href="#" class="log-link text-blue-400 hover:underline" data-filename="' + row.nom + '">Log</a>' ? ' | <a href="#" class="log-link text-blue-400 hover:underline" data-filename="' + row.nom + '">Log</a>'
: ''; : '';
let mediainfoLink = (parseInt(row.status) === 0 || parseInt(row.status) === 1 || parseInt(row.status) === 2) let mediainfoLink = (parseInt(row.status) === 0 || parseInt(row.status) === 1 || parseInt(row.status) === 2)

View File

@ -120,9 +120,11 @@ do_add() {
do_check() { do_check() {
release_path="$2" release_path="$2"
release_name=$(basename "$release_path") release_name=$(basename "$release_path")
release_without_ext="${release_name%.*}" if [[ "${release_name}" =~ \.(mkv|mp4|iso)$ ]]; then
release_name="${release_name%.*}"
fi
response=$(curl -s "${URL_API}${APIKEY}&check=${release_without_ext}") response=$(curl -s "${URL_API}${APIKEY}&check=${release_name}")
code=$(echo "$response" | jq -r '.code') code=$(echo "$response" | jq -r '.code')
explain=$(echo "$response" | jq -r '.Explain') explain=$(echo "$response" | jq -r '.Explain')