mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-11-22 03:19:53 -08:00
Compare commits
No commits in common. "a726b9d5500b43cdcb58dddc0650814ceb0c8bd3" and "cf5c5dbceed0bc17d321912e1765bdd34fae978c" have entirely different histories.
a726b9d550
...
cf5c5dbcee
58
ani-cli
58
ani-cli
@ -480,26 +480,36 @@ anime_selection() {
|
||||
# Select anime from query results
|
||||
search_results=$*
|
||||
if [ "$IS_ROFI" -eq 1 ]; then
|
||||
count=1
|
||||
menu=()
|
||||
res=()
|
||||
searched=""
|
||||
cnt=0
|
||||
# generate inputlist for rofi and indexes of previously searched anime
|
||||
while read -r anime_id; do
|
||||
menu+="$((cnt + 1)). $anime_id\n"
|
||||
res["$cnt"]="$anime_id"
|
||||
lg "ANIME: $anime_id"
|
||||
if ! check_db "$anime_id" "search"; then
|
||||
lg "$anime_id HAS BEEN SEARCHED BEFORE"
|
||||
[ -z "$searched" ] && searched="$cnt" || searched="$searched, $cnt"
|
||||
fi
|
||||
((++cnt))
|
||||
menu+="$count. $anime_id\n"
|
||||
idx=$((count - 1))
|
||||
res["$idx"]="$anime_id"
|
||||
count=$((count + 1))
|
||||
done <<- EOF
|
||||
$search_results
|
||||
EOF
|
||||
menu+="$((++cnt)). Quit"
|
||||
menu+="$count. Quit"
|
||||
|
||||
lg "searched indexes: $searched"
|
||||
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
|
||||
msg="$(generate_span "Query: $query")"
|
||||
@ -541,6 +551,12 @@ anime_selection() {
|
||||
|
||||
lg "CHOICE: $choice"
|
||||
|
||||
if [ "$IS_ROFI" -eq 1 ]; then
|
||||
# check both choice and name are set
|
||||
if [[ ! "$choice" ]] || [[ ! "$name" ]]; then
|
||||
die "Invalid choice... committing seppuku"
|
||||
fi
|
||||
fi
|
||||
# Check if input is a number
|
||||
[ "$choice" -eq "$choice" ] 2> /dev/null || die "Invalid number entered"
|
||||
|
||||
@ -556,12 +572,13 @@ anime_selection() {
|
||||
$search_results
|
||||
EOF
|
||||
|
||||
printf "$c_reset"
|
||||
[ -z "$name" ] && name="$anime_id"
|
||||
[ -z "$selection_id" ] && die "Invalid number entered"
|
||||
|
||||
insert_history "$name" "search" &
|
||||
|
||||
printf "$c_reset"
|
||||
|
||||
[ -z "$selection_id" ] && die "Invalid number entered"
|
||||
|
||||
read -r last_ep_number <<- EOF
|
||||
$(search_eps "$selection_id")
|
||||
EOF
|
||||
@ -575,19 +592,17 @@ episode_selection() {
|
||||
stmt="SELECT DISTINCT episode_number \
|
||||
FROM watch_history \
|
||||
WHERE anime_name = '$anime_id';"
|
||||
# hist=$(run_stmt "$stmt")
|
||||
hist=$(run_stmt "$stmt")
|
||||
|
||||
# Get Watch History for $anime_id as comma separated list
|
||||
watch_history=""
|
||||
# for i in $hist; do
|
||||
while read -r i; do
|
||||
for i in $hist; do
|
||||
if [[ "$watch_history" == "" ]]; then
|
||||
watch_history="$((--i))"
|
||||
else
|
||||
watch_history="$watch_history, $((--i))"
|
||||
fi
|
||||
done < <(run_stmt "$stmt")
|
||||
lg "Episode watch history -> $watch_history"
|
||||
done
|
||||
|
||||
# get user choice and set the start and end
|
||||
msg=$(printf "%s\n%s" "$(generate_span "Anime Name: $anime_id")" "$(generate_span "Range of episodes can be provided as: START_EPISODE - END_EPISODE")")
|
||||
@ -626,6 +641,7 @@ episode_selection() {
|
||||
ep_choice_end=""
|
||||
fi
|
||||
printf "$c_reset"
|
||||
|
||||
}
|
||||
|
||||
open_episode() {
|
||||
|
Loading…
Reference in New Issue
Block a user