From 9ac2c8a07bc7f6d7bb16f1b0bff24cda825d2822 Mon Sep 17 00:00:00 2001 From: qo-op Date: Thu, 4 Mar 2021 21:56:36 +0100 Subject: [PATCH] check if TMDB / REFERENCE is a number --- ajouter_video.sh | 7 ++++++- zen/new_file_in_astroport.sh | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ajouter_video.sh b/ajouter_video.sh index 6a73e24..ff595d8 100755 --- a/ajouter_video.sh +++ b/ajouter_video.sh @@ -182,8 +182,13 @@ zenity --question --width 300 --text "IMPORTANT! Nous allons ouvrir le site them [ $? == 1 ] && exit 1 xdg-open "https://www.themoviedb.org/search?query=${FILE_TITLE}" -TMDB=$(zenity --entry --title="Identification TMDB" --text="Indiquez le numéro de la fiche du film. Exemple: https://www.themoviedb.org/movie/301528-toy-story-4 => 301528" --entry-text="") +TMDB=$(zenity --entry --title="Identification TMDB" --text="Indiquez le numéro de la fiche du film. Exemple: 301528 (à extraire du lien https://www.themoviedb.org/movie/301528-toy-story-4)" --entry-text="") [[ $TMDB == "" ]] && exit 1 +if ! [[ "$TMDB" =~ ^[0-9]+$ ]] +then + zenity --warning --width ${large} --text "Vous devez renseigner un numéro! Merci de recommencer..." && exit 1 +fi + # VIDEO TITLE TITLE=$(zenity --entry --width 300 --title "Titre" --text "Indiquez le titre de la vidéo" --entry-text="${FILE_TITLE}") diff --git a/zen/new_file_in_astroport.sh b/zen/new_file_in_astroport.sh index 4ef92eb..67f41c7 100755 --- a/zen/new_file_in_astroport.sh +++ b/zen/new_file_in_astroport.sh @@ -72,7 +72,11 @@ case ${CAT} in film | serie | anime) INDEXPREFIX="TMDB_" REFERENCE=$(echo "$path" | cut -d '/' -f 6 ) # Path contains TMDB id - [ "${REFERENCE}" -ne "${REFERENCE}" ] && echo "ERROR: $path BAD TMDB code. Get it from https://www.themoviedb.org/ " && exit 1 # ${REFERENCE} NOT A NUMBER + if ! [[ "$REFERENCE" =~ ^[0-9]+$ ]] # ${REFERENCE} NOT A NUMBER + then + echo "ERROR: $path BAD TMDB code. Get it from https://www.themoviedb.org/ " + exit 1 + fi ;; *) echo "$CAT inconnu" && exit 1