diff --git a/autopost/analyzer.php b/autopost/analyzer.php
deleted file mode 100644
index e4d6599..0000000
--- a/autopost/analyzer.php
+++ /dev/null
@@ -1,130 +0,0 @@
- pour choisir la méthode d'analyse
-if (strpos($xmlContent, '') !== false) {
- // Analyse via Regex (approche nzbanal.php)
- $rename = '/"(.*?).par2/';
- preg_match($rename, $xmlContent, $matchesname);
- $ngname = $matchesname[1];
-
- if (empty($ngname)) {
- $rename = '/subject="(.*?).par2/';
- preg_match($rename, $xmlContent, $matchesname);
- $ngname = $matchesname[1];
- }
-
- // Récupération du mot de passe
- $repass = '/(.*?)<\/meta>/';
- preg_match($repass, $xmlContent, $matchespass);
- $password = $matchespass[1];
-
- // Récupération de la date
- $redate = '/date="(.*?)"/';
- preg_match($redate, $xmlContent, $matchesdate);
- $update = $matchesdate[1];
- $update = date('d/m/Y', $update);
-
- // Calcul de la taille des fichiers RAR/ISO/MKV/MP4
- $regexsize = '/(rar|iso|mkv|mp4).*\(\d+\/\d+\) (\d+)/';
- preg_match_all($regexsize, $xmlContent, $matchessize, PREG_PATTERN_ORDER, 0);
-
- $filesize = formatBytesnzb(array_sum($matchessize[2]));
-
- // Extraction des groupes
- $regroup = '/(.*?)<\/group>/';
- preg_match_all($regroup, $xmlContent, $matchesgroup, PREG_PATTERN_ORDER, 0);
- $resultgroup = array_unique($matchesgroup[1]);
-
- $GROUP = '';
- $i = '0';
- foreach ($resultgroup as $group) {
- $GROUP .= $group;
- $i++;
- }
-
- // Création de l'objet JSON pour cette approche
- $myObj = new stdClass();
- $myObj->Name = $ngname;
- $myObj->Pass = $password;
- $myObj->Date = $update;
- $myObj->Groupes = $GROUP;
- $myObj->Taille = $filesize;
- $myObj->Taillebit = array_sum($matchessize[2]);
-
- $myJSON = json_encode($myObj);
- echo $myJSON;
-} else {
- // Analyse via XML (approche nzbanal_obs.php)
- $password = 'Aucun';
- $xml = @simplexml_load_string($xmlContent, null, 0, "http://www.newzbin.com/DTD/2003/nzb");
-
- if ($xml === false) {
- die('Erreur lors de l\'analyse du fichier NZB en tant que XML.');
- }
-
- $maxSegmentsFile = null;
- $maxSegmentsCount = 0;
-
- foreach ($xml->file as $file) {
- $fileName = (string)$file->attributes()->subject;
- $fileDate = (string)$file->attributes()->date;
- $fileGroups = [];
- $totalSize = 0;
- $segmentCount = 0;
-
- foreach ($file->groups->group as $group) {
- $fileGroups[] = (string)$group;
- }
-
- foreach ($file->segments->segment as $segment) {
- $segmentSize = (int)$segment->attributes()->bytes;
- $totalSize += $segmentSize;
- $segmentCount++;
- }
-
- if ($segmentCount > $maxSegmentsCount) {
- $maxSegmentsCount = $segmentCount;
- $maxSegmentsFile = [
- 'name' => $fileName,
- 'date' => $fileDate,
- 'groups' => $fileGroups,
- 'total_size' => $totalSize,
- 'segment_count' => $segmentCount
- ];
- }
- }
-
- if ($maxSegmentsFile) {
- $myObj = new stdClass();
- $myObj->Name = $maxSegmentsFile['name'];
- $myObj->Pass = $password;
- $myObj->Date = date('Y-m-d H:i:s', (int)$maxSegmentsFile['date']);
- $myObj->Groupes = implode(', ', $maxSegmentsFile['groups']);
- $myObj->Taille = formatBytesnzb($maxSegmentsFile['total_size']);
- $myObj->Taillebit = $maxSegmentsFile['total_size'];
-
- $myJSON = json_encode($myObj);
- echo $myJSON;
- } else {
- echo "Aucun fichier trouvé dans le NZB.
-";
- }
-}
-?>
diff --git a/autopost/analyzer.sh b/autopost/analyzer.sh
new file mode 100755
index 0000000..11f13b4
--- /dev/null
+++ b/autopost/analyzer.sh
@@ -0,0 +1,73 @@
+#!/bin/bash
+# Vérification de la présence d'un argument
+if [ "$#" -lt 1 ]; then
+ echo "Usage: $0 fichier.nzb" >&2
+ exit 1
+fi
+
+nzbFilePath="$1"
+if [ ! -f "$nzbFilePath" ]; then
+ echo "Fichier NZB non trouvé." >&2
+ exit 1
+fi
+
+# Fonction de formatage de taille en octets (avec unités)
+format_bytes() {
+ size="$1"
+ precision="${2:-2}"
+ if [ "$size" -eq 0 ]; then
+ echo "0"
+ return
+ fi
+ # Calcul avec awk pour afficher la taille en Ko, Mo, Go, etc.
+ awk -v size="$size" -v prec="$precision" 'BEGIN {
+ suffixes[0] = "";
+ suffixes[1] = "Ko";
+ suffixes[2] = "Mo";
+ suffixes[3] = "Go";
+ suffixes[4] = "To";
+ base = log(size)/log(1024);
+ i = int(base);
+ value = exp((base - i)*log(1024));
+ format = "%." prec "f %s";
+ printf format, value, suffixes[i];
+ }'
+}
+
+# Extraction du nom (ngname)
+# On essaie d'abord avec le motif " ... .par2, puis avec subject=" ... .par2
+ngname=$(grep -Po '"\K.*?(?=\.par2)' "$nzbFilePath" | head -n 1)
+if [ -z "$ngname" ]; then
+ ngname=$(grep -Po 'subject="\K.*?(?=\.par2)' "$nzbFilePath" | head -n 1)
+fi
+
+# Extraction du mot de passe
+password=$(grep -Po '\K.*?(?=)' "$nzbFilePath" | head -n 1)
+
+# Extraction de la date (en supposant un timestamp Unix dans l'attribut date)
+timestamp=$(grep -Po 'date="\K\d+' "$nzbFilePath" | head -n 1)
+if [ -n "$timestamp" ]; then
+ # Format "YYYY-MM-DD HH:MM:SS"
+ update=$(date -d @"$timestamp" +"%Y-%m-%d %H:%M:%S")
+else
+ update=""
+fi
+
+# Calcul de la taille totale en additionnant les valeurs des attributs "bytes" de chaque balise
+sizes=$(grep -Po '\K.*?(?=)' "$nzbFilePath")
+GROUP=$(echo "$groups" | sort -u | paste -sd "" -)
+
+# Création de l'objet JSON
+# Attention : cette méthode simple avec printf ne gère pas l'échappement complet des caractères spéciaux
+json=$(printf '{"Name":"%s", "Pass":"%s", "Date":"%s", "Groupes":"%s", "Taille":"%s", "Taillebit":%s}' \
+ "$ngname" "$password" "$update" "$GROUP" "$filesize" "$totalSize")
+
+echo "$json"
diff --git a/autopost/common.sh b/autopost/common.sh
index 395e9e1..aba2f84 100644
--- a/autopost/common.sh
+++ b/autopost/common.sh
@@ -1,6 +1,11 @@
#!/bin/bash
source /home/$USER/autopost/conf.sh
+#CONFIG GLOBAL
+SCREEN_NAME="autopost"
+SCRIPT_PATH="/home/$USER/autopost/posteur.sh"
+ANALYZER="/home/$USER/autopost/analyzer.sh"
+
# Couleurs de texte
NOIR='\e[30m'
ROUGE='\e[31m'
diff --git a/autopost/conf.sh b/autopost/conf.sh
index 392ed7f..a91fc41 100644
--- a/autopost/conf.sh
+++ b/autopost/conf.sh
@@ -9,11 +9,6 @@ DOSSIER_LOGS="/home/$USER/autopost/logs/"
DOSSIER_NZB_ATTENTE="/home/$USER/ATTENTE/"
DOSSIER_NZB_FINAL="/home/$USER/FINIS/"
-#CONFIG GLOBAL
-SCREEN_NAME="autopost"
-SCRIPT_PATH="/home/$USER/autopost/posteur.sh"
-ANALYZER="/home/$USER/autopost/analyzer.php"
-
#CONFIG FOURNISSEUR USENET DE POST
NG_HOST=""
NG_PORT=""
diff --git a/install.sh b/install.sh
index 93af903..dd081d0 100644
--- a/install.sh
+++ b/install.sh
@@ -46,7 +46,7 @@ if command -v mediainfo > /dev/null 2>&1; then
else
echo -e "${ROUGE}mediainfo est manquant. Installation en cours...${NORMAL}"
curl -L -o "$BIN_DIR/mediainfo" "https://mediaarea.net/download/binary/mediainfo/20.09/mediainfo-20.09.glibc2.3-x86_64.AppImage"
- chmod +x "$BIN_DIR/mediainfo"
+ chmod 777 "$BIN_DIR/mediainfo"
LISTE_APPLIS+=("$BIN_DIR/mediainfo")
echo -e "${VERT}mediainfo installé dans $BIN_DIR${NORMAL}"
fi
@@ -61,7 +61,7 @@ else
# Recherche et déplacement du binaire sqlite3 uniquement
find "$BIN_DIR" -type f -name "sqlite3" -exec mv {} "$BIN_DIR/sqlite3" \;
- chmod +x "$BIN_DIR/sqlite3"
+ chmod 777 "$BIN_DIR/sqlite3"
# Nettoyage des fichiers inutiles
rm -rf sqlite-tools.zip "$BIN_DIR/sqlite-tools-linux-x64-3480000" "$BIN_DIR/sqldiff" "$BIN_DIR/sqlite3_analyzer" "$BIN_DIR/sqlite3_rsync"
@@ -76,7 +76,7 @@ if command -v jq > /dev/null 2>&1; then
else
echo -e "${ROUGE}jq est manquant. Installation en cours...${NORMAL}"
curl -L -o "$BIN_DIR/jq" "https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64"
- chmod +x "$BIN_DIR/jq"
+ chmod 777 "$BIN_DIR/jq"
LISTE_APPLIS+=("$BIN_DIR/jq")
echo -e "${VERT}jq installé dans $BIN_DIR${NORMAL}"
fi
@@ -113,7 +113,7 @@ echo -e "$BLEU""Téléchargement de autopost""$NORMAL"
mkdir -p "$AUTOPOST_DIR"
# Télécharger les fichiers dans autopost
-wget -q -O "$AUTOPOST_DIR/analyzer.php" "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/analyzer.php"
+wget -q -O "$AUTOPOST_DIR/analyzer.php" "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/analyzer.sh"
wget -q -O "$AUTOPOST_DIR/common.sh" "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/common.sh"
wget -q -O "$AUTOPOST_DIR/posteur.sh" "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/autopost/posteur.sh"
diff --git a/readme.md b/readme.md
index 88f9909..d4399c5 100644
--- a/readme.md
+++ b/readme.md
@@ -22,7 +22,6 @@ Une fois votre fichier ajouté il sera traité automatiquement.
| ------ | ------ |
| basename | Normalement installé par défaut |
| curl | à installer si nécessaire |
-| php | la version cli est suffisante |
#### Installation.