1
0

Compare commits

..

No commits in common. "023784cbe437310b3ee979384395be9e5a3a03a4" and "c05c09fb4a3a67a5fe8074abb1fac23bea80512f" have entirely different histories.

4 changed files with 2 additions and 146 deletions

View File

@ -76,6 +76,7 @@ do_add() {
mediainfo --output=JSON --full "${DOSSIER_GLOBAL}${release_name}" > "${DOSSIER_NFO}${release_without_ext}.json" mediainfo --output=JSON --full "${DOSSIER_GLOBAL}${release_name}" > "${DOSSIER_NFO}${release_without_ext}.json"
echo -e "$CYAN""AJOUT DE LA RELEASE ${release_name} DANS LA DATABASE""$NORMAL" echo -e "$CYAN""AJOUT DE LA RELEASE ${release_name} DANS LA DATABASE""$NORMAL"
#sqlite3 "$DB_FILE" "INSERT INTO release (nom, status) VALUES ('${release_name}', 0);"
sqlite3 "$DB_FILE" "BEGIN IMMEDIATE; INSERT INTO release (nom, status) VALUES ('${release_name}', 0); COMMIT;" sqlite3 "$DB_FILE" "BEGIN IMMEDIATE; INSERT INTO release (nom, status) VALUES ('${release_name}', 0); COMMIT;"
else else
echo "il ne s'agit pas d'un fichier mkv ou mp4" echo "il ne s'agit pas d'un fichier mkv ou mp4"
@ -84,28 +85,6 @@ do_add() {
fi fi
} }
do_check() {
release_path="$2"
release_name=$(basename "$release_path")
release_without_ext="${release_name%.*}"
# Récupération de la réponse JSON complète
response=$(curl -s "${URL_API}${APIKEY}&check=${release_without_ext}")
# Extraction du champ "code" avec jq
code=$(echo "$response" | jq -r '.code')
# Extraction du champ "explain" avec jq
explain=$(echo "$response" | jq -r '.Explain')
# Arrêt du script si "code" vaut 1, en affichant le message "explain"
if [ "$code" = "1" ]; then
echo -e "${release_name}" "$ROUGE""$explain""$NORMAL"
else
echo -e "${release_name}" "$BLEU""$explain""$NORMAL"
fi
}
do_status() { do_status() {
checkdb checkdb
@ -195,13 +174,6 @@ case "$1" in
status) status)
do_status do_status
;; ;;
check)
if [ -z "$2" ]; then
echo "Usage: $0 add <release_path>"
exit 1
fi
do_check "$@"
;;
createdb) createdb)
do_createdb do_createdb
;; ;;

View File

