mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-10-28 04:44:11 -07:00
Merge branch 'master' of github.com:ksyasuda/aniwrapper
This commit is contained in:
commit
7ee540601e
304
ani-cli
304
ani-cli
@ -278,8 +278,10 @@ get_search_query() {
|
|||||||
-config "$CFG_DIR/${ROFI_CFG}")
|
-config "$CFG_DIR/${ROFI_CFG}")
|
||||||
|
|
||||||
# Strip the list entry number from string
|
# Strip the list entry number from string
|
||||||
query="$(awk '{print $NF}' <<<${query//[1-9]+\. /})"
|
# query="$(awk '{print $NF}' <<<${query//[1-9]+\. /})"
|
||||||
|
query="${query//[1-9]*\. /}"
|
||||||
log "Query: $query"
|
log "Query: $query"
|
||||||
|
# [ "$VERBOSE" -eq 1 ] && printf "%s\n" "Query: $query"
|
||||||
else
|
else
|
||||||
query=$*
|
query=$*
|
||||||
fi
|
fi
|
||||||
@ -471,17 +473,17 @@ open_episode() {
|
|||||||
video_url=$(get_links "$dpage_url")
|
video_url=$(get_links "$dpage_url")
|
||||||
|
|
||||||
case $video_url in
|
case $video_url in
|
||||||
*streamtape*)
|
*streamtape*)
|
||||||
# If direct download not available then scrape streamtape.com
|
# If direct download not available then scrape streamtape.com
|
||||||
BROWSER=${BROWSER:-firefox}
|
BROWSER=${BROWSER:-firefox}
|
||||||
printf "scraping streamtape.com\n"
|
printf "scraping streamtape.com\n"
|
||||||
video_url=$(curl -s "$video_url" | sed -n -E '
|
video_url=$(curl -s "$video_url" | sed -n -E '
|
||||||
/^<script>document/{
|
/^<script>document/{
|
||||||
s/^[^"]*"([^"]*)" \+ '\''([^'\'']*).*/https:\1\2\&dl=1/p
|
s/^[^"]*"([^"]*)" \+ '\''([^'\'']*).*/https:\1\2\&dl=1/p
|
||||||
q
|
q
|
||||||
}
|
}
|
||||||
')
|
')
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ $is_download -eq 0 ]; then
|
if [ $is_download -eq 0 ]; then
|
||||||
@ -527,52 +529,52 @@ playlist_remove=0
|
|||||||
playlist_add=0
|
playlist_add=0
|
||||||
while getopts 'hd:Hlpa:P:sv' OPT; do
|
while getopts 'hd:Hlpa:P:sv' OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
h)
|
h)
|
||||||
help_text
|
help_text
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
d)
|
d)
|
||||||
is_download=1
|
is_download=1
|
||||||
download_dir="$OPTARG"
|
download_dir="$OPTARG"
|
||||||
|
|
||||||
if [ "$VERBOSE" -eq 1 ]; then
|
if [ "$VERBOSE" -eq 1 ]; then
|
||||||
printf "%s\n" "DOWNLOAD DIR: $download_dir"
|
printf "%s\n" "DOWNLOAD DIR: $download_dir"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
H)
|
H)
|
||||||
scrape=history
|
scrape=history
|
||||||
;;
|
;;
|
||||||
l)
|
l)
|
||||||
list_history=1
|
list_history=1
|
||||||
;;
|
;;
|
||||||
p)
|
p)
|
||||||
scrape=playlist
|
scrape=playlist
|
||||||
is_playlist=1
|
is_playlist=1
|
||||||
;;
|
;;
|
||||||
a)
|
a)
|
||||||
is_add=1
|
is_add=1
|
||||||
scrape=add
|
scrape=add
|
||||||
playlist_file="${OPTARG/ //}"
|
playlist_file="${OPTARG/ //}"
|
||||||
;;
|
;;
|
||||||
P)
|
P)
|
||||||
is_playlist=1
|
is_playlist=1
|
||||||
# remove spaces from $OPTARG
|
# remove spaces from $OPTARG
|
||||||
playlist_file="${OPTARG/ //}"
|
playlist_file="${OPTARG/ //}"
|
||||||
[ -z "$playlist_file" ] && die "Enter in path to playlist"
|
[ -z "$playlist_file" ] && die "Enter in path to playlist"
|
||||||
log "$playlist_file"
|
log "$playlist_file"
|
||||||
$player_fn "$playlist_file"
|
$player_fn "$playlist_file"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
s)
|
s)
|
||||||
scrape=sync
|
scrape=sync
|
||||||
;;
|
;;
|
||||||
v)
|
v)
|
||||||
VERBOSE=1
|
VERBOSE=1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
printf "%s\n" "Invalid option"
|
printf "%s\n" "Invalid option"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $((OPTIND - 1))
|
shift $((OPTIND - 1))
|
||||||
@ -593,102 +595,102 @@ if [[ "$list_history" -eq 1 ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
case $scrape in
|
case $scrape in
|
||||||
query)
|
query)
|
||||||
|
|
||||||
get_search_query "$*"
|
get_search_query "$*"
|
||||||
search_results=$(search_anime "$query")
|
search_results=$(search_anime "$query")
|
||||||
[ -z "$search_results" ] && die "No search results found"
|
[ -z "$search_results" ] && die "No search results found"
|
||||||
anime_selection "$search_results"
|
anime_selection "$search_results"
|
||||||
[ $? -ne 0 ] && die "No anime selection found"
|
[ $? -ne 0 ] && die "No anime selection found"
|
||||||
episode_selection
|
episode_selection
|
||||||
;;
|
;;
|
||||||
history)
|
history)
|
||||||
stmt="SELECT DISTINCT anime_name FROM watch_history ORDER BY watch_date DESC"
|
stmt="SELECT DISTINCT anime_name FROM watch_history ORDER BY watch_date DESC"
|
||||||
search_results=$(printf "%s\n" "$stmt" | sqlite3 -noheader "$HISTORY_DB")
|
search_results=$(printf "%s\n" "$stmt" | sqlite3 -noheader "$HISTORY_DB")
|
||||||
[ -z "$search_results" ] && die "History is empty"
|
[ -z "$search_results" ] && die "History is empty"
|
||||||
anime_selection "${search_results[@]}"
|
anime_selection "${search_results[@]}"
|
||||||
[ $? -ne 0 ] && die "No anime selection found"
|
[ $? -ne 0 ] && die "No anime selection found"
|
||||||
log "SELECTION: $selection_id"
|
log "SELECTION: $selection_id"
|
||||||
|
|
||||||
stmt="SELECT episode_number \
|
stmt="SELECT episode_number \
|
||||||
FROM watch_history \
|
FROM watch_history \
|
||||||
WHERE anime_name = '$selection_id' \
|
WHERE anime_name = '$selection_id' \
|
||||||
ORDER BY watch_date DESC \
|
ORDER BY watch_date DESC \
|
||||||
LIMIT 1"
|
LIMIT 1"
|
||||||
ep_choice_start=$(run_stmt "$stmt")
|
ep_choice_start=$(run_stmt "$stmt")
|
||||||
log "Most recently watched episode: $ep_choice_start"
|
log "Most recently watched episode: $ep_choice_start"
|
||||||
# search_results=$(sed -n -E 's/\t[0-9]*//p' "$logfile")
|
# search_results=$(sed -n -E 's/\t[0-9]*//p' "$logfile")
|
||||||
# ep_choice_start=$(sed -n -E "s/${selection_id}\t//p" "$logfile")
|
# ep_choice_start=$(sed -n -E "s/${selection_id}\t//p" "$logfile")
|
||||||
;;
|
;;
|
||||||
playlist)
|
playlist)
|
||||||
lines=$(cat "$playlist_file" | wc -l)
|
lines=$(cat "$playlist_file" | wc -l)
|
||||||
[ "$VERBOSE" -eq 1 ] && printf "%s%d\n" "Num lines in playlist: " "$lines"
|
[ "$VERBOSE" -eq 1 ] && printf "%s%d\n" "Num lines in playlist: " "$lines"
|
||||||
if [[ "$lines" -eq 0 ]]; then
|
if [[ "$lines" -eq 0 ]]; then
|
||||||
get_search_query "$*"
|
|
||||||
search_results=$(search_anime "$query")
|
|
||||||
[ -z "$search_results" ] && die "No search results found"
|
|
||||||
anime_selection "$search_results"
|
|
||||||
[ $? -ne 0 ] && die "No anime selection found"
|
|
||||||
episode_selection
|
|
||||||
else
|
|
||||||
line=($(sed '1q;d' "$playlist_file"))
|
|
||||||
if [[ "${#line[@]}" -ne 2 ]]; then
|
|
||||||
die "Something went wrong with the playlist file... exiting"
|
|
||||||
fi
|
|
||||||
selection_id="${line[0]}"
|
|
||||||
episodes=($selection_id)
|
|
||||||
ep_choice_start="${line[1]}"
|
|
||||||
ep_choice_end=""
|
|
||||||
read last_ep_number <<-EOF
|
|
||||||
$(search_eps "$selection_id")
|
|
||||||
EOF
|
|
||||||
[ "$VERBOSE" -eq 1 ] && printf "Anime: %s Episode: %d\n" "$episodes" "$ep_choice_start"
|
|
||||||
[ "$VERBOSE" -eq 1 ] && printf "Episodes: %s\n" "${episodes[@]}"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
add)
|
|
||||||
get_search_query "$*"
|
get_search_query "$*"
|
||||||
search_results=$(search_anime "$query")
|
search_results=$(search_anime "$query")
|
||||||
[ -z "$search_results" ] && die "No search results found"
|
[ -z "$search_results" ] && die "No search results found"
|
||||||
anime_selection "$search_results"
|
anime_selection "$search_results"
|
||||||
[ $? -ne 0 ] && die "No anime selection found"
|
[ $? -ne 0 ] && die "No anime selection found"
|
||||||
episode_selection
|
episode_selection
|
||||||
;;
|
else
|
||||||
sync)
|
line=($(sed '1q;d' "$playlist_file"))
|
||||||
printf "%s" "Enter username for remote user: "
|
if [[ "${#line[@]}" -ne 2 ]]; then
|
||||||
read -r username
|
die "Something went wrong with the playlist file... exiting"
|
||||||
printf "%s" "Enter host for remote user: "
|
|
||||||
read -r host
|
|
||||||
|
|
||||||
# printf "%s" "Enter connection string for remote user in the form user@host: "
|
|
||||||
# read -r connection_str
|
|
||||||
connection_str="$username@$host"
|
|
||||||
printf "%s" "Enter port to connect to remote host with or leave blank for default (22): "
|
|
||||||
read -r port
|
|
||||||
if [[ "${port/ //}" == "" ]]; then
|
|
||||||
PORT=22
|
|
||||||
else
|
|
||||||
PORT="$port"
|
|
||||||
fi
|
fi
|
||||||
|
selection_id="${line[0]}"
|
||||||
|
episodes=($selection_id)
|
||||||
|
ep_choice_start="${line[1]}"
|
||||||
|
ep_choice_end=""
|
||||||
|
read last_ep_number <<-EOF
|
||||||
|
$(search_eps "$selection_id")
|
||||||
|
EOF
|
||||||
|
[ "$VERBOSE" -eq 1 ] && printf "Anime: %s Episode: %d\n" "$episodes" "$ep_choice_start"
|
||||||
|
[ "$VERBOSE" -eq 1 ] && printf "Episodes: %s\n" "${episodes[@]}"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
add)
|
||||||
|
get_search_query "$*"
|
||||||
|
search_results=$(search_anime "$query")
|
||||||
|
[ -z "$search_results" ] && die "No search results found"
|
||||||
|
anime_selection "$search_results"
|
||||||
|
[ $? -ne 0 ] && die "No anime selection found"
|
||||||
|
episode_selection
|
||||||
|
;;
|
||||||
|
sync)
|
||||||
|
printf "%s" "Enter username for remote user: "
|
||||||
|
read -r username
|
||||||
|
printf "%s" "Enter host for remote user: "
|
||||||
|
read -r host
|
||||||
|
|
||||||
printf "%s" "Enter path to private key (leave blank if unsure or not needed): "
|
# printf "%s" "Enter connection string for remote user in the form user@host: "
|
||||||
read -r key_path
|
# read -r connection_str
|
||||||
|
connection_str="$username@$host"
|
||||||
|
printf "%s" "Enter port to connect to remote host with or leave blank for default (22): "
|
||||||
|
read -r port
|
||||||
|
if [[ "${port/ //}" == "" ]]; then
|
||||||
|
PORT=22
|
||||||
|
else
|
||||||
|
PORT="$port"
|
||||||
|
fi
|
||||||
|
|
||||||
printf "%s\n" "Syncing database with: $connection_str on port $PORT"
|
printf "%s" "Enter path to private key (leave blank if unsure or not needed): "
|
||||||
temp_db="/tmp/aniwrapper_tmp_history.sqlite3"
|
read -r key_path
|
||||||
|
|
||||||
if [[ -z "$key_path" ]]; then
|
printf "%s\n" "Syncing database with: $connection_str on port $PORT"
|
||||||
scp -P "$PORT" "$connection_str:$XDG_CONFIG_HOME/aniwrapper/history.sqlite3" "$temp_db"
|
temp_db="/tmp/aniwrapper_tmp_history.sqlite3"
|
||||||
else
|
|
||||||
scp -P "$PORT" -i "$key_path" "$connection_str:$XDG_CONFIG_HOME/aniwrapper/history.sqlite3" "$temp_db"
|
if [[ -z "$key_path" ]]; then
|
||||||
fi
|
scp -P "$PORT" "$connection_str:$XDG_CONFIG_HOME/aniwrapper/history.sqlite3" "$temp_db"
|
||||||
if [[ "$?" -ne 0 ]]; then
|
else
|
||||||
printf "%s\n" "Error getting database file from remote host"
|
scp -P "$PORT" -i "$key_path" "$connection_str:$XDG_CONFIG_HOME/aniwrapper/history.sqlite3" "$temp_db"
|
||||||
exit 1
|
fi
|
||||||
fi
|
if [[ "$?" -ne 0 ]]; then
|
||||||
sync_search_history && sync_watch_history
|
printf "%s\n" "Error getting database file from remote host"
|
||||||
exit 0
|
exit 1
|
||||||
;;
|
fi
|
||||||
|
sync_search_history && sync_watch_history
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
{ # checking input
|
{ # checking input
|
||||||
@ -743,29 +745,29 @@ while :; do
|
|||||||
|
|
||||||
printf "$c_reset"
|
printf "$c_reset"
|
||||||
case $choice in
|
case $choice in
|
||||||
n)
|
n)
|
||||||
episode=$((episode + 1))
|
episode=$((episode + 1))
|
||||||
;;
|
;;
|
||||||
p)
|
p)
|
||||||
episode=$((episode - 1))
|
episode=$((episode - 1))
|
||||||
;;
|
;;
|
||||||
|
|
||||||
s)
|
s)
|
||||||
printf "${c_blue}Choose episode $c_cyan[1-%d]$c_reset:$c_green " $last_ep_number
|
printf "${c_blue}Choose episode $c_cyan[1-%d]$c_reset:$c_green " $last_ep_number
|
||||||
read episode
|
read episode
|
||||||
printf "$c_reset"
|
printf "$c_reset"
|
||||||
[ "$episode" -eq "$episode" ] 2>/dev/null || die "Invalid number entered"
|
[ "$episode" -eq "$episode" ] 2>/dev/null || die "Invalid number entered"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
r) ;;
|
r) ;;
|
||||||
|
|
||||||
q)
|
q)
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
die "invalid choice"
|
die "invalid choice"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
open_episode "$selection_id" "$episode" "$download_dir"
|
open_episode "$selection_id" "$episode" "$download_dir"
|
||||||
done
|
done
|
||||||
|
352
aniwrapper
352
aniwrapper
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config"
|
[ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config"
|
||||||
|
|
||||||
CMD=/usr/local/bin/ani-cli
|
CMD=/usr/bin/ani-cli
|
||||||
DEFAULT_DOWNLOAD="$HOME/Videos/sauce"
|
DEFAULT_DOWNLOAD="$HOME/Videos/sauce"
|
||||||
CFG_DIR="$XDG_CONFIG_HOME/aniwrapper"
|
CFG_DIR="$XDG_CONFIG_HOME/aniwrapper"
|
||||||
DEFAULT_PLAYLIST="$CFG_DIR/playlists/playlist.txt"
|
DEFAULT_PLAYLIST="$CFG_DIR/playlists/playlist.txt"
|
||||||
@ -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,91 +61,76 @@ 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. Play playlist|2. Add to playlist|3. Delete from playlist|4. Quit"
|
options="1. From file|2. Streaming|3. 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
|
# watch playlist from file (downloaded videos)
|
||||||
# ------------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
log "Playlist mode"
|
log "Watching playlist from file"
|
||||||
options="1. From file|2. Streaming|3. Quit"
|
PLAYLIST_DIR="$HOME/Videos/sauce"
|
||||||
choice=$(printf "%s\n" "${options[@]}" |
|
log "Default playlist directory: $PLAYLIST_DIR"
|
||||||
rofi -dmenu -sep '|' \
|
choice=$(cd "$PLAYLIST_DIR" && find . -mindepth 1 -type d |
|
||||||
-config "$CFG_DIR/$CFG_FILE" -l 4 -i -p "Enter choice:")
|
cut -c 3- |
|
||||||
|
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"
|
||||||
[ "$choice" == "$quit" ] && quit
|
log "Choice" "$choice"
|
||||||
log "Selection: $choice"
|
run -P "$PLAYLIST_DIR/$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
|
||||||
# ------------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
# add to playlist
|
# watch playlist of 'queued' videos to stream
|
||||||
# ------------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
log "Add to playlist"
|
log "Watching from 'queue'"
|
||||||
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):")
|
||||||
@ -154,100 +139,115 @@ case "$selection" in
|
|||||||
else
|
else
|
||||||
PLAYLIST_FILE="$DEFAULT_PLAYLIST"
|
PLAYLIST_FILE="$DEFAULT_PLAYLIST"
|
||||||
fi
|
fi
|
||||||
run -a "$PLAYLIST_FILE"
|
run -p
|
||||||
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
|
|
||||||
lines="$lines|$((cnt + 1)). $line"
|
|
||||||
fi
|
|
||||||
((cnt++))
|
|
||||||
done <"$PLAYLIST_FILE"
|
|
||||||
choice=$(rofi -dmenu -l 12 \
|
|
||||||
-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
|
fi
|
||||||
;;
|
elif [[ "$selection" == "2." ]]; then
|
||||||
5.)
|
# ------------------------------------------------------------------
|
||||||
log "Sync history database"
|
# add to playlist
|
||||||
# username=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
|
# ------------------------------------------------------------------
|
||||||
# -l 1 -p "Enter the username of the remote user:")
|
log "Add to playlist"
|
||||||
# if [[ -z "$username" ]] || [[ "$username" == "" ]]; then
|
choice=$(rofi -dmenu \
|
||||||
# log "No username provided... exiting"
|
-config "$CFG_DIR/$CFG_FILE" \
|
||||||
# exit 1
|
-l 1 -p "Enter path to playlist file (or leave blank for default):")
|
||||||
# fi
|
if [[ "$choice" ]]; then
|
||||||
# host=$(rofi -dmenu -config "$CFG_DIR/$CFG_FILE" \
|
PLAYLIST_FILE="$choice"
|
||||||
# -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):")
|
|
||||||
|
|
||||||
printf "%s\n%s\n%d\n%s\n" "sudacode" "sudacode" 3005 "" | ani-cli -s
|
|
||||||
# if [[ -z "$keypath" ]]; then
|
|
||||||
# printf "%s\n%s\n%d\n%s\n" "$username" "$host" "$port" "" | ani-cli -s
|
|
||||||
# else
|
|
||||||
# printf "%s\n%s\n%d\n%s\n" "$username" "$host" "$port" "$keypath" | ani-cli -s
|
|
||||||
# fi
|
|
||||||
if [[ "$?" -ne 0 ]]; then
|
|
||||||
log "Aniwrapper was unable to sync the databases..."
|
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
log "Databases synced successfully"
|
PLAYLIST_FILE="$DEFAULT_PLAYLIST"
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
;;
|
run -a "$PLAYLIST_FILE"
|
||||||
6.)
|
elif [[ "$selection" == "3." ]]; then
|
||||||
# ---------------------------------------------------------------------------
|
# -----------------------------------------------------------------------
|
||||||
# get out
|
# delete from playlist
|
||||||
# ---------------------------------------------------------------------------
|
# -----------------------------------------------------------------------
|
||||||
printf "%s\n" "Quitting..."
|
log "Delete from playlist"
|
||||||
exit 0
|
choice=$(rofi -dmenu \
|
||||||
;;
|
-config "$CFG_DIR/$CFG_FILE" \
|
||||||
*)
|
-l 1 -p "Enter path to playlist file (or leave blank for default):")
|
||||||
log "Invalid choice..."
|
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
|
||||||
|
lines="$lines|$((cnt + 1)). $line"
|
||||||
|
fi
|
||||||
|
((cnt++))
|
||||||
|
done <"$PLAYLIST_FILE"
|
||||||
|
choice=$(rofi -dmenu -l 12 \
|
||||||
|
-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
|
||||||
|
# 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):")
|
||||||
|
|
||||||
|
printf "%s\n%s\n%d\n%s\n" "sudacode" "sudacode" 3005 "" | ani-cli -s
|
||||||
|
# if [[ -z "$keypath" ]]; then
|
||||||
|
# printf "%s\n%s\n%d\n%s\n" "$username" "$host" "$port" "" | ani-cli -s
|
||||||
|
# else
|
||||||
|
# printf "%s\n%s\n%d\n%s\n" "$username" "$host" "$port" "$keypath" | ani-cli -s
|
||||||
|
# fi
|
||||||
|
if [[ "$?" -ne 0 ]]; then
|
||||||
|
log "Aniwrapper was unable to sync the databases..."
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
else
|
||||||
|
log "Databases synced successfully"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
6.)
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# get out
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
printf "%s\n" "Quitting..."
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log "Invalid choice..."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user