Compare commits
No commits in common. "13a887bc5e05d6b4cf3c3d0c2804175154466bef" and "ab6695b128c6e75cd02ed2fae24a64a70b4a6a7b" have entirely different histories.
13a887bc5e
...
ab6695b128
@ -69,11 +69,7 @@ while true; do
|
|||||||
echo -e "${JAUNE}VERIF DU NZB${NORMAL}"
|
echo -e "${JAUNE}VERIF DU NZB${NORMAL}"
|
||||||
nzbsizebit=$(bash ${ANALYZER} "${DOSSIER_NZB_ATTENTE}${FILESANSEXT}.nzb" | jq '.Taillebit')
|
nzbsizebit=$(bash ${ANALYZER} "${DOSSIER_NZB_ATTENTE}${FILESANSEXT}.nzb" | jq '.Taillebit')
|
||||||
echo -e "NZB_SIZE : ${nzbsizebit}"
|
echo -e "NZB_SIZE : ${nzbsizebit}"
|
||||||
if [[ "${name}" =~ \.(iso)$ ]]; then
|
jsonsizebit=$(jq -r '.media.track[] | select(."@type" == "General") | .FileSize' "${DOSSIER_NFO}${FILESANSEXT}.json")
|
||||||
jsonsizebit=$(du -b -c "${name}" | grep total | awk '{ print $1 }')
|
|
||||||
else
|
|
||||||
jsonsizebit=$(jq -r '.media.track[] | select(."@type" == "General") | .FileSize' "${DOSSIER_NFO}${FILESANSEXT}.json")
|
|
||||||
fi
|
|
||||||
echo -e "MEDIAINFO_SIZE : ${jsonsizebit}"
|
echo -e "MEDIAINFO_SIZE : ${jsonsizebit}"
|
||||||
|
|
||||||
if [[ ${nzbsizebit} -le ${jsonsizebit} ]] || [[ ${nzbsizebit} = "NAN" ]]; then
|
if [[ ${nzbsizebit} -le ${jsonsizebit} ]] || [[ ${nzbsizebit} = "NAN" ]]; then
|
||||||
|
|||||||
@ -178,7 +178,7 @@ autopostRouter.get('/', async (req, res) => {
|
|||||||
? ' | <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)
|
||||||
? ' | <a href="#" class="mediainfo-link text-blue-400 hover:underline" data-filename="'+row.nom+'">MediaInfo/BDInfo</a>'
|
? ' | <a href="#" class="mediainfo-link text-blue-400 hover:underline" data-filename="'+row.nom+'">Mediainfo</a>'
|
||||||
: '';
|
: '';
|
||||||
let dlLink = row.status === 1
|
let dlLink = row.status === 1
|
||||||
? ` | <a href="/autopost/dl?name=${encodeURIComponent(row.nom)}" class="dl-link text-blue-400 hover:underline">DL</a>`
|
? ` | <a href="/autopost/dl?name=${encodeURIComponent(row.nom)}" class="dl-link text-blue-400 hover:underline">DL</a>`
|
||||||
@ -490,43 +490,21 @@ autopostRouter.get('/mediainfo', (req, res) => {
|
|||||||
if (!filename) {
|
if (!filename) {
|
||||||
return res.status(400).json({ error: "Nom du fichier non spécifié." });
|
return res.status(400).json({ error: "Nom du fichier non spécifié." });
|
||||||
}
|
}
|
||||||
const base = filename.includes('.') ? filename.split('.').slice(0, -1).join('.') : filename;
|
let base = filename.includes('.') ? filename.split('.').slice(0, -1).join('.') : filename;
|
||||||
const jsonPath = path.join(config.infodirectory, base + '.json');
|
const mediainfoFilePath = path.join(config.infodirectory, base + '.json');
|
||||||
const bdinfoPath = path.join(config.infodirectory, base + '.bdinfo.txt');
|
fs.readFile(mediainfoFilePath, 'utf8', (err, data) => {
|
||||||
|
if (err) {
|
||||||
// Vérifie lequel des deux existe, priorité au .json
|
console.error(err.message);
|
||||||
fs.access(jsonPath, fs.constants.F_OK, (errJson) => {
|
return res.status(500).json({ error: "Erreur lors du chargement du fichier mediainfo." });
|
||||||
if (!errJson) {
|
}
|
||||||
// .json existe
|
try {
|
||||||
readAndSend(jsonPath);
|
const obj = JSON.parse(data);
|
||||||
} else {
|
const pretty = JSON.stringify(obj, null, 2);
|
||||||
// .json n'existe pas, on essaie .bdinfo.txt
|
res.json({ content: pretty });
|
||||||
fs.access(bdinfoPath, fs.constants.F_OK, (errBdinfo) => {
|
} catch(e) {
|
||||||
if (!errBdinfo) {
|
res.json({ content: data });
|
||||||
readAndSend(bdinfoPath);
|
|
||||||
} else {
|
|
||||||
res.status(404).json({ error: "Aucun fichier mediainfo trouvé." });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function readAndSend(filePath) {
|
|
||||||
fs.readFile(filePath, 'utf8', (err, data) => {
|
|
||||||
if (err) {
|
|
||||||
console.error(err.message);
|
|
||||||
return res.status(500).json({ error: "Erreur lors du chargement du fichier mediainfo." });
|
|
||||||
}
|
|
||||||
// Essaie de prettifier si JSON
|
|
||||||
try {
|
|
||||||
const obj = JSON.parse(data);
|
|
||||||
const pretty = JSON.stringify(obj, null, 2);
|
|
||||||
res.json({ content: pretty });
|
|
||||||
} catch (e) {
|
|
||||||
res.json({ content: data });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// --------------------------- Download -----------------------------
|
// --------------------------- Download -----------------------------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user