@ -164,7 +164,7 @@ _autopost_completion() {
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
# Liste des commandes disponibles # Liste des commandes disponibles
opts="start stop restart show status createdb add log check" opts="start stop restart show status createdb add log"
# Si l'utilisateur est en train de taper le premier argument, proposer les commandes # Si l'utilisateur est en train de taper le premier argument, proposer les commandes
if [ $COMP_CWORD -eq 1 ]; then if [ $COMP_CWORD -eq 1 ]; then

View File

@ -29,12 +29,6 @@ Une fois votre fichier ajouté il sera traité automatiquement.
wget -qO install.sh https://tig.unfr.pw/UNFR/postauto/raw/branch/main/install.sh && chmod +x install.sh && ./install.sh wget -qO install.sh https://tig.unfr.pw/UNFR/postauto/raw/branch/main/install.sh && chmod +x install.sh && ./install.sh
``` ```
#### Update
```sh
wget -qO update.sh https://tig.unfr.pw/UNFR/postauto/raw/branch/main/update.sh && chmod +x update.sh && ./update.sh
```
#### Configuration. #### Configuration.
Éditer le fichier /home/$USER/autopost/conf.sh Éditer le fichier /home/$USER/autopost/conf.sh
```sh ```sh

110
update.sh
View File

@ -1,110 +0,0 @@
#!/bin/bash
# Couleurs de texte
NOIR='\e[30m'
ROUGE='\e[31m'
VERT='\e[32m'
JAUNE='\e[33m'
BLEU='\e[34m'
ROSE='\e[35m'
CYAN='\e[36m'
BLANC='\e[37m'
# Couleurs de fond
FOND_NOIR='\e[40m'
FOND_ROUGE='\e[41m'
FOND_VERT='\e[42m'
FOND_JAUNE='\e[43m'
FOND_BLEU='\e[44m'
FOND_ROSE='\e[45m'
FOND_CYAN='\e[46m'
FOND_BLANC='\e[47m'
# Effets
GRAS='\e[1m'
SOULIGNE='\e[4m'
CLIGNOTANT='\e[5m'
INVERSE='\e[7m'
NORMAL='\e[0m'
#Vérification des prérequis
echo -e "$BLEU""Vérification si les prérequis sont disponibles""$NORMAL"
LISTE_APPLIS="curl basename php"
BIN_DIR="$HOME/bin"
AUTOPOST_DIR="$HOME/autopost"
# Vérifier si le dossier bin existe, sinon le créer
echo -e "$BLEU""Vérification de la présence du dossier bin""$NORMAL"
if [ ! -d "$BIN_DIR" ]; then
mkdir -p "$BIN_DIR"
fi
# Téléchargement et installation du script de post
echo -e "$BLEU""Téléchargement de autopost""$NORMAL"
# Création des répertoires si inexistants
mkdir -p "$AUTOPOST_DIR"
# Télécharger les fichiers dans autopost
wget -q -O "$AUTOPOST_DIR/analyzer.sh" "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"
# Télécharger le fichier dans bin
wget -q -O "$BIN_DIR/postauto" "https://tig.unfr.pw/UNFR/postauto/raw/branch/main/bin/postauto"
# Définir le chemin du fichier bashrc
BASHRC_FILE="$HOME/.bashrc"
# Marqueurs pour identifier la section ajoutée
DEBUT_MARKER="# DEBUT COMPLETION POSTAUTO"
FIN_MARKER="# FIN COMPLETION POSTAUTO"
# Le code de complétion à ajouter, encadré par les marqueurs
read -r -d '' COMPLETION_CODE << 'EOF'
# DEBUT COMPLETION POSTAUTO
# Fonction de complétion pour ton script
_autopost_completion() {
local cur prev opts
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Liste des commandes disponibles
opts="start stop restart show status createdb add log check"
# Si l'utilisateur est en train de taper le premier argument, proposer les commandes
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
# (Optionnel) Pour la sous-commande "add", proposer des fichiers en complétion
if [ $COMP_CWORD -eq 2 ] && [ "${COMP_WORDS[1]}" = "add" ]; then
COMPREPLY=( $(compgen -f -- "${cur}") )
return 0
fi
}
# Associer la fonction de complétion à ton script (ici, 'postauto' est le nom de la commande)
complete -F _autopost_completion postauto
# FIN COMPLETION POSTAUTO
EOF
# Vérifier si le code est déjà présent dans le fichier bashrc
if grep -q "$DEBUT_MARKER" "$BASHRC_FILE"; then
# Faire une sauvegarde de sécurité du fichier .bashrc
cp "$BASHRC_FILE" "${BASHRC_FILE}.bak"
echo "Sauvegarde réalisée dans ${BASHRC_FILE}.bak"
# Supprimer le bloc de code entre les marqueurs (inclusifs)
sed -i "/$DEBUT_MARKER/,/$FIN_MARKER/d" "$BASHRC_FILE"
else
echo "Ajout de la configuration de complétion dans $BASHRC_FILE..."
# Ajouter une ligne vide pour séparer (optionnel)
echo "" >> "$BASHRC_FILE"
# Ajouter le code de complétion
echo "$COMPLETION_CODE" >> "$BASHRC_FILE"
echo "Mise à jour effectuée."
fi
echo "Suppression du script après exécution..."
rm -- "$0