Skip to content

Commit eed37c5

Browse files
committed
fix: use tab separator for uptodate marker and guard empty id
1 parent 6fb2c45 commit eed37c5

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

ani-cli

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,13 @@ episodes_list() {
344344
# PLAYING
345345

346346
process_hist_entry() {
347+
[ -z "$id" ] && return 0
347348
ep_list=$(episodes_list "$id")
348349
latest_ep=$(printf "%s\n" "$ep_list" | tail -n1)
349350
title=$(printf "%s\n" "$title" | sed "s|[0-9]\+ episodes|${latest_ep} episodes|")
350351
ep_no=$(printf "%s" "$ep_list" | sed -n "/^${ep_no}$/{n;p;}") 2>/dev/null
351352
[ -n "$ep_no" ] && printf "%s\t%s - episode %s\n" "$id" "$title" "$ep_no"
352-
[ -n "$ep_no" ] || printf "%s\t%s - episode %s (up to date)\n" "$id" "$title" "$latest_ep"
353+
[ -n "$ep_no" ] || printf "%s\t%s - episode %s\tuptodate\n" "$id" "$title" "$latest_ep"
353354
}
354355

355356
update_history() {
@@ -585,7 +586,7 @@ esac
585586
# searching
586587
case "$search" in
587588
history)
588-
anime_list=$(while read -r ep_no id title; do process_hist_entry & done <"$histfile")
589+
anime_list=$(while read -r ep_no id title; do process_hist_entry; done <"$histfile")
589590
wait
590591
[ -z "$anime_list" ] && die "No unwatched series in history!"
591592
[ -z "${index##*[!0-9]*}" ] && id=$(printf "%s" "$anime_list" | nl -w 2 | sed 's/^[[:space:]]//' | nth "Select anime: " | cut -f1)
@@ -595,7 +596,7 @@ case "$search" in
595596
ep_list=$(episodes_list "$id")
596597
ep_no=$(printf "%s" "$anime_list" | grep "$id" | cut -f2 | sed -nE 's/.*- episode (.+)$/\1/p')
597598
allanime_title="$(printf "%s" "$title" | cut -d'(' -f1 | tr -d '[:punct:]')"
598-
printf "%s" "$anime_list" | grep "$id" | cut -f2 | grep -q "(up to date)" && time_until_next_ep "$allanime_title"
599+
printf "%s" "$anime_list" | grep -F "$id" | grep -q " uptodate$" && time_until_next_ep "$(printf "%s" "$title" | cut -d'(' -f1 | sed 's/ *$//')"
599600
;;
600601
*)
601602
if [ "$use_external_menu" = "0" ]; then

0 commit comments

Comments
 (0)