Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Match rejected due to folder having files with different titles #246

Open
4 of 6 tasks
sin3point14 opened this issue Feb 21, 2025 · 1 comment
Open
4 of 6 tasks

Comments

@sin3point14
Copy link
Contributor

sin3point14 commented Feb 21, 2025

Checklist

  • My version of the app is the latest available
  • I have checked open and closed issues
  • I have checked the docs for a fix

Bug Severity

Low

Bug Area

Anime Library

Bug Description / Steps to Reproduce

Kurakon is not being matched to the correct anilist id by the matcher:

Image

I added logging to the code:

sin3point14@devm-manas-wsl:~/github/seanime$ git --no-pager diff internal/library/scanner/matcher.go
diff --git a/internal/library/scanner/matcher.go b/internal/library/scanner/matcher.go
index fd833075..546335f0 100644
--- a/internal/library/scanner/matcher.go
+++ b/internal/library/scanner/matcher.go
@@ -3,10 +3,6 @@ package scanner
 import (
        "errors"
        "fmt"
-       "github.com/rs/zerolog"
-       "github.com/samber/lo"
-       lop "github.com/samber/lo/parallel"
-       "github.com/sourcegraph/conc/pool"
        "math"
        "seanime/internal/api/anilist"
        "seanime/internal/library/anime"
@@ -14,6 +10,11 @@ import (
        "seanime/internal/util"
        "seanime/internal/util/comparison"
        "time"
+
+       "github.com/rs/zerolog"
+       "github.com/samber/lo"
+       lop "github.com/samber/lo/parallel"
+       "github.com/sourcegraph/conc/pool"
 )
 
 type Matcher struct {
@@ -312,6 +313,11 @@ func (m *Matcher) validateMatches() {
 // with the media titles and un-matches the local files that have a lower rating.
 // This is done to try and filter out wrong matches.
 func (m *Matcher) validateMatchGroup(mediaId int, lfs []*anime.LocalFile) {
+       log := false
+       if mediaId == 178462 {
+               log = true
+               fmt.Println("LESSGO")
+       }
 
        media, found := m.MediaContainer.GetMediaFromId(mediaId)
        if !found {
@@ -325,6 +331,15 @@ func (m *Matcher) validateMatchGroup(mediaId int, lfs []*anime.LocalFile) {
 
        titles := media.GetAllTitles()
 
+       if log {
+               for _, lf := range lfs {
+                       fmt.Printf("1 %+v\n", lf)
+               }
+               for _, title := range titles {
+                       fmt.Printf("2 %s\n", *title)
+               }
+       }
+
        // Compare all files' parsed title with the media title
        // Get the highest rating that will be used to un-match lower rated files
        p := pool.NewWithResults[float64]()
@@ -335,6 +350,10 @@ func (m *Matcher) validateMatchGroup(mediaId int, lfs []*anime.LocalFile) {
                                return 0
                        }
                        compRes, ok := comparison.FindBestMatchWithSorensenDice(&t, titles)
+                       if log {
+                               fmt.Printf("3 %s", t)
+                               fmt.Printf("4 %+v %+v %+v %+v", *compRes.OriginalValue, compRes.Rating, *compRes.Value, ok)
+                       }
                        if ok {
                                return compRes.Rating
                        }

output:

Feb 21 14:20:39 the-beast seanime[3891585]: LESSGO
Feb 21 14:20:39 the-beast seanime[3891585]: 1 &{Path:/data/seanime/library/Class no Daikirai na Joshi to Kekkon Suru Koto ni Natta/[Erai-raws] Kurakon - 05 [1080p CR WEBRip HEVC EAC3][MultiSub][B43EBCBD].mkv Name:[Erai-raws] Kurakon - 05 [1080p CR WEBRip HEVC EAC3][MultiSub][B43EBCBD].mkv ParsedData:0xc000bfe000 ParsedFolderData:[0xc0006de410] Metadata:0xc001699020 Locked:false Ignored:false MediaId:178462}
Feb 21 14:20:39 the-beast seanime[3891585]: 1 &{Path:/data/seanime/library/Class no Daikirai na Joshi to Kekkon Suru Koto ni Natta/[Erai-raws] Kurakon - 06 [1080p CR WEBRip HEVC EAC3][MultiSub][9476AA2E].mkv Name:[Erai-raws] Kurakon - 06 [1080p CR WEBRip HEVC EAC3][MultiSub][9476AA2E].mkv ParsedData:0xc0006de4e0 ParsedFolderData:[0xc002d72ea0] Metadata:0xc00228e030 Locked:false Ignored:false MediaId:178462}
Feb 21 14:20:39 the-beast seanime[3891585]: 1 &{Path:/data/seanime/library/Class no Daikirai na Joshi to Kekkon Suru Koto ni Natta/[SubsPlease] Class no Daikirai na Joshi to Kekkon suru Koto ni Natta - 07 (1080p) [BE9638C1].mkv Name:[SubsPlease] Class no Daikirai na Joshi to Kekkon suru Koto ni Natta - 07 (1080p) [BE9638C1].mkv ParsedData:0xc0026d9930 ParsedFolderData:[0xc0026d9a00] Metadata:0xc00052db60 Locked:false Ignored:false MediaId:178462}
Feb 21 14:20:39 the-beast seanime[3891585]: 2 Class no Daikirai na Joshi to Kekkon Suru Koto ni Natta.
Feb 21 14:20:39 the-beast seanime[3891585]: 2 I'm Getting Married to a Girl I Hate in My Class
Feb 21 14:20:39 the-beast seanime[3891585]: 3 Kurakon4 Kurakon 0.13114754098360656 Class no Daikirai na Joshi to Kekkon Suru Koto ni Natta. true3 Class no Daikirai na Joshi to Kekkon suru Koto ni Natta4 Class no Daikirai na Joshi to Kekkon suru Koto ni Natta 0.9908256880733946 Class no Daikirai na Joshi to Kekkon Suru Koto ni Natta. true3 Kurakon4 Kurakon 0.13114754098360656 Class no Daikirai na Joshi to Kekkon Suru Koto ni Natta. true

Interestingly for the "2" logged lines we see Class no Daikirai na Joshi to Kekkon Suru Koto ni Natta. and I'm Getting Married to a Girl I Hate in My Class however no Kurakon, which is shown in the TITLE field in the screenshot. Hence, we get a super low match score for the ep titles with Kurakon.

(There is also the issue that the TITLE block doesn't show I'm Getting Married to a Girl I Hate in My Class but I didn't dig into that)

Expected Behavior

The match for ep titled with Kurakon should succeed.
The following diff fixes the issue but I didn't put up a PR since I don't know why that Filter was there in the first place

sin3point14@devm-manas-wsl:~/github/seanime$ git --no-pager diff internal/api/anilist/media_helper.go
diff --git a/internal/api/anilist/media_helper.go b/internal/api/anilist/media_helper.go
index 2039085d..e5792d9f 100644
--- a/internal/api/anilist/media_helper.go
+++ b/internal/api/anilist/media_helper.go
@@ -1,8 +1,9 @@
 package anilist
 
 import (
-       "github.com/samber/lo"
        "seanime/internal/util/comparison"
+
+       "github.com/samber/lo"
 )
 
 func (m *BaseAnime) GetTitleSafe() string {
@@ -114,7 +115,7 @@ func (m *BaseAnime) GetAllTitles() []*string {
                titles = append(titles, m.Title.English)
        }
        if m.HasSynonyms() && len(m.Synonyms) > 1 {
-               titles = append(titles, lo.Filter(m.Synonyms, func(s *string, i int) bool { return comparison.ValueContainsSeason(*s) })...)
+               titles = append(titles, m.Synonyms...)
        }
        return titles
 }

Screenshots

No response

Logs

Already showed the logs above ^

Debugging Checklist

  • I have included error messages
  • I have included server logs
  • I have included browser console logs

App Version

v2.7.4

Operating System

Linux

@sin3point14 sin3point14 added the bug Something isn't working label Feb 21, 2025
@5rahim 5rahim changed the title bug: bug: Match rejected due to folder having files with different titles Feb 21, 2025
@5rahim
Copy link
Owner

5rahim commented Feb 21, 2025

There is also the issue that the TITLE block doesn't show I'm Getting Married to a Girl I Hate in My Class but I didn't dig into that

The first 5 fields in the scan summary show the results of the file path parser, not related to the matcher.

Regarding comparison.ValueContainsSeason(*s) it's done because AniList often adds a bunch of random synonyms, also in different languages, with various lengths (like KnY etc.) and I think it's safer to keep it that way but I'm willing to add an advance option in the settings to override the filter.

The safer solution would be to completely remove validateMatches since it rarely rejects stuff. Even in your case, locking all other files but the ones named "Kurakon" and refreshing would solve the issue (probably).

@5rahim 5rahim added this to the v2.8.0 milestone Feb 21, 2025
@5rahim 5rahim moved this to Planned in Seanime Roadmap Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Planned
Development

No branches or pull requests

2 participants