From 47df581ba60f761d3697126fc2c5f7d8c1417277 Mon Sep 17 00:00:00 2001 From: ksyasuda Date: Mon, 8 Nov 2021 00:37:24 -0800 Subject: [PATCH] update name of repo and config dir to aniwrapper --- aniwrapper | 96 ++++++++++++++++++++++++++++++++++++------------------ db.sh | 2 +- setup.sh | 2 +- 3 files changed, 67 insertions(+), 33 deletions(-) diff --git a/aniwrapper b/aniwrapper index 459be23..a0a4280 100755 --- a/aniwrapper +++ b/aniwrapper @@ -3,67 +3,101 @@ [ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config" CMD=/usr/local/bin/ani-cli -DEFAULT="$HOME/Videos/sauce/" +DEFAULT_DOWNLOAD="$HOME/Videos/sauce" DEFAULT_PLAYLIST="$HOME/Videos/sauce/playlists/playlist.txt" -CFG_DIR="$XDG_CONFIG_HOME/ani-cli" +CFG_DIR="$XDG_CONFIG_HOME/aniwrapper" CFG_FILE="meh.rasi" -# echo "CONFIG DIR: $CFG_DIR" - -# not a wrapper around the ani-cli-rofi +# printf "%s\n" "CONFIG DIR: $CFG_DIR" options="1. Stream|2. Download|3. Continue|4. Playlist|5. Quit" choice=$(echo "${options[@]}" | rofi -dmenu -sep '|' -config "$CFG_DIR/$CFG_FILE" -l 5 -i -p "Aniwrapper") -[ "$choice" == "5. Quit" ] && ( - echo 'Quitting...' +seppuku() { + printf "%s\n" "$*" + exit 1 +} + +quit() { + printf "%s\n" 'Quitting...' exit 0 -) +} + +run() { + "$CMD" "$*" +} + +[ "$choice" == "5. Quit" ] && quit selection=$(printf "%s\n" "$choice" | awk '{ print $1 }') if [[ "$selection" == "1." ]]; then - echo "STREAMING..." - $CMD + # --------------------------------------------------------------------------- + # streaming + # --------------------------------------------------------------------------- + printf "%s\n" "STREAMING..." + run elif [[ "$selection" == "2." ]]; then + # --------------------------------------------------------------------------- + # download + # --------------------------------------------------------------------------- dl_dir=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \ -l 1 -p "Enter download dir:") # if dl_dir is none set to current directory - [ "$dl_dir" == "" ] && dl_dir="$DEFAULT" - $CMD -d "$dl_dir" + [ "$dl_dir" == "" ] && dl_dir="$DEFAULT_DOWNLOAD" + run -d "$dl_dir" elif [[ "$selection" == "3." ]]; then - $CMD -H + # --------------------------------------------------------------------------- + # continue + # --------------------------------------------------------------------------- + run -H elif [[ "$selection" == "4." ]]; then + # --------------------------------------------------------------------------- + # playlist mode + # --------------------------------------------------------------------------- options="1. Play playlist|2. Add to playlist|3. Delete from playlist|4. Quit" - choice=$(echo "${options[@]}" | rofi -dmenu -sep '|' -config "$CFG_DIR/$CFG_FILE" -l 4 -i -p "Enter choice:") - [ "$choice" == "4. Quit" ] && ( - echo 'Quitting...' - exit 0 - ) + choice=$(printf "%s\n" "${options[@]}" | + rofi -dmenu -sep '|' \ + -config "$CFG_DIR/$CFG_FILE" -l 4 -i -p "Enter choice:") + [ "$choice" == "5. Quit" ] && quit selection=$(printf "%s\n" "$choice" | awk '{ print $1 }') if [[ "$selection" == "1." ]]; then + # ----------------------------------------------------------------------- + # watch playlist + # ----------------------------------------------------------------------- options="1. From file|2. Streaming|3. Quit" - choice=$(echo "${options[@]}" | rofi -dmenu -sep '|' -config "$CFG_DIR/$CFG_FILE" -l 4 -i -p "Enter choice:") - [ "$choice" == "4. Quit" ] && ( - echo 'Quitting...' - exit 0 - ) + choice=$(printf "%s\n" "${options[@]}" | + rofi -dmenu -sep '|' \ + -config "$CFG_DIR/$CFG_FILE" -l 4 -i -p "Enter choice:") + [ "$choice" == "5. Quit" ] && quit selection=$(printf "%s\n" "$choice" | awk '{ print $1 }') if [[ "$selection" == "1." ]]; then + # ------------------------------------------------------------------- + # watch playlist from file (downloaded videos) + # ------------------------------------------------------------------- # TODO: Change directory to variable set at install PLAYLIST_DIR="$HOME/Videos/sauce" - choice=$(ls "$PLAYLIST_DIR" | rofi -dmenu -config "$CFG_DIR/$CFG_FILE" -l 5 -i -p "Choose playlist:") - # choice=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" -l 1 -i -p "Enter path to playlist") - # [ -z "$choice" ] && choice="$HOME/Videos/sauce/" - "$CMD" -P "$PLAYLIST_DIR/$choice" + choice=$(find "$PLAYLIST_DIR" -type d | + rofi -dmenu \ + -config "$CFG_DIR/$CFG_FILE" -l 5 -i -p "Choose playlist:") + [ -z "$choice" ] && + run -P "$PLAYLIST_DIR/$choice" elif [[ "$selection" == "2." ]]; then - "$CMD" -p + # ------------------------------------------------------------------- + # watch playlist of 'queued' videos to stream + # ------------------------------------------------------------------- + run -p fi - # selection=$(printf "%s\n" "$choice" | awk '{ print $1 }') elif [[ "$selection" == "2." ]]; then - "$CMD" -a + # ----------------------------------------------------------------------- + # add to playlist + # ----------------------------------------------------------------------- + run -a elif [[ "$selection" == "3." ]]; then - "$CMD" -r + # ----------------------------------------------------------------------- + # delete from playlist + # ----------------------------------------------------------------------- + run -r fi fi diff --git a/db.sh b/db.sh index 9325b68..9b7b244 100755 --- a/db.sh +++ b/db.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -DIR="$XDG_CONFIG_HOME/ani-cli" +DIR="$XDG_CONFIG_HOME/aniwrapper" DB='history.sqlite3' log() { diff --git a/setup.sh b/setup.sh index bd2c5e2..e33c869 100755 --- a/setup.sh +++ b/setup.sh @@ -15,7 +15,7 @@ if [[ -z "$XDG_CONFIG_HOME" ]]; then XDG_CONFIG_HOME="$HOME/.config" fi -DIR="$XDG_CONFIG_HOME/ani-cli" +DIR="$XDG_CONFIG_HOME/aniwrapper" MPV_DIR="$XDG_CONFIG_HOME/mpv" printf "%s\n" "INSTALL DIR: $DIR"