mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-11-22 03:19:53 -08:00
Compare commits
No commits in common. "4af41db0bf360748c91ed5ef2c446349f1f5929f" and "7a3a61bb589375c08b56f55fad14f1086af80922" have entirely different histories.
4af41db0bf
...
7a3a61bb58
123
ani-cli
123
ani-cli
@ -138,54 +138,6 @@ get_video_quality() {
|
|||||||
printf '%s' "$video_link"
|
printf '%s' "$video_link"
|
||||||
}
|
}
|
||||||
|
|
||||||
set_video_quality() {
|
|
||||||
if ((IS_ROFI == 1)); then
|
|
||||||
qualities="1. best|2. 1080p|3. 720p|4. 480p|5. 360p|6. worst"
|
|
||||||
while IFS='|' read -ra quals; do
|
|
||||||
for q in "${quals[@]}"; do
|
|
||||||
if [[ "$(awk '{ print $NF }' <<< "$q")" == "$quality" ]]; then
|
|
||||||
cur_quality="$((${q:0:1} - 1))"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done <<< "$qualities"
|
|
||||||
choice=$(rofi -dmenu -dpi "$DPI" -config "$ROFI_CFG" \
|
|
||||||
-theme-str 'listview {columns: 1;} window {width: 25%;}' \
|
|
||||||
-i -l 6 -no-custom -sep '|' -a "$cur_quality" -mesg "$(generate_span "Current quality: $quality")" \
|
|
||||||
-p "Choose quality:" -window-title 'aniwrapper' -selected-row "$cur_quality" <<< "$qualities")
|
|
||||||
quality=$(awk '{ print $2 }' <<< "$choice")
|
|
||||||
else
|
|
||||||
qualities="best|1080p|720p|480p|360p|worst"
|
|
||||||
prompt "Choose quality [$qualities]"
|
|
||||||
read -r quality
|
|
||||||
while [[ ! "$quality" =~ ($qualities) ]]; do
|
|
||||||
lg "$quality not a valid quality"
|
|
||||||
prompt "Choose quality [$qualities]"
|
|
||||||
read -r quality
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
[ -z "$quality" ] && die "No quality selected"
|
|
||||||
}
|
|
||||||
|
|
||||||
get_dl_dir() {
|
|
||||||
if ((IS_ROFI == 1)); then
|
|
||||||
download_dir=$(
|
|
||||||
rofi -dpi "$DPI" -dmenu -config "$ROFI_CFG" \
|
|
||||||
-theme-str 'listview {columns: 1;} window {width: 45%;}' \
|
|
||||||
-mesg "$(generate_span "Enter the path to the download directory, or leave blank to go with the default: $HOME/Videos/sauce/")" \
|
|
||||||
-l 1 -p "Enter download dir:" -window-title 'aniwrapper'
|
|
||||||
)
|
|
||||||
else
|
|
||||||
prompt "Enter download directory"
|
|
||||||
read -r download_dir
|
|
||||||
fi
|
|
||||||
lg "Download dir: $download_dir"
|
|
||||||
[ -z "$download_dir" ] && download_dir="$HOME/Videos/sauce/"
|
|
||||||
if [ ! -d "$download_dir" ]; then
|
|
||||||
mkdir -p "$download_dir" || die "Error creating directory: $download_dir"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
dep_ch() {
|
dep_ch() {
|
||||||
for dep; do
|
for dep; do
|
||||||
if ! command -v "$dep" > /dev/null; then
|
if ! command -v "$dep" > /dev/null; then
|
||||||
@ -222,19 +174,19 @@ run_stmt() {
|
|||||||
check_db() {
|
check_db() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
directory)
|
directory)
|
||||||
stmt="SELECT COUNT(*) FROM file_history WHERE directory = '$2';"
|
stmt="SELECT DISTINCT COUNT(*) FROM file_history WHERE directory = '$2';"
|
||||||
;;
|
;;
|
||||||
file)
|
file)
|
||||||
stmt="SELECT COUNT(*) FROM file_history WHERE directory = '$2' AND filename = '$3';"
|
stmt="SELECT DISTINCT COUNT(*) FROM file_history WHERE directory = '$2' AND filename = '$3';"
|
||||||
;;
|
;;
|
||||||
search)
|
search)
|
||||||
stmt="SELECT COUNT(*) FROM search_history WHERE anime_name = '$2';"
|
stmt="SELECT DISTINCT COUNT(*) FROM search_history WHERE anime_name = '$2';"
|
||||||
;;
|
;;
|
||||||
watch | sync)
|
watch | sync)
|
||||||
stmt="SELECT COUNT(*) FROM watch_history WHERE anime_name = '$2' AND episode_number = '$3';"
|
stmt="SELECT DISTINCT COUNT(*) FROM watch_history WHERE anime_name = '$2' AND episode_number = '$3';"
|
||||||
;;
|
;;
|
||||||
anime)
|
anime)
|
||||||
stmt="SELECT COUNT(*) FROM anime WHERE anime_name = '$2';"
|
stmt="SELECT DISTINCT COUNT(*) FROM anime WHERE anime_name = '$2';"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
res=$(run_stmt "$stmt")
|
res=$(run_stmt "$stmt")
|
||||||
@ -339,7 +291,7 @@ sync_search_history() {
|
|||||||
fi
|
fi
|
||||||
((++cnt))
|
((++cnt))
|
||||||
fi
|
fi
|
||||||
done < <(sqlite3 -list -noheader "$temp_db" "SELECT * FROM search_history")
|
done < <(sqlite3 -list -noheader "$temp_db" "SELECT DISTINCT * FROM search_history")
|
||||||
lg "$cnt rows inserted into search_history table"
|
lg "$cnt rows inserted into search_history table"
|
||||||
lg "$errs errors on insert"
|
lg "$errs errors on insert"
|
||||||
}
|
}
|
||||||
@ -358,7 +310,7 @@ sync_watch_history() {
|
|||||||
fi
|
fi
|
||||||
((++cnt))
|
((++cnt))
|
||||||
done < <(sqlite3 -list -noheader "$temp_db" "SELECT episode_number, watch_date FROM watch_history WHERE anime_name = '$anime_name'")
|
done < <(sqlite3 -list -noheader "$temp_db" "SELECT episode_number, watch_date FROM watch_history WHERE anime_name = '$anime_name'")
|
||||||
done < <(sqlite3 -list -noheader "$temp_db" "SELECT anime_name FROM watch_history")
|
done < <(sqlite3 -list -noheader "$temp_db" "SELECT DISTINCT anime_name FROM watch_history")
|
||||||
lg "$cnt rows inserted into watch_history table"
|
lg "$cnt rows inserted into watch_history table"
|
||||||
lg "$errs rows skipped on insert"
|
lg "$errs rows skipped on insert"
|
||||||
}
|
}
|
||||||
@ -484,7 +436,7 @@ get_search_query() {
|
|||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ]; then
|
||||||
query="${*// /-}"
|
query="${*// /-}"
|
||||||
elif [ "$IS_ROFI" -eq 1 ]; then
|
elif [ "$IS_ROFI" -eq 1 ]; then
|
||||||
stmt="SELECT id || '. ' || anime_name FROM search_history ORDER BY search_date DESC;"
|
stmt="SELECT DISTINCT id || '. ' || anime_name FROM search_history ORDER BY search_date DESC;"
|
||||||
msg="Choose from list of searched anime below, or enter a unique name of an anime to search for"
|
msg="Choose from list of searched anime below, or enter a unique name of an anime to search for"
|
||||||
query=$(rofi -dpi "$DPI" -dmenu -l 15 -p "Search Anime:" \
|
query=$(rofi -dpi "$DPI" -dmenu -l 15 -p "Search Anime:" \
|
||||||
-mesg "$(generate_span "$msg")" \
|
-mesg "$(generate_span "$msg")" \
|
||||||
@ -597,7 +549,7 @@ episode_selection() {
|
|||||||
ep_choice_start=1
|
ep_choice_start=1
|
||||||
if ((IS_ROFI == 1)); then
|
if ((IS_ROFI == 1)); then
|
||||||
lg "Anime ID: $anime_id"
|
lg "Anime ID: $anime_id"
|
||||||
stmt="SELECT episode_number FROM watch_history WHERE anime_name = '$anime_id';"
|
stmt="SELECT DISTINCT episode_number FROM watch_history WHERE anime_name = '$anime_id';"
|
||||||
|
|
||||||
# Get Watch History for $anime_id as comma separated list
|
# Get Watch History for $anime_id as comma separated list
|
||||||
watch_history=""
|
watch_history=""
|
||||||
@ -841,7 +793,7 @@ main() {
|
|||||||
;;
|
;;
|
||||||
history)
|
history)
|
||||||
BASE_URL="$(curl -s -L -o /dev/null -w "%{url_effective}\n" https://gogoanime.fi)"
|
BASE_URL="$(curl -s -L -o /dev/null -w "%{url_effective}\n" https://gogoanime.fi)"
|
||||||
stmt="SELECT anime_name FROM search_history ORDER BY search_date DESC"
|
stmt="SELECT DISTINCT anime_name FROM search_history ORDER BY search_date DESC"
|
||||||
search_results="$(run_stmt "$stmt")"
|
search_results="$(run_stmt "$stmt")"
|
||||||
[ -z "$search_results" ] && die "History is empty"
|
[ -z "$search_results" ] && die "History is empty"
|
||||||
if ! anime_selection "${search_results[@]}"; then
|
if ! anime_selection "${search_results[@]}"; then
|
||||||
@ -915,14 +867,18 @@ main() {
|
|||||||
choice=''
|
choice=''
|
||||||
while :; do
|
while :; do
|
||||||
inf "Currently playing $selection_id episode" "${episode// /}/$LAST_EP_NUMBER"
|
inf "Currently playing $selection_id episode" "${episode// /}/$LAST_EP_NUMBER"
|
||||||
((episode != LAST_EP_NUMBER)) && menu_line_alternate "next episode" "n"
|
if ((episode != LAST_EP_NUMBER)); then
|
||||||
((episode != FIRST_EP_NUMBER)) && menu_line_alternate "previous episode" "p"
|
menu_line_alternate "next episode" "n"
|
||||||
((FIRST_EP_NUMBER != LAST_EP_NUMBER)) && menu_line_alternate "select episode" "s"
|
fi
|
||||||
|
if ((episode != FIRST_EP_NUMBER)); then
|
||||||
|
menu_line_alternate "previous episode" "p"
|
||||||
|
fi
|
||||||
|
if ((FIRST_EP_NUMBER != LAST_EP_NUMBER)); then
|
||||||
|
menu_line_alternate "select episode" "s"
|
||||||
|
fi
|
||||||
menu_line_alternate "replay current episode" "r"
|
menu_line_alternate "replay current episode" "r"
|
||||||
menu_line_alternate "search for another anime" "a"
|
menu_line_alternate "search for another anime" "a"
|
||||||
menu_line_alternate "download current episode" "d"
|
menu_line_alternate "select quality (current: $quality)" "Q"
|
||||||
menu_line_alternate "download current episode (with quality selection)" "D"
|
|
||||||
menu_line_alternate "select video quality (current: $quality)" "Q"
|
|
||||||
menu_line_strong "exit" "q"
|
menu_line_strong "exit" "q"
|
||||||
prompt "Enter choice"
|
prompt "Enter choice"
|
||||||
read -r choice
|
read -r choice
|
||||||
@ -948,21 +904,34 @@ main() {
|
|||||||
lg "NEW EPISODE: $selection_id - $episode"
|
lg "NEW EPISODE: $selection_id - $episode"
|
||||||
;;
|
;;
|
||||||
Q)
|
Q)
|
||||||
set_video_quality
|
if ((IS_ROFI == 1)); then
|
||||||
|
qualities="1. best|2. 1080p|3. 720p|4. 480p|5. 360p|6. worst"
|
||||||
|
while IFS='|' read -ra quals; do
|
||||||
|
for q in "${quals[@]}"; do
|
||||||
|
if [[ "$(awk '{ print $NF }' <<< "$q")" == "$quality" ]]; then
|
||||||
|
cur_quality="$((${q:0:1} - 1))"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done <<< "$qualities"
|
||||||
|
choice=$(rofi -dmenu -dpi "$DPI" -config "$ROFI_CFG" \
|
||||||
|
-theme-str 'listview {columns: 1;} window {width: 25%;}' \
|
||||||
|
-i -l 6 -no-custom -sep '|' -a "$cur_quality" -mesg "$(generate_span "Current quality: $quality")" \
|
||||||
|
-p "Choose quality:" -window-title 'aniwrapper' -selected-row "$cur_quality" <<< "$qualities")
|
||||||
|
quality=$(awk '{ print $2 }' <<< "$choice")
|
||||||
|
else
|
||||||
|
qualities="best|1080p|720p|480p|360p|worst"
|
||||||
|
prompt "Choose quality [$qualities]"
|
||||||
|
read -r quality
|
||||||
|
while [[ ! "$quality" =~ ($qualities) ]]; do
|
||||||
|
lg "$quality not a valid quality"
|
||||||
|
prompt "Choose quality [$qualities]"
|
||||||
|
read -r quality
|
||||||
|
done
|
||||||
|
fi
|
||||||
episode=$((episode))
|
episode=$((episode))
|
||||||
;;
|
;;
|
||||||
|
|
||||||
d)
|
|
||||||
get_dl_dir
|
|
||||||
is_download=1
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
D)
|
|
||||||
get_dl_dir
|
|
||||||
set_video_quality
|
|
||||||
is_download=1
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
q)
|
q)
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
@ -976,7 +945,7 @@ main() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
dep_ch "$PLAYER_FN" "curl" "sed" "grep" "sqlite3" "rofi" "git" "aria2c" "openssl"
|
dep_ch "$PLAYER_FN" "curl" "sed" "grep" "sqlite3" "rofi" "git" "aria2c"
|
||||||
parse_args "$@"
|
parse_args "$@"
|
||||||
shift $((OPTIND - 1))
|
shift $((OPTIND - 1))
|
||||||
main "$@"
|
main "$@"
|
||||||
|
Loading…
Reference in New Issue
Block a user