Compare commits

..

No commits in common. "d8b5f2b94a836507999f814d17a4e2872784f903" and "ebc8587e6fbe86fc6e6be8b00081cd2a4458a73f" have entirely different histories.

2 changed files with 35 additions and 47 deletions

35
ani-cli
View File

@ -405,11 +405,9 @@ find_media() {
##################### #####################
get_search_query() { get_search_query() {
if [ $# -gt 0 ]; then stmt="SELECT DISTINCT id || '. ' || anime_name FROM search_history ORDER BY search_date DESC;"
query="${*// /-}" msg="Choose from list of searched anime below, or enter a unique name of an anime to search for"
elif [ "$IS_ROFI" -eq 1 ]; then if [ "$IS_ROFI" -eq 1 ]; then
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"
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")" \
-config "$ROFI_CFG" < <(run_stmt "$stmt")) -config "$ROFI_CFG" < <(run_stmt "$stmt"))
@ -669,17 +667,16 @@ open_episode() {
stream() { stream() {
lg "Running stream()" lg "Running stream()"
if [ "$#" -eq 0 ]; then get_search_query
get_search_query searched=0
else # check if anime has been searched before
get_search_query "$*"
fi
anime_id="${query// /}" anime_id="${query// /}"
[ -z "$anime_id" ] && die "No anime selected or queried" [ -z "$anime_id" ] && die "No anime selected or queried"
searched=0
lg "Checking if anime: $anime_id has been searched before..." lg "Checking if anime: $anime_id has been searched before..."
if check_db "search" "$anime_id"; then check_db "search" "$anime_id"
lg "$anime_id has been searched before" searched="$?"
lg "Searched before: $searched"
if [ "$searched" -eq 0 ]; then
search_results=$(search_anime $query) # want word splitting to account for both input cases search_results=$(search_anime $query) # want word splitting to account for both input cases
[ -z "$search_results" ] && die "No search results found" [ -z "$search_results" ] && die "No search results found"
lg "SEARCH RESULTS: $search_results" lg "SEARCH RESULTS: $search_results"
@ -687,10 +684,12 @@ stream() {
die "No anime selection found" die "No anime selection found"
fi fi
else else
# skip search_anime function and assign $query if previously searched # if the query is a previous search
# skip search_anime function and assign $query
anime_id="${query// /}"
selection_id="$anime_id" selection_id="$anime_id"
insert_history "search" "$anime_id" & insert_history "search" "$anime_id" &
read -r last_ep_number < <(search_eps "$anime_id") read -r last_ep_number <<< "$(search_eps "$selection_id")"
fi fi
episode_selection episode_selection
} }
@ -797,6 +796,7 @@ parse_args() {
;; ;;
esac esac
done done
shift $((OPTIND - 1))
} }
######## ########
@ -806,7 +806,7 @@ main() {
case $scrape in case $scrape in
query) query)
BASE_URL="$(curl -s -L -o /dev/null -w "%{url_effective}\n" https://gogoanime.cm)" BASE_URL="$(curl -s -L -o /dev/null -w "%{url_effective}\n" https://gogoanime.cm)"
stream "$@" stream
;; ;;
history) history)
BASE_URL="$(curl -s -L -o /dev/null -w "%{url_effective}\n" https://gogoanime.cm)" BASE_URL="$(curl -s -L -o /dev/null -w "%{url_effective}\n" https://gogoanime.cm)"
@ -979,5 +979,4 @@ main() {
dep_ch "$player_fn" "curl" "sed" "grep" "sqlite3" "rofi" "git" "aria2c" dep_ch "$player_fn" "curl" "sed" "grep" "sqlite3" "rofi" "git" "aria2c"
parse_args "$@" parse_args "$@"
shift $((OPTIND - 1)) main
main "$@"

View File

@ -73,6 +73,7 @@ run() {
if ((IS_PLAY_FROM_FILE == 0 && GET_QUALITY == 1)); then if ((IS_PLAY_FROM_FILE == 0 && GET_QUALITY == 1)); then
get_quality get_quality
fi fi
if ((SILENT == 1)); then if ((SILENT == 1)); then
if ((IS_CUSTOM_THEME == 0)); then if ((IS_CUSTOM_THEME == 0)); then
"$CMD" -D"$DPI" -Sq "$QUALITY" -t "$theme" "$@" "$CMD" -D"$DPI" -Sq "$QUALITY" -t "$theme" "$@"
@ -217,6 +218,7 @@ parse_args() {
;; ;;
esac esac
done done
} }
check_flags() { check_flags() {
@ -225,7 +227,7 @@ check_flags() {
seppuku "verbose and silent options cannot be used together" seppuku "verbose and silent options cannot be used together"
fi fi
if ((IS_ROFI == 0 && IS_DOWNLOAD == 0)); then if ((IS_ROFI == 0 && IS_DOWNLOAD == 0)); then
run -c "$@" run -c
exit $? exit $?
elif ((IS_ROFI == 0 && IS_DOWNLOAD == 1)); then elif ((IS_ROFI == 0 && IS_DOWNLOAD == 1)); then
printf "%s" "Enter download dir: " printf "%s" "Enter download dir: "
@ -234,33 +236,21 @@ check_flags() {
if [ ! -d "$dl_dir" ]; then if [ ! -d "$dl_dir" ]; then
mkdir -p "$dl_dir" || seppuku "Error creating directory: $dl_dir" mkdir -p "$dl_dir" || seppuku "Error creating directory: $dl_dir"
fi fi
run "-cd $dl_dir" "$@" run "-cd $dl_dir"
exit $? exit $?
elif ((IS_ROFI == 1 && IS_PLAY_FROM_FILE == 1 && IS_CUSTOM_THEME == 1)); then elif ((IS_ROFI == 1 && IS_PLAY_FROM_FILE == 1 && IS_CUSTOM_THEME == 1)); then
run "-f$play_path" -T "$CFG_FILE" "$@" run "-f$play_path" -T "$CFG_FILE"
exit $? exit $?
elif ((IS_ROFI == 1 && IS_PLAY_FROM_FILE == 1 && IS_CUSTOM_THEME == 0)); then elif ((IS_ROFI == 1 && IS_PLAY_FROM_FILE == 1 && IS_CUSTOM_THEME == 0)); then
run "-f$play_path" -t "$theme" "$@" run "-f$play_path" -t "$theme"
exit $? exit $?
fi fi
} }
get_dl_dir() {
dl_dir=$(
rofi -dpi "$DPI" -dmenu -config "$CFG_FILE" \
-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:"
)
# if dl_dir is none set to current directory
[ "$dl_dir" == "" ] && dl_dir="$DEFAULT_DOWNLOAD"
}
######## ########
# Main # # Main #
######## ########
main() { main() {
((SILENT != 1)) && lg "CONFIG DIR: $CFG_DIR"
((SILENT != 1)) && lg "ROFI CFG: $CFG_FILE"
choice=$(echo "${options[@]}" | rofi -dpi "$DPI" -dmenu -only-match -sep '|' \ choice=$(echo "${options[@]}" | rofi -dpi "$DPI" -dmenu -only-match -sep '|' \
-config "$CFG_FILE" -l 7 -i -p "Aniwrapper") -config "$CFG_FILE" -l 7 -i -p "Aniwrapper")
@ -281,7 +271,14 @@ main() {
# download # download
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
lg "Download anime" lg "Download anime"
get_dl_dir && run -d "$dl_dir" dl_dir=$(
rofi -dpi "$DPI" -dmenu -config "$CFG_FILE" \
-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:"
)
# if dl_dir is none set to current directory
[ "$dl_dir" == "" ] && dl_dir="$DEFAULT_DOWNLOAD"
run -d "$dl_dir"
;; ;;
3.) 3.)
@ -351,15 +348,7 @@ main() {
} }
parse_args "$@" parse_args "$@"
shift $((OPTIND - 1)) ((SILENT != 1)) && lg "CONFIG DIR: $CFG_DIR"
if [ $# -gt 0 ]; then ((SILENT != 1)) && lg "ROFI CFG: $CFG_FILE"
check_flags "$*" check_flags
if [ "$IS_DOWNLOAD" -eq 0 ]; then main
run "$*"
elif [ "$IS_DOWNLOAD" -eq 1 ]; then
get_dl_dir && run -d "$dl_dir" "$*"
fi
else
check_flags
main
fi