mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2025-01-30 10:27:38 -08:00
improve anime_selection menu performance
This commit is contained in:
parent
cf5c5dbcee
commit
f882f7d3d2
36
ani-cli
36
ani-cli
@ -480,36 +480,26 @@ anime_selection() {
|
|||||||
# Select anime from query results
|
# Select anime from query results
|
||||||
search_results=$*
|
search_results=$*
|
||||||
if [ "$IS_ROFI" -eq 1 ]; then
|
if [ "$IS_ROFI" -eq 1 ]; then
|
||||||
count=1
|
|
||||||
menu=()
|
menu=()
|
||||||
res=()
|
res=()
|
||||||
|
searched=""
|
||||||
|
cnt=0
|
||||||
|
# generate inputlist for rofi and indexes of previously searched anime
|
||||||
while read -r anime_id; do
|
while read -r anime_id; do
|
||||||
menu+="$count. $anime_id\n"
|
menu+="$((cnt + 1)). $anime_id\n"
|
||||||
idx=$((count - 1))
|
res["$cnt"]="$anime_id"
|
||||||
res["$idx"]="$anime_id"
|
lg "ANIME: $anime_id"
|
||||||
count=$((count + 1))
|
if ! check_db "$anime_id" "search"; then
|
||||||
|
lg "$anime_id HAS BEEN SEARCHED BEFORE"
|
||||||
|
[ -z "$searched" ] && searched="$cnt" || searched="$searched, $cnt"
|
||||||
|
fi
|
||||||
|
((++cnt))
|
||||||
done <<- EOF
|
done <<- EOF
|
||||||
$search_results
|
$search_results
|
||||||
EOF
|
EOF
|
||||||
menu+="$count. Quit"
|
menu+="$((++cnt)). Quit"
|
||||||
|
|
||||||
searched=""
|
lg "searched indexes: $searched"
|
||||||
cnt=0
|
|
||||||
# Get the comma separated list of indexes of anime that has been searched before
|
|
||||||
for anime in "${res[@]}"; do
|
|
||||||
lg "ANIME: $anime"
|
|
||||||
check_db "$anime" "search"
|
|
||||||
if [[ $? -gt 0 ]]; then
|
|
||||||
lg "$anime HAS BEEN SEARCHED BEFORE"
|
|
||||||
if [ -z "$searched" ]; then
|
|
||||||
searched="$cnt"
|
|
||||||
else
|
|
||||||
searched="$searched, $cnt"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
((++cnt))
|
|
||||||
done
|
|
||||||
lg "SEARCHED: $searched"
|
|
||||||
|
|
||||||
# get the anime from indexed list
|
# get the anime from indexed list
|
||||||
msg="$(generate_span "Query: $query")"
|
msg="$(generate_span "Query: $query")"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user