#Jimaku episode num checking algorithm fails when files use continous episode number naming schemes

1 messages · Page 1 of 1 (latest)

ionic pagoda
#

Sometimes episode numbers in subtile files continiously keep count from the first season to the rest.

For example instead of the first episode of season 2 being S02E01, it would be say Episode 13 or 第13話. This is a problem because if I'm trying to watch episode 13 of season 2, the jimaku suggestion will only give me the subtitle that has 13 in the name but is actually for episode 1.

For a concrete example, try getting the subtitle for episode 18 of My hero season 2. It will give you this file 僕のヒーローアカデミア.S02E06.第18話 騎馬戦決着.WEBRip.Amazon.ja-jp[sdh].srt which is actually for episode 6.

night surge
#

Send picture of title name

ionic pagoda
night surge
ionic pagoda
#

Because the episode 6 file has an 18 in it if you count from the beginning of season 1 (12 + 6)

drifting notch
#

This is one of those cases where they count the second cour separately.

#

?

#

Ah sorry, I didnt get to read the last message

ionic pagoda
ionic pagoda
#

@night surge is my last description of the problem clear or should I elaborate more?

ionic pagoda
#

Ok so I decided to go through the code to understand why this problem happens. If you want the quickest possible fix that will take care of the specific problem that I encountered, then in the jimaku file at:
WebUI/src/features/anime/reader/services/jimaku.ts

In the last if chain in the filterEpisodeMatches function, check that the matches aren't empty before returning:

  if (hasJapanese && japaneseMatches.length) {
    return { matches: japaneseMatches, hasEpisodeTags: true }
  }
  if (hasSeason && seasonMatches.length) {
    return { matches: seasonMatches, hasEpisodeTags: true }
  }
  if (hasGeneral && generalMatches.length) {
    return { matches: generalMatches, hasEpisodeTags: true }
  }
  return { matches: [], hasEpisodeTags: false }

This fixes the problem, but it also made me curious why we're only choosing to return only one of the three categories of matches instead of just returning all the matches we get? This whole problem was caused because the function would find some atleast one file with japanese episode numbering, set hasJapanese to true making it only able to return japanese matches, then proceed to not find any Japanese episode numbers that match the actual target because the japanese episode numbers are the continuous kind not the per season kind. So it would return an empty array, making it fallback to filtering through all the jimaku files and finding the incorrect one.

#

I would've made a PR but ideally I'd want to understand why we're doing this in the first place because if it's not needed then ideally we just return both Japanese and season matches together (we can leave general matches as a last ditch effort if none of the other two worked)

night surge
#

@ionic pagoda can you join vc quick?

ionic pagoda
#

yeah 1 sec