update readme and turn off verbose mode

This commit is contained in:
ksyasuda 2021-11-09 00:54:55 -08:00
parent 4b7fccec1c
commit ea63ad4ac8
7 changed files with 178 additions and 126 deletions

View File

@ -4,7 +4,7 @@
[Setup](#setup) | [Usage](#usage) | [Screenshots](#screenshots) [Setup](#setup) | [Usage](#usage) | [Screenshots](#screenshots)
![Aniwrapper screenshot](./screenshots/aniwrapper_home.png) ![Aniwrapper screenshot](./assets/screenshots/aniwrapper_home.png)
</div> </div>
@ -20,11 +20,14 @@
- [Installing](#installing) - [Installing](#installing)
- [Usage](#usage) - [Usage](#usage)
- [aniwrapper](#aniwrapper) - [aniwrapper](#aniwrapper)
- [Option 1: Streaming (Default)](#option-1-streaming-default)
- [ani-cli Script](#ani-cli-script) - [ani-cli Script](#ani-cli-script)
- [Screenshots](#screenshots) - [Screenshots](#screenshots)
<!-- markdown-toc end --> <!-- markdown-toc end -->
---
# Introduction # Introduction
This is a fork of [Dink4n's ani-cli](https://github.com/Dink4n/ani-cli), This is a fork of [Dink4n's ani-cli](https://github.com/Dink4n/ani-cli),
@ -92,6 +95,24 @@ The setup process consists of:
Running `sudo make install` copies the `ani-cli` as well as the `aniwrapper` scripts to `/usr/local/bin/` Running `sudo make install` copies the `ani-cli` as well as the `aniwrapper` scripts to `/usr/local/bin/`
## `aniwrapper` Menus
There are several menus used to drive the program forward
### Search Anime
The first menu consists of a search box and a list of anime titles corresponding to past valid searches. Choose an option from the menu, or enter in a unique search query to search for a new anime. The result from this will be used to query against `gogoanime` and return similar named anime
### Anime Selection
The next menu is where you select the anime to watch from a narrowed down list. Elements that have a blue border and text color indicate which anime have been watched before
- _In the future, I'd like to make it so if you select an option from the list of previously searched anime, then it will skip this and go on to episode selection_
### Episode Selection
In the episode selection menu, you can select an individual episode from the list, provide a single episode, or provide a range of episodes as two space separated integers `start_episode end_episode`. Like in the previous menu, any element with a blue border and text-color indicates that episode has been watched before
# Usage # Usage
## aniwrapper ## aniwrapper
@ -99,6 +120,34 @@ Running `sudo make install` copies the `ani-cli` as well as the `aniwrapper` scr
# Launch aniwrapper menu # Launch aniwrapper menu
aniwrapper aniwrapper
### Option 1: Streaming
<div align="center">
![streaming gif select from menu](./assets/gifs/streaming.gif)
Streaming a previously watched anime
[click here](./assets/gifs/streaming_new.gif) for an example showing streaming a new anime
</div>
Streaming is the default option for the `aniwrapper` script and will prompt you with each of the menus specified in the _[aniwrapper Menus](#aniwrapper-menus)_ section
### Option 2: Download
The default download location is `$HOME/Videos/sauce` and will be chosen as the download directory unless otherwise specified
After specifying the download directory (or leaving it blank for the default), you will be presented with the menus from the _[aniwrapper Menus](#aniwrapper-menus)_ section for selecting the anime and episode(s) to download
### Option 3: Continue
**CURRENTLY BROKEN. WORKING ON FIX**
The continue option queries the `sqlite3` history databse and pulls the list of distinct anime names from the `watch_history` table. Select an option from the list and the most recently watched episode of the selected anime will play
### Option 4: Playlist
_description coming soon_
## ani-cli Script ## ani-cli Script
# watch anime # watch anime
@ -133,9 +182,9 @@ This would open/download episodes 1 2 3 4 5 6
<div align="center"> <div align="center">
Aniwrapper Main Menu Aniwrapper Main Menu
![aniwrapper frontpage](./screenshots/aniwrapper_home.png) ![aniwrapper frontpage](./assets/screenshots/aniwrapper_home.png)
Aniwrapper Streaming Menu Aniwrapper Streaming Menu
![aniwrapper streaming options](./screenshots/aniwrapper_stream.png) ![aniwrapper streaming options](./assets/screenshots/aniwrapper_stream.png)
More to come soon... maybe More to come soon... maybe
</div> </div>

246
ani-cli
View File

@ -5,6 +5,8 @@ if [[ -z "$XDG_CONFIG_HOME" ]]; then
XDG_CONFIG_HOME="$HOME/.config" XDG_CONFIG_HOME="$HOME/.config"
fi fi
VERBOSE=0
BASE_URL="https://gogoanime.cm" BASE_URL="https://gogoanime.cm"
CFG_DIR="$XDG_CONFIG_HOME/aniwrapper" CFG_DIR="$XDG_CONFIG_HOME/aniwrapper"
ROFI_CFG="meh.rasi" ROFI_CFG="meh.rasi"
@ -26,8 +28,6 @@ c_magenta="\033[1;35m"
c_cyan="\033[1;36m" c_cyan="\033[1;36m"
c_reset="\033[0m" c_reset="\033[0m"
VERBOSE=1
help_text() { help_text() {
while IFS= read line; do while IFS= read line; do
printf "%s\n" "$line" printf "%s\n" "$line"
@ -107,7 +107,8 @@ check_anime_name() {
# Check to make sure passed in name is not empty # Check to make sure passed in name is not empty
[ "$VERBOSE" -eq 1 ] && printf "%s\n" "VAR: $1" [ "$VERBOSE" -eq 1 ] && printf "%s\n" "VAR: $1"
if [[ "$1" == "" ]] || [[ "$1" == " " ]] || [[ "$1" == "\n" ]]; then if [[ "$1" == "" ]] || [[ "$1" == " " ]] || [[ "$1" == "\n" ]]; then
printf "%s\n" "Passed in name is null" [ "$VERBOSE" -eq 1 ] &&
printf "%s\n" "Passed in name is nothing"
return 1 return 1
fi fi
return 0 return 0
@ -156,16 +157,19 @@ insert_history() {
# check the anime_name/id # check the anime_name/id
check_anime_name "$1" check_anime_name "$1"
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
printf "%s\n" "ERROR: Anime name is none... exiting" [ "$VERBOSE" -eq 1 ] &&
printf "%s\n" "ERROR: Anime name is none... exiting"
return 1 return 1
fi fi
datetime=$(date +'%Y-%m-%d %H:%M:%S') datetime=$(date +'%Y-%m-%d %H:%M:%S')
check_db "$@" check_db "$@"
if [[ $? -gt 0 ]]; then if [[ $? -gt 0 ]]; then
if [[ "$2" == "search" ]]; then if [[ "$2" == "search" ]]; then
printf "%s\n" "Already in search db... Updating search_date" [ "$VERBOSE" -eq 1 ] &&
printf "%s\n" "Already in search db... Updating search_date"
else else
printf "%s\n" "Already in search db... Updating watch_date" [ "$VERBOSE" -eq 1 ] &&
printf "%s\n" "Already in search db... Updating watch_date"
fi fi
update_date "$@" update_date "$@"
else else
@ -257,7 +261,7 @@ anime_selection() {
fi fi
done done
printf "%s\n" "SEARCHED: $searched" [ "$VERBOSE" -eq 1 ] && printf "%s\n" "SEARCHED: $searched"
# get the anime from indexed list # get the anime from indexed list
user_input=$(printf "${menu[@]}" | user_input=$(printf "${menu[@]}" |
@ -312,9 +316,9 @@ anime_selection() {
episode_selection() { episode_selection() {
# select episode number for anime # select episode number for anime
[ $is_download -eq 1 ] && [ "$is_download" -eq 1 ] &&
printf "Range of episodes can be specified: start_number end_number\n" printf "Range of episodes can be specified: start_number end_number\n"
printf "%s\n" "Anime ID: $anime_id" [ "$VERBOSE" -eq 1 ] && printf "%s\n" "Anime ID: $anime_id"
stmt="SELECT DISTINCT episode_number \ stmt="SELECT DISTINCT episode_number \
FROM watch_history \ FROM watch_history \
WHERE anime_name = '$anime_id';" WHERE anime_name = '$anime_id';"
@ -395,17 +399,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
@ -452,45 +456,45 @@ playlist_add=0
playlist_file="$CFG_DIR/playlists/playlist.txt" playlist_file="$CFG_DIR/playlists/playlist.txt"
while getopts 'hd:HlpadP:' OPT; do while getopts 'hd:HlpadP:' 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
echo "DOWNLOAD DIR: $download_dir" echo "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
;; ;;
d) d)
is_delete=1 is_delete=1
scrape=delete scrape=delete
;; ;;
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"
[ "$VERBOSE" -eq 1 ] && printf "%s\n" "$playlist_file" [ "$VERBOSE" -eq 1 ] && printf "%s\n" "$playlist_file"
$player_fn "$playlist_file" $player_fn "$playlist_file"
exit 0 exit 0
;; ;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
@ -511,63 +515,63 @@ if [[ "$list_history" -eq 1 ]]; then
fi fi
case $scrape in case $scrape in
query) query)
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
;;
history)
# search_results=$(sed -n -E 's/\t[0-9]*//p' "$logfile")
stmt="SELECT DISTINCT anime_name FROM watch_history ORDER BY watch_date DESC"
search_results=$(printf "%s\n" "$stmt" | sqlite3 -noheader "$HISTORY_DB")
[ -z "$search_results" ] && die "History is empty"
anime_selection "${search_results[@]}"
[ $? -ne 0 ] && die "No anime selection found"
stmt="SELECT episode_number FROM watch_history ORDER BY watch_date DESC LIMIT 1"
run_stmt "$stmt"
ep_choice_start=$?
echo "EPISODE: $ep_choice_start"
# ep_choice_start=$(sed -n -E "s/${selection_id}\t//p" "$logfile")
;;
playlist)
lines=$(cat "$playlist_file" | wc -l)
[ "$VERBOSE" -eq 1 ] && printf "%s%d\n" "Num lines in playlist: " "$lines"
if [[ "$lines" -eq 0 ]]; then
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
history) line=($(sed '1q;d' "$playlist_file"))
# search_results=$(sed -n -E 's/\t[0-9]*//p' "$logfile") if [[ "${#line[@]}" -ne 2 ]]; then
stmt="SELECT DISTINCT anime_name FROM watch_history ORDER BY watch_date DESC" die "Something went wrong with the playlist file... exiting"
search_results=$(printf "%s\n" "$stmt" | sqlite3 -noheader "$HISTORY_DB")
[ -z "$search_results" ] && die "History is empty"
anime_selection "${search_results[@]}"
[ $? -ne 0 ] && die "No anime selection found"
stmt="SELECT episode_number FROM watch_history ORDER BY watch_date DESC LIMIT 1"
run_stmt "$stmt"
ep_choice_start=$?
echo "EPISODE: $ep_choice_start"
# ep_choice_start=$(sed -n -E "s/${selection_id}\t//p" "$logfile")
;;
playlist)
lines=$(cat "$playlist_file" | wc -l)
[ "$VERBOSE" -eq 1 ] && printf "%s%d\n" "Num lines in playlist: " "$lines"
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 fi
;; selection_id="${line[0]}"
add) episodes=($selection_id)
get_search_query "$*" ep_choice_start="${line[1]}"
search_results=$(search_anime "$query") ep_choice_end=""
[ -z "$search_results" ] && die "No search results found" read last_ep_number <<-EOF
anime_selection "$search_results" $(search_eps "$selection_id")
[ $? -ne 0 ] && die "No anime selection found" EOF
episode_selection [ "$VERBOSE" -eq 1 ] && printf "Anime: %s Episode: %d\n" "$episodes" "$ep_choice_start"
;; [ "$VERBOSE" -eq 1 ] && printf "Episodes: %s\n" "${episodes[@]}"
delete) ;; 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
;;
delete) ;;
esac esac
@ -618,29 +622,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

View File

@ -7,7 +7,7 @@ DEFAULT_DOWNLOAD="$HOME/Videos/sauce"
DEFAULT_PLAYLIST="$HOME/Videos/sauce/playlists/playlist.txt" DEFAULT_PLAYLIST="$HOME/Videos/sauce/playlists/playlist.txt"
CFG_DIR="$XDG_CONFIG_HOME/aniwrapper" CFG_DIR="$XDG_CONFIG_HOME/aniwrapper"
CFG_FILE="meh.rasi" CFG_FILE="meh.rasi"
VERBOSE=1 VERBOSE=0
# printf "%s\n" "CONFIG DIR: $CFG_DIR" # printf "%s\n" "CONFIG DIR: $CFG_DIR"
@ -44,7 +44,6 @@ if [[ "$selection" == "1." ]]; then
# streaming # streaming
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
log "Streaming mode" log "Streaming mode"
printf "%s\n" "STREAMING..."
run run
elif [[ "$selection" == "2." ]]; then elif [[ "$selection" == "2." ]]; then
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------

BIN
assets/gifs/streaming.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 MiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB