mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-11-22 03:19:53 -08:00
update readme and fix handling of multiword vs selected search query
This commit is contained in:
parent
bc58d1677a
commit
7b03f71130
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
[**_Setup_**](#setup) | [**_Usage_**](#usage) | [**_Screenshots_**](#screenshots)
|
[**_Setup_**](#setup) | [**_Usage_**](#usage) | [**_Screenshots_**](#screenshots)
|
||||||
|
|
||||||
![Aniwrapper screenshot](https://imgur.com/bhea2u3.png)
|
![Aniwrapper screenshot](https://imgur.com/ZAmoEUA.png)
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -146,8 +146,6 @@ The first menu consists of a search box and a list of anime titles corresponding
|
|||||||
|
|
||||||
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
|
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
|
## 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
|
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
|
||||||
@ -175,7 +173,6 @@ In the episode selection menu, you can select an individual episode from the lis
|
|||||||
# ex. The following command will launch aniwrapper in command-line download mode with quality selection
|
# ex. The following command will launch aniwrapper in command-line download mode with quality selection
|
||||||
aniwrapper -cqd
|
aniwrapper -cqd
|
||||||
|
|
||||||
|
|
||||||
### Option 1: Streaming
|
### Option 1: Streaming
|
||||||
|
|
||||||
- [click here](https://imgur.com/nLjqLCL.gif) for an example showing streaming a new anime
|
- [click here](https://imgur.com/nLjqLCL.gif) for an example showing streaming a new anime
|
||||||
@ -244,7 +241,7 @@ 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](https://imgur.com/bhea2u3.png)
|
![aniwrapper frontpage](https://imgur.com/ZAmoEUA.png)
|
||||||
Aniwrapper Streaming Menu
|
Aniwrapper Streaming Menu
|
||||||
![aniwrapper streaming options](https://imgur.com/jVJQERk.png)
|
![aniwrapper streaming options](https://imgur.com/jVJQERk.png)
|
||||||
More to come soon... maybe
|
More to come soon... maybe
|
||||||
|
74
ani-cli
74
ani-cli
@ -58,7 +58,14 @@ log() {
|
|||||||
|
|
||||||
search_anime() {
|
search_anime() {
|
||||||
# get anime name along with its id
|
# get anime name along with its id
|
||||||
search=${1// /-}
|
log "NUM ARGS: $#"
|
||||||
|
if [[ $# -gt 1 ]]; then
|
||||||
|
search="$*"
|
||||||
|
search="${search// /-}"
|
||||||
|
else
|
||||||
|
search="$1"
|
||||||
|
fi
|
||||||
|
# search=${1// /-}
|
||||||
log "Search Query: $search"
|
log "Search Query: $search"
|
||||||
titlepattern='<a href="/category/'
|
titlepattern='<a href="/category/'
|
||||||
curl -s "$BASE_URL//search.html" \
|
curl -s "$BASE_URL//search.html" \
|
||||||
@ -161,8 +168,11 @@ run_stmt() {
|
|||||||
## Database Code ##
|
## Database Code ##
|
||||||
#####################
|
#####################
|
||||||
|
|
||||||
# Return number of matches for anime/episode in db
|
|
||||||
check_db() {
|
check_db() {
|
||||||
|
# Return number of matches for anime/episode in db
|
||||||
|
# args:
|
||||||
|
# $1: anime name: str
|
||||||
|
# $2: either 'search' or 'watch' for which db to query
|
||||||
if [[ "$2" == "search" ]]; then
|
if [[ "$2" == "search" ]]; then
|
||||||
stmt="SELECT DISTINCT COUNT(*) \
|
stmt="SELECT DISTINCT COUNT(*) \
|
||||||
FROM search_history \
|
FROM search_history \
|
||||||
@ -230,16 +240,16 @@ sync_search_history() {
|
|||||||
cnt=0
|
cnt=0
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
anime_name=$(awk -F '|' '{print $2}' <<<"$line")
|
anime_name=$(awk -F '|' '{print $2}' <<<"$line")
|
||||||
res=$(sqlite3 -noheader "$HISTORY_DB" <<<"SELECT anime_name FROM search_history WHERE anime_name = '$anime_name'")
|
res=$(sqlite3 -noheader "$HISTORY_DB" "SELECT COUNT(*) FROM search_history WHERE anime_name = '$anime_name'")
|
||||||
if [[ "${res/ //}" == "" ]]; then
|
if [[ "$res" -eq 0 ]]; then
|
||||||
search_date=$(awk -F '|' '{print $3}' <<<"$line")
|
search_date=$(awk -F '|' '{print $3}' <<<"$line")
|
||||||
log "Adding ($anime_name|$search_date) to search history..."
|
log "Adding ($anime_name|$search_date) to search history..."
|
||||||
if ! sqlite3 "$HISTORY_DB" <<<"INSERT INTO search_history(anime_name, search_date) VALUES('$anime_name', '$search_date')"; then
|
if ! sqlite3 "$HISTORY_DB" "INSERT INTO search_history(anime_name, search_date) VALUES('$anime_name', '$search_date')"; then
|
||||||
err "Error inserting row $line"
|
err "Error inserting row $line"
|
||||||
fi
|
fi
|
||||||
((++cnt))
|
((++cnt))
|
||||||
fi
|
fi
|
||||||
done <<<"$(sqlite3 -noheader "$temp_db" <<<"SELECT DISTINCT * FROM search_history")"
|
done <<<"$(sqlite3 -noheader "$temp_db" "SELECT DISTINCT * FROM search_history")"
|
||||||
log "Inserted $cnt rows into search_history table"
|
log "Inserted $cnt rows into search_history table"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +259,7 @@ sync_watch_history() {
|
|||||||
# anime_name=$(awk -F '|' '{print $2}' <<<"$line")
|
# anime_name=$(awk -F '|' '{print $2}' <<<"$line")
|
||||||
anime_name="${line/ //}"
|
anime_name="${line/ //}"
|
||||||
log "ANIME: $anime_name"
|
log "ANIME: $anime_name"
|
||||||
episodes=$(sqlite3 -noheader "$temp_db" <<<"SELECT episode_number, watch_date FROM watch_history WHERE anime_name = '$anime_name'")
|
episodes=$(sqlite3 -noheader "$temp_db" "SELECT episode_number, watch_date FROM watch_history WHERE anime_name = '$anime_name'")
|
||||||
# for each episode of $anime_name on the remote machine, check local
|
# for each episode of $anime_name on the remote machine, check local
|
||||||
while read -r ep; do
|
while read -r ep; do
|
||||||
episode_num=$(awk -F '|' '{print $1}' <<<"$ep")
|
episode_num=$(awk -F '|' '{print $1}' <<<"$ep")
|
||||||
@ -261,7 +271,7 @@ sync_watch_history() {
|
|||||||
log "NOT IN DB"
|
log "NOT IN DB"
|
||||||
watch_date=$(awk -F '|' '{print $NF}' <<<"$ep")
|
watch_date=$(awk -F '|' '{print $NF}' <<<"$ep")
|
||||||
log "Adding ($anime_name|$episode_num|$watch_date) to watch history..."
|
log "Adding ($anime_name|$episode_num|$watch_date) to watch history..."
|
||||||
if ! sqlite3 "$HISTORY_DB" <<<"INSERT INTO watch_history(anime_name, episode_number, watch_date) VALUES('$anime_name', '$episode_num', '$watch_date')"; then
|
if ! sqlite3 "$HISTORY_DB" "INSERT INTO watch_history(anime_name, episode_number, watch_date) VALUES('$anime_name', '$episode_num', '$watch_date')"; then
|
||||||
err "Error inserting row $ep"
|
err "Error inserting row $ep"
|
||||||
fi
|
fi
|
||||||
((++cnt))
|
((++cnt))
|
||||||
@ -269,7 +279,7 @@ sync_watch_history() {
|
|||||||
log "Episode: $episode_num found in the db... skipping"
|
log "Episode: $episode_num found in the db... skipping"
|
||||||
fi
|
fi
|
||||||
done <<<"${episodes[@]}"
|
done <<<"${episodes[@]}"
|
||||||
done <<<"$(sqlite3 -noheader "$temp_db" <<<"SELECT DISTINCT anime_name FROM watch_history")"
|
done <<<"$(sqlite3 -noheader "$temp_db" "SELECT DISTINCT anime_name FROM watch_history")"
|
||||||
log "Inserted $cnt rows into watch_history table"
|
log "Inserted $cnt rows into watch_history table"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,11 +301,9 @@ get_search_query() {
|
|||||||
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"
|
||||||
span="<span foreground='peachpuff' style='italic' size='small' weight='light'>$msg</span>"
|
span="<span foreground='peachpuff' style='italic' size='small' weight='light'>$msg</span>"
|
||||||
if [ -z "$*" ] && [ "$is_rofi" -eq 1 ]; then
|
if [ -z "$*" ] && [ "$is_rofi" -eq 1 ]; then
|
||||||
query=$(printf "%s\n" "${hist[@]}" |
|
query=$(rofi -dmenu -l 12 -p "Search Anime:" \
|
||||||
rofi -dmenu -l 12 -p "Search Anime:" \
|
|
||||||
-mesg "$span" \
|
-mesg "$span" \
|
||||||
-config "$CFG_DIR/${ROFI_CFG}")
|
-config "$CFG_DIR/${ROFI_CFG}" <<< "${hist[@]}")
|
||||||
|
|
||||||
# Remove the id from the query
|
# Remove the id from the query
|
||||||
query="${query//[1-9]*\. /}"
|
query="${query//[1-9]*\. /}"
|
||||||
# fixes '-' at end of selected anime, but removes spaces from queries
|
# fixes '-' at end of selected anime, but removes spaces from queries
|
||||||
@ -363,28 +371,26 @@ anime_selection() {
|
|||||||
choice="${choice::-1}"
|
choice="${choice::-1}"
|
||||||
name=$(printf '%s\n' "$user_input" | awk '{print $NF}')
|
name=$(printf '%s\n' "$user_input" | awk '{print $NF}')
|
||||||
else
|
else
|
||||||
menu_format_string='[%d] %s\n'
|
menu_format_string='[%d] %s\n'
|
||||||
menu_format_string_c1="$c_blue[$c_cyan%d$c_blue] $c_reset%s\n"
|
menu_format_string_c1="$c_blue[$c_cyan%d$c_blue] $c_reset%s\n"
|
||||||
menu_format_string_c2="$c_blue[$c_cyan%d$c_blue] $c_yellow%s$c_reset\n"
|
menu_format_string_c2="$c_blue[$c_cyan%d$c_blue] $c_yellow%s$c_reset\n"
|
||||||
|
|
||||||
count=1
|
count=1
|
||||||
while read anime_id; do
|
while read anime_id; do
|
||||||
# alternating colors for menu
|
# alternating colors for menu
|
||||||
[ $((count % 2)) -eq 0 ] &&
|
[ $((count % 2)) -eq 0 ] &&
|
||||||
menu_format_string=$menu_format_string_c1 ||
|
menu_format_string=$menu_format_string_c1 ||
|
||||||
menu_format_string=$menu_format_string_c2
|
menu_format_string=$menu_format_string_c2
|
||||||
|
|
||||||
printf "$menu_format_string" "$count" "$anime_id"
|
printf "$menu_format_string" "$count" "$anime_id"
|
||||||
count=$((count+1))
|
count=$((count+1))
|
||||||
done <<-EOF
|
done <<< "$search_results"
|
||||||
$search_results
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# User input
|
# User input
|
||||||
printf "$c_blue%s$c_green" "Enter number: "
|
printf "$c_blue%s$c_green" "Enter number: "
|
||||||
read choice
|
read choice
|
||||||
printf "$c_reset"
|
printf "$c_reset"
|
||||||
name="$anime_id"
|
name="$anime_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log "CHOICE: $choice"
|
log "CHOICE: $choice"
|
||||||
@ -629,7 +635,9 @@ shift $((OPTIND - 1))
|
|||||||
case $scrape in
|
case $scrape in
|
||||||
query)
|
query)
|
||||||
get_search_query "$*"
|
get_search_query "$*"
|
||||||
search_results=$(search_anime "$query")
|
res=$(check_db "$query" search)
|
||||||
|
log "Searched before: $res"
|
||||||
|
search_results=$(search_anime $query)
|
||||||
[ -z "$search_results" ] && die "No search results found"
|
[ -z "$search_results" ] && die "No search results found"
|
||||||
if ! anime_selection "$search_results"; then
|
if ! anime_selection "$search_results"; then
|
||||||
die "No anime selection found"
|
die "No anime selection found"
|
||||||
|
Loading…
Reference in New Issue
Block a user