64 lines
2 KiB
JavaScript
64 lines
2 KiB
JavaScript
// api_v1/scanner/debugVideoDates.js
|
|
const path = require('path');
|
|
const { probeVideo } = require('./video');
|
|
|
|
async function debugVideo(absPath) {
|
|
console.log("🎥 File:", absPath);
|
|
|
|
const info = await probeVideo(absPath);
|
|
|
|
console.log("\n=== RAW probeVideo(info) ===\n");
|
|
console.dir(info, { depth: 6 });
|
|
|
|
// Estrazione campi data come nello scanner
|
|
const formatTags = info.format?.tags || {};
|
|
const stream0Tags = info.streams?.[0]?.tags || {};
|
|
const stream1Tags = info.streams?.[1]?.tags || {};
|
|
|
|
const creationFormat = formatTags.creation_time || null;
|
|
const creationStream0 = stream0Tags.creation_time || null;
|
|
const creationStream1 = stream1Tags.creation_time || null;
|
|
|
|
console.log("\n=== DATE CANDIDATE ===");
|
|
console.log("format.tags.creation_time :", creationFormat);
|
|
console.log("streams[0].tags.creation_time:", creationStream0);
|
|
console.log("streams[1].tags.creation_time:", creationStream1);
|
|
|
|
// Simulazione logica attuale dello scanner (ma esplicita)
|
|
let videoDate =
|
|
creationFormat ||
|
|
creationStream0 ||
|
|
creationStream1 ||
|
|
null;
|
|
|
|
console.log("\nScelta videoDate (prima di qualsiasi conversione):", videoDate);
|
|
|
|
if (videoDate) {
|
|
// Variante 1: SENZA conversione (quella che ti ho suggerito)
|
|
const takenAtRaw = videoDate;
|
|
|
|
// Variante 2: CON conversione (quella che ti sballa il giorno)
|
|
const takenAtIso = new Date(videoDate).toISOString();
|
|
|
|
console.log("\n=== CONFRONTO ===");
|
|
console.log("takenAtRaw (usato così com'è) :", takenAtRaw);
|
|
console.log("takenAtIso (new Date().toISOString):", takenAtIso);
|
|
} else {
|
|
console.log("\n⚠ Nessuna data trovata nei tag video.");
|
|
}
|
|
}
|
|
|
|
async function main() {
|
|
const arg = process.argv[2];
|
|
if (!arg) {
|
|
console.error("Uso: node debugVideoDates.js /percorso/al/video.mp4");
|
|
process.exit(1);
|
|
}
|
|
|
|
const absPath = path.resolve(arg);
|
|
await debugVideo(absPath);
|
|
}
|
|
|
|
main().catch(err => {
|
|
console.error("❌ Errore debugVideoDates:", err);
|
|
});
|