From 0b72c296bfbabdd36b00509e7d259a438b062370 Mon Sep 17 00:00:00 2001 From: ksyasuda Date: Thu, 30 Dec 2021 21:58:02 -0800 Subject: [PATCH] add check for notify-send in download function if notify-send not installed, prints to stdout. Makes it so aniwrapper can be run in command-line mode on servers without a display (or notification) server running --- ani-cli | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ani-cli b/ani-cli index d47c009..3a0d4e2 100755 --- a/ani-cli +++ b/ani-cli @@ -536,9 +536,15 @@ open_episode() { mkdir -p "$anime_id" || die "Could not create directory" cd "$anime_id" || die "Could not enter subdirectory $ddir/$anime_id" # ffmpeg -i "$play_link" -c copy "${anime_id}-${episode}.mkv" >/dev/null 2>&1 && - ffmpeg -i "$play_link" -c copy "${episode}.mkv" >/dev/null 2>&1 && - notify-send -i "$ANIWRAPPER_ICON_PATH" "Download complete for ${anime_id//-/ } - Episode: $episode" || - notify-send -i "$MAISAN_ICON_PATH" "Download failed for ${anime_id//-/ } - Episode: $episode. Please retry or check your internet connection" + if command -v "notify-send" >/dev/null; then + ffmpeg -i "$play_link" -c copy "${episode}.mkv" >/dev/null 2>&1 && + notify-send -i "$ANIWRAPPER_ICON_PATH" "Download complete for ${anime_id//-/ } - Episode: $episode" || + notify-send -i "$MAISAN_ICON_PATH" "Download failed for ${anime_id//-/ } - Episode: $episode. Please retry or check your internet connection" + else + ffmpeg -i "$play_link" -c copy "${episode}.mkv" >/dev/null 2>&1 && + printf "${c_green}Downloaded complete for %s - Episode: %s${c_reset}\n" "${anime_id//-/ }" "$episode" || + printf "${c_red}Download failed for %s - Episode: %s, please retry or check your internet connection${c_reset}\n" "${anime_id//-/ }" "$episode" + fi # printf "${c_green}Downloaded episode: %s${c_reset}\n" "$episode" || # printf "${c_red}Download failed episode: %s , please retry or check your internet connection${c_reset}\n" "$episode" }