mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-11-22 03:19:53 -08:00
104 lines
3.7 KiB
Bash
Executable File
104 lines
3.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
[ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config"
|
|
|
|
CMD=/usr/local/bin/ani-cli
|
|
DEFAULT_DOWNLOAD="$HOME/Videos/sauce"
|
|
DEFAULT_PLAYLIST="$HOME/Videos/sauce/playlists/playlist.txt"
|
|
CFG_DIR="$XDG_CONFIG_HOME/aniwrapper"
|
|
CFG_FILE="meh.rasi"
|
|
|
|
# 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")
|
|
|
|
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
|
|
# ---------------------------------------------------------------------------
|
|
# 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_DOWNLOAD"
|
|
run -d "$dl_dir"
|
|
elif [[ "$selection" == "3." ]]; then
|
|
# ---------------------------------------------------------------------------
|
|
# continue
|
|
# ---------------------------------------------------------------------------
|
|
run -H
|
|
elif [[ "$selection" == "4." ]]; then
|
|
# ---------------------------------------------------------------------------
|
|
# playlist mode
|
|
# ---------------------------------------------------------------------------
|
|
options="1. Play playlist|2. Add to playlist|3. Delete from playlist|4. Quit"
|
|
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=$(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=$(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
|
|
# -------------------------------------------------------------------
|
|
# watch playlist of 'queued' videos to stream
|
|
# -------------------------------------------------------------------
|
|
run -p
|
|
fi
|
|
elif [[ "$selection" == "2." ]]; then
|
|
# -----------------------------------------------------------------------
|
|
# add to playlist
|
|
# -----------------------------------------------------------------------
|
|
run -a
|
|
elif [[ "$selection" == "3." ]]; then
|
|
# -----------------------------------------------------------------------
|
|
# delete from playlist
|
|
# -----------------------------------------------------------------------
|
|
run -r
|
|
fi
|
|
fi
|