Skip to content

Improvements to processing history#1737

Open
RaitaroH wants to merge 2 commits into
pystardust:masterfrom
RaitaroH:master
Open

Improvements to processing history#1737
RaitaroH wants to merge 2 commits into
pystardust:masterfrom
RaitaroH:master

Conversation

@RaitaroH
Copy link
Copy Markdown

@RaitaroH RaitaroH commented May 23, 2026

Pull Request Template

Type of change

  • Bug fix
  • Feature
  • Documentation update

Description

Fixing sort -n

The anime "Detecitve Conan' has many episodes. The episodes_list() curl returns some strange numbers such as "348.349", which the current "sort -n" will put after latest ep "1201". This issue will also embed itself into the histfile.

To fix this, it is enough to use sort -g.

$ echo -e "348.349\n1201\n100\n800" | sort -n
100
800
1201
348.349

$ echo -e "348.349\n1201\n100\n800" | sort -g
100
348.349
800
1201

episodes_list is called many times

In the -c option we first call episodes_list() which processes all anime in histfile, then ep_list will call episodes_list again. We could instead have the episodes_list save the result in tmp so we don't curl again.

Checklist

  • any anime playing
  • bumped version

  • next, prev and replay work
  • -c history and continue work
  • not using -c also works
  • -q quality works

RaitaroH added 2 commits May 23, 2026 15:05
fixes "Meitantei Conan" latest episode being incorrect
@RaitaroH RaitaroH requested a review from Derisis13 as a code owner May 23, 2026 12:33
@RaitaroH
Copy link
Copy Markdown
Author

This comment is not part of this PR, nor will it be. It is just a remark.

We could reduce curls further if we skipped processing entries that are finished. Is just that, currently, we do not know if a show has been completed or we simply caught up to the latest known episode (say we watched ep 4 out of 4 known last week, but now there is a 5th episode, yet the script will skip without curl-ing, thus never updating to 5).

process_hist_entry() {
    # skip if anime is completed
    last_known_ep_no=$(printf "%s" "$title" | grep -oP '\(\K[0-9.]+(?= episodes\))')
    # use bc to avoid errors when ep_no is a float number
    [ "$(echo "$ep_no >= $last_known_ep_no" | bc)" -eq 1 ] && exit 0
    ...
}

I suppose we could have another column in the histfile to say if show is finished or not.

For now deleting the histfile either with the -D or manually seems is sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant