mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-11-22 03:19:53 -08:00
update aniwrapper sync to pass verbose option
This commit is contained in:
parent
ee507bd220
commit
78b8dbb3eb
344
aniwrapper
344
aniwrapper
@ -11,16 +11,16 @@ VERBOSE=0
|
|||||||
|
|
||||||
while getopts 'vh' OPT; do
|
while getopts 'vh' OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
h)
|
h)
|
||||||
help_text
|
help_text
|
||||||
;;
|
;;
|
||||||
v)
|
v)
|
||||||
VERBOSE=1
|
VERBOSE=1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
log "Invalid option"
|
log "Invalid option"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -61,76 +61,91 @@ log() {
|
|||||||
selection=$(printf "%s\n" "$choice" | awk '{ print $1 }')
|
selection=$(printf "%s\n" "$choice" | awk '{ print $1 }')
|
||||||
|
|
||||||
case "$selection" in
|
case "$selection" in
|
||||||
1.)
|
1.)
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# streaming
|
# streaming
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
log "Streaming mode"
|
log "Streaming mode"
|
||||||
run
|
run
|
||||||
;;
|
;;
|
||||||
2.)
|
2.)
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# download
|
# download
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
log "Download anime"
|
log "Download anime"
|
||||||
dl_dir=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
|
dl_dir=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
|
||||||
-l 1 -p "Enter download dir:")
|
-l 1 -p "Enter download dir:")
|
||||||
# if dl_dir is none set to current directory
|
# if dl_dir is none set to current directory
|
||||||
[ "$dl_dir" == "" ] && dl_dir="$DEFAULT_DOWNLOAD"
|
[ "$dl_dir" == "" ] && dl_dir="$DEFAULT_DOWNLOAD"
|
||||||
run -d "$dl_dir"
|
run -d "$dl_dir"
|
||||||
;;
|
;;
|
||||||
3.)
|
3.)
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# continue
|
# continue
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
log "Continue watching"
|
log "Continue watching"
|
||||||
run -H
|
run -H
|
||||||
;;
|
;;
|
||||||
4.)
|
4.)
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# playlist mode
|
# playlist mode
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
log "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:")
|
|
||||||
[ -z "$choice" ] && seppuku "No choice selected"
|
|
||||||
[ "$choice" == "$quit" ] && quit
|
|
||||||
selection=$(printf "%s\n" "$choice" | awk '{ print $1 }')
|
|
||||||
if [[ "$selection" == "1." ]]; then
|
|
||||||
# ------------------------------------------------------------------
|
|
||||||
# watch playlist
|
|
||||||
# ------------------------------------------------------------------
|
|
||||||
log "Playlist mode"
|
log "Playlist mode"
|
||||||
options="1. From file|2. Streaming|3. Quit"
|
options="1. Play playlist|2. Add to playlist|3. Delete from playlist|4. Quit"
|
||||||
choice=$(printf "%s\n" "${options[@]}" |
|
choice=$(printf "%s\n" "${options[@]}" |
|
||||||
rofi -dmenu -sep '|' \
|
rofi -dmenu -sep '|' \
|
||||||
-config "$CFG_DIR/$CFG_FILE" -l 4 -i -p "Enter choice:")
|
-config "$CFG_DIR/$CFG_FILE" -l 4 -i -p "Enter choice:")
|
||||||
[ -z "$choice" ] && seppuku "No choice selected"
|
[ -z "$choice" ] && seppuku "No choice selected"
|
||||||
[ "$choice" == "$quit" ] && quit
|
[ "$choice" == "$quit" ] && quit
|
||||||
log "Selection: $choice"
|
|
||||||
selection=$(printf "%s\n" "$choice" | awk '{ print $1 }')
|
selection=$(printf "%s\n" "$choice" | awk '{ print $1 }')
|
||||||
if [[ "$selection" == "1." ]]; then
|
if [[ "$selection" == "1." ]]; then
|
||||||
# --------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# watch playlist from file (downloaded videos)
|
# watch playlist
|
||||||
# --------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
log "Watching playlist from file"
|
log "Playlist mode"
|
||||||
PLAYLIST_DIR="$HOME/Videos/sauce"
|
options="1. From file|2. Streaming|3. Quit"
|
||||||
log "Default playlist directory: $PLAYLIST_DIR"
|
choice=$(printf "%s\n" "${options[@]}" |
|
||||||
choice=$(cd "$PLAYLIST_DIR" && find . -mindepth 1 -type d |
|
rofi -dmenu -sep '|' \
|
||||||
cut -c 3- |
|
-config "$CFG_DIR/$CFG_FILE" -l 4 -i -p "Enter choice:")
|
||||||
rofi -dmenu \
|
|
||||||
-config "$CFG_DIR/$CFG_FILE" -l 5 -i -p "Choose playlist:")
|
|
||||||
[ -z "$choice" ] && seppuku "No choice selected"
|
[ -z "$choice" ] && seppuku "No choice selected"
|
||||||
log "Choice" "$choice"
|
[ "$choice" == "$quit" ] && quit
|
||||||
run -P "$PLAYLIST_DIR/$choice"
|
log "Selection: $choice"
|
||||||
|
selection=$(printf "%s\n" "$choice" | awk '{ print $1 }')
|
||||||
|
if [[ "$selection" == "1." ]]; then
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
# watch playlist from file (downloaded videos)
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
log "Watching playlist from file"
|
||||||
|
PLAYLIST_DIR="$HOME/Videos/sauce"
|
||||||
|
log "Default playlist directory: $PLAYLIST_DIR"
|
||||||
|
choice=$(cd "$PLAYLIST_DIR" && find . -mindepth 1 -type d |
|
||||||
|
cut -c 3- |
|
||||||
|
rofi -dmenu \
|
||||||
|
-config "$CFG_DIR/$CFG_FILE" -l 5 -i -p "Choose playlist:")
|
||||||
|
[ -z "$choice" ] && seppuku "No choice selected"
|
||||||
|
log "Choice" "$choice"
|
||||||
|
run -P "$PLAYLIST_DIR/$choice"
|
||||||
|
elif [[ "$selection" == "2." ]]; then
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
# watch playlist of 'queued' videos to stream
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
log "Watching from 'queue'"
|
||||||
|
choice=$(rofi -dmenu \
|
||||||
|
-config "$CFG_DIR/$CFG_FILE" \
|
||||||
|
-l 1 -p "Enter path to playlist file (or leave blank for default):")
|
||||||
|
if [[ "$choice" ]]; then
|
||||||
|
PLAYLIST_FILE="$choice"
|
||||||
|
else
|
||||||
|
PLAYLIST_FILE="$DEFAULT_PLAYLIST"
|
||||||
|
fi
|
||||||
|
run -p
|
||||||
|
fi
|
||||||
elif [[ "$selection" == "2." ]]; then
|
elif [[ "$selection" == "2." ]]; then
|
||||||
# --------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# watch playlist of 'queued' videos to stream
|
# add to playlist
|
||||||
# --------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
log "Watching from 'queue'"
|
log "Add to playlist"
|
||||||
choice=$(rofi -dmenu \
|
choice=$(rofi -dmenu \
|
||||||
-config "$CFG_DIR/$CFG_FILE" \
|
-config "$CFG_DIR/$CFG_FILE" \
|
||||||
-l 1 -p "Enter path to playlist file (or leave blank for default):")
|
-l 1 -p "Enter path to playlist file (or leave blank for default):")
|
||||||
@ -139,115 +154,102 @@ case "$selection" in
|
|||||||
else
|
else
|
||||||
PLAYLIST_FILE="$DEFAULT_PLAYLIST"
|
PLAYLIST_FILE="$DEFAULT_PLAYLIST"
|
||||||
fi
|
fi
|
||||||
run -p
|
run -a "$PLAYLIST_FILE"
|
||||||
fi
|
elif [[ "$selection" == "3." ]]; then
|
||||||
elif [[ "$selection" == "2." ]]; then
|
# -----------------------------------------------------------------------
|
||||||
# ------------------------------------------------------------------
|
# delete from playlist
|
||||||
# add to playlist
|
# -----------------------------------------------------------------------
|
||||||
# ------------------------------------------------------------------
|
log "Delete from playlist"
|
||||||
log "Add to playlist"
|
choice=$(rofi -dmenu \
|
||||||
choice=$(rofi -dmenu \
|
-config "$CFG_DIR/$CFG_FILE" \
|
||||||
-config "$CFG_DIR/$CFG_FILE" \
|
-l 1 -p "Enter path to playlist file (or leave blank for default):")
|
||||||
-l 1 -p "Enter path to playlist file (or leave blank for default):")
|
if [[ "$choice" ]]; then
|
||||||
if [[ "$choice" ]]; then
|
PLAYLIST_FILE="$choice"
|
||||||
PLAYLIST_FILE="$choice"
|
|
||||||
else
|
|
||||||
PLAYLIST_FILE="$DEFAULT_PLAYLIST"
|
|
||||||
fi
|
|
||||||
run -a "$PLAYLIST_FILE"
|
|
||||||
elif [[ "$selection" == "3." ]]; then
|
|
||||||
# -----------------------------------------------------------------------
|
|
||||||
# delete from playlist
|
|
||||||
# -----------------------------------------------------------------------
|
|
||||||
log "Delete from playlist"
|
|
||||||
choice=$(rofi -dmenu \
|
|
||||||
-config "$CFG_DIR/$CFG_FILE" \
|
|
||||||
-l 1 -p "Enter path to playlist file (or leave blank for default):")
|
|
||||||
if [[ "$choice" ]]; then
|
|
||||||
PLAYLIST_FILE="$choice"
|
|
||||||
else
|
|
||||||
PLAYLIST_FILE="$DEFAULT_PLAYLIST"
|
|
||||||
fi
|
|
||||||
[ "$VERBOSE" -eq 1 ] && log "playlist file: $PLAYLIST_FILE"
|
|
||||||
lines=""
|
|
||||||
cnt=0
|
|
||||||
while read -r line; do
|
|
||||||
if [[ "$cnt" -eq 0 ]]; then
|
|
||||||
lines="$((cnt + 1)). $line"
|
|
||||||
else
|
else
|
||||||
lines="$lines|$((cnt + 1)). $line"
|
PLAYLIST_FILE="$DEFAULT_PLAYLIST"
|
||||||
fi
|
fi
|
||||||
((cnt++))
|
[ "$VERBOSE" -eq 1 ] && log "playlist file: $PLAYLIST_FILE"
|
||||||
done <"$PLAYLIST_FILE"
|
lines=""
|
||||||
choice=$(rofi -dmenu -l 12 \
|
cnt=0
|
||||||
-sep '|' \
|
while read -r line; do
|
||||||
-config "$CFG_DIR/$CFG_FILE" -p "Choose episode to delete:" \
|
if [[ "$cnt" -eq 0 ]]; then
|
||||||
<<<"${lines[*]}")
|
lines="$((cnt + 1)). $line"
|
||||||
log "choice: $choice"
|
else
|
||||||
selection=$(awk '{print $1}' <<<"$choice")
|
lines="$lines|$((cnt + 1)). $line"
|
||||||
idx=${selection//\./}
|
fi
|
||||||
log "index selected: $idx"
|
((cnt++))
|
||||||
log "deleting entry: $idx"
|
done <"$PLAYLIST_FILE"
|
||||||
if [[ -z "$idx" ]]; then
|
choice=$(rofi -dmenu -l 12 \
|
||||||
log "no entry selected"
|
-sep '|' \
|
||||||
|
-config "$CFG_DIR/$CFG_FILE" -p "Choose episode to delete:" \
|
||||||
|
<<<"${lines[*]}")
|
||||||
|
log "choice: $choice"
|
||||||
|
selection=$(awk '{print $1}' <<<"$choice")
|
||||||
|
idx=${selection//\./}
|
||||||
|
log "index selected: $idx"
|
||||||
|
log "deleting entry: $idx"
|
||||||
|
if [[ -z "$idx" ]]; then
|
||||||
|
log "no entry selected"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sed -ie "$idx"d "$PLAYLIST_FILE"
|
||||||
|
if [ "$?" -eq 0 ]; then
|
||||||
|
log "$selection deleted from playlist"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
log "there was a problem deleting $choice"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
5.)
|
||||||
|
log "Sync history database"
|
||||||
|
username=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
|
||||||
|
-l 1 -p "Enter the username of the remote user:")
|
||||||
|
if [[ -z "$username" ]] || [[ "$username" == "" ]]; then
|
||||||
|
log "No username provided... exiting"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
sed -ie "$idx"d "$PLAYLIST_FILE"
|
host=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
|
||||||
if [ "$?" -eq 0 ]; then
|
-l 1 -p "Enter the host for the remote machine (eg 192.168.1.99):")
|
||||||
log "$selection deleted from playlist"
|
if [[ -z "$host" ]] || [[ "$host" == "" ]]; then
|
||||||
exit 0
|
log "No host provided... exiting"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
port=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
|
||||||
|
-l 1 -p "Enter in the ssh port for remote machine or leave blank for default [22]:")
|
||||||
|
if [[ -z "$port" ]] || [[ "$port" == "" ]]; then
|
||||||
|
port=22
|
||||||
|
fi
|
||||||
|
keypath=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
|
||||||
|
-l 1 -p "Enter path to private key (leave blank if not needed or if unsure):")
|
||||||
|
|
||||||
|
if [[ -z "$keypath" ]]; then
|
||||||
|
printf "%s\n%s\n%d\n%s\n" "$username" "$host" "$port" "" | run -s
|
||||||
|
# printf "%s\n%s\n%d\n%s\n" "$username" "$host" "$port" "" | ani-cli -s
|
||||||
else
|
else
|
||||||
log "there was a problem deleting $choice"
|
# printf "%s\n%s\n%d\n%s\n" "$username" "$host" "$port" "$keypath" | ani-cli -s
|
||||||
exit 1
|
printf "%s\n%s\n%d\n%s\n" "$username" "$host" "$port" "$keypath" | run -s
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
;;
|
|
||||||
5.)
|
|
||||||
log "Sync history database"
|
|
||||||
username=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
|
|
||||||
-l 1 -p "Enter the username of the remote user:")
|
|
||||||
if [[ -z "$username" ]] || [[ "$username" == "" ]]; then
|
|
||||||
log "No username provided... exiting"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
host=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
|
|
||||||
-l 1 -p "Enter the host for the remote machine (eg 192.168.1.99):")
|
|
||||||
if [[ -z "$host" ]] || [[ "$host" == "" ]]; then
|
|
||||||
log "No host provided... exiting"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
port=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
|
|
||||||
-l 1 -p "Enter in the ssh port for remote machine or leave blank for default [22]:")
|
|
||||||
if [[ -z "$port" ]] || [[ "$port" == "" ]]; then
|
|
||||||
port=22
|
|
||||||
fi
|
|
||||||
keypath=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
|
|
||||||
-l 1 -p "Enter path to private key (leave blank if not needed or if unsure):")
|
|
||||||
|
|
||||||
if [[ -z "$keypath" ]]; then
|
if [[ "$?" -ne 0 ]]; then
|
||||||
printf "%s\n%s\n%d\n%s\n" "$username" "$host" "$port" "" | ani-cli -s
|
log "Aniwrapper was unable to sync the databases..."
|
||||||
else
|
exit 1
|
||||||
printf "%s\n%s\n%d\n%s\n" "$username" "$host" "$port" "$keypath" | ani-cli -s
|
else
|
||||||
fi
|
log "Databases synced successfully"
|
||||||
|
exit 0
|
||||||
if [[ "$?" -ne 0 ]]; then
|
fi
|
||||||
log "Aniwrapper was unable to sync the databases..."
|
;;
|
||||||
exit 1
|
6.)
|
||||||
else
|
# ---------------------------------------------------------------------------
|
||||||
log "Databases synced successfully"
|
# get out
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
printf "%s\n" "Quitting..."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
;;
|
||||||
;;
|
*)
|
||||||
6.)
|
log "Invalid choice..."
|
||||||
# ---------------------------------------------------------------------------
|
exit 1
|
||||||
# get out
|
;;
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
printf "%s\n" "Quitting..."
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
log "Invalid choice..."
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user