Compare commits

..

No commits in common. "50af29a5bd8a4bbb7c9829d90cc860fe1eb03cf7" and "7c2b547b571e4b03f67656e119006a1198d5b786" have entirely different histories.

2 changed files with 9 additions and 12 deletions

15
ani-cli
View File

@ -1,5 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
BASE_URL=$(curl -s -L -o /dev/null -w "%{url_effective}\n" https://gogoanime.cm)
CFG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/aniwrapper" CFG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/aniwrapper"
HISTORY_DB="$CFG_DIR/history.sqlite3" HISTORY_DB="$CFG_DIR/history.sqlite3"
PLAYER_CMD="mpv" PLAYER_CMD="mpv"
@ -14,6 +15,7 @@ SILENT=0
player_fn="mpv" player_fn="mpv"
playable="\.mp4|\.mkv|\.ts|\.mp3|\.webm" playable="\.mp4|\.mkv|\.ts|\.mp3|\.webm"
playable_list="mp4,mkv,ts,mp3,webm"
prog="ani-cli" prog="ani-cli"
c_red="\033[1;31m" c_red="\033[1;31m"
c_green="\033[1;32m" c_green="\033[1;32m"
@ -334,7 +336,6 @@ get_directory_data() {
[ "$search_dir" = "/" ] && cnt=0 # account for no ../ on / [ "$search_dir" = "/" ] && cnt=0 # account for no ../ on /
for directory in "$1"/*; do for directory in "$1"/*; do
directory="${directory##*/}" directory="${directory##*/}"
[ ! -d "$search_dir/$directory" ] && continue
[ -z "$inputlist" ] && inputlist="$directory" || inputlist="$inputlist|$directory" [ -z "$inputlist" ] && inputlist="$directory" || inputlist="$inputlist|$directory"
if ! check_db "directory" "$search_dir/$directory"; then if ! check_db "directory" "$search_dir/$directory"; then
lg "$search_dir/$directory opened before... adding $cnt to list" 1> /dev/stderr lg "$search_dir/$directory opened before... adding $cnt to list" 1> /dev/stderr
@ -344,8 +345,7 @@ get_directory_data() {
done done
shopt -s nullglob # set nullglob to avoid printing output if no files with extension exist shopt -s nullglob # set nullglob to avoid printing output if no files with extension exist
shopt -s nocaseglob # case insensitive globbing shopt -s nocaseglob # case insensitive globbing
for filename in "$search_dir"/*.{mp4,mkv,ts,mp3,webm}; do for filename in "$1"/*."{$playable_list}"; do
filename="${filename##*/}"
[ -z "$inputlist" ] && inputlist="$filename" || inputlist="$inputlist|$filename" [ -z "$inputlist" ] && inputlist="$filename" || inputlist="$inputlist|$filename"
if ! check_db "file" "$search_dir" "$filename"; then if ! check_db "file" "$search_dir" "$filename"; then
lg "$filename watched before... adding $cnt to list" 1> /dev/stderr lg "$filename watched before... adding $cnt to list" 1> /dev/stderr
@ -355,14 +355,13 @@ get_directory_data() {
done done
shopt -u nullglob shopt -u nullglob
shopt -u nocaseglob shopt -u nocaseglob
lg "INPUTLIST: $inputlist"
if [[ -n "$inputlist" && "$search_dir" != / ]]; then if [[ -n "$inputlist" && "$search_dir" != / ]]; then
inputlist="../|$inputlist|Back|Quit" inputlist="../|$inputlist|Back|Quit"
elif [[ -z "$inputlist" && "$search_dir" != / ]]; then elif [[ -z "$inputlist" && "$search_dir" != / ]]; then
inputlist="../|Back|Quit" inputlist="../|Back|Quit"
elif [[ "$search_dir" = / ]]; then elif [[ "$search_dir" = / ]]; then
inputlist="$inputlist|Back|Quit" inputlist="$inputlist|Back|Quit"
else
inputlist="Quit"
fi fi
lg "INPUT LIST: $inputlist" 1> /dev/stderr lg "INPUT LIST: $inputlist" 1> /dev/stderr
lg "WATCHED LIST: $watched" 1> /dev/stderr lg "WATCHED LIST: $watched" 1> /dev/stderr
@ -690,13 +689,13 @@ open_episode() {
{ {
mkdir -p "$dl_dir" || die "Could not create directory" mkdir -p "$dl_dir" || die "Could not create directory"
if command -v "notify-send" > /dev/null; then if command -v "notify-send" > /dev/null; then
if aria2c -x 16 -s 16 --referer="$dpage_link" "$video_url" --dir="$dl_dir" -o "$episode.mp4" --download-result=hide; then if aria2c --referer="$dpage_link" "$video_url" --dir="$dl_dir" -o "$episode.mp4" --download-result=hide; then
notify-send -i "$ANIWRAPPER_ICON_PATH" "Download complete for ${anime_id//-/ } - Episode: $episode" notify-send -i "$ANIWRAPPER_ICON_PATH" "Download complete for ${anime_id//-/ } - Episode: $episode"
else else
notify-send -i "$MAISAN_ICON_PATH" "Download failed for ${anime_id//-/ } - Episode: $episode. Please retry or check your internet connection" notify-send -i "$MAISAN_ICON_PATH" "Download failed for ${anime_id//-/ } - Episode: $episode. Please retry or check your internet connection"
fi fi
else else
if aria2c -x 16 -s 16 --referer="$dpage_link" "$video_url" --dir="$dl_dir" -o "$episode.mp4" --download-result=hide; then if aria2c --referer="$dpage_link" "$video_url" --dir="$dl_dir" -o "$episode.mp4" --download-result=hide; then
((SILENT != 1)) && printf "${c_green}Downloaded complete for %s - Episode: %s${c_reset}\n" "${anime_id//-/ }" "$episode" ((SILENT != 1)) && printf "${c_green}Downloaded complete for %s - Episode: %s${c_reset}\n" "${anime_id//-/ }" "$episode"
else else
((SILENT != 1)) && printf "${c_red}Download failed for %s - Episode: %s, please retry or check your internet connection${c_reset}\n" "${anime_id//-/ }" "$episode" ((SILENT != 1)) && printf "${c_red}Download failed for %s - Episode: %s, please retry or check your internet connection${c_reset}\n" "${anime_id//-/ }" "$episode"
@ -852,11 +851,9 @@ parse_args() {
main() { main() {
case $scrape in case $scrape in
query) query)
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)
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"

View File

@ -65,7 +65,7 @@ seppuku() {
} }
quit() { quit() {
((SILENT != 1)) && lg 'Quitting...' lg 'Quitting...'
exit 0 exit 0
} }
@ -326,7 +326,7 @@ main() {
} }
parse_args "$@" parse_args "$@"
((SILENT != 1)) && lg "CONFIG DIR: $CFG_DIR" lg "CONFIG DIR: $CFG_DIR"
((SILENT != 1)) && lg "ROFI CFG: $CFG_FILE" lg "ROFI CFG: $CFG_FILE"
check_flags check_flags
main main