Kareadita / Kavita

Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.
http://www.kavitareader.com
GNU General Public License v3.0
6.15k stars 320 forks source link

Series `Localized Name` causing removal of books or duplication of series #2215

Open DieselTech opened 1 year ago

DieselTech commented 1 year ago

Describe the bug When having a Localized Name set for a series, files within that series folder would treat both names as valid filenames for said series.

To Reproduce Steps to reproduce the behavior:

  1. Have a series with Localized Name set
  2. Scan library
  3. See either extra series populate with just the localized name OR 3b. The series will remove books from the listing because it doesn't see any files matching Localized Name string.

Expected behavior When Localized Name is set the scanner should consider both Name and Localized Name as the same exact series.

Logs kavita.txt

Desktop (please complete the following information):

Additional context This also has the added downside of flip flopping what volumes and chapters show up each time a scan is made. That causes read status to be lost.

DieselTech commented 1 year ago

Here's an example of how this is showing:

image

When it detects the localized name, it removes all the previous volumes / chapters that used the normal "name". Here in the screenshot chapters 1 through 106 don't exist anywhere in kavita now. Searching doesn't show them either:

image

majora2007 commented 1 year ago

Can you please provide me the ComicInfo Series and LocalizedSeries from the first chapter or volume of this series? That is the key to this merging working.

DieselTech commented 1 year ago

The first chapter (no volumes here) does not contain any comicinfo.xml files. In fact none of them do. The LocalizedSeries is being set by KOMF when it does the metadata update.

majora2007 commented 1 year ago

Okay, I'll have to take a look. This merging behaviour wasn't designed with the API being the one to set it. It should work though, but if the Series title is changing from the first set to something new, it requires a Scan Library to ingest the changes.

majora2007 commented 1 year ago

I just tested this out. I have a single Series: "Bleach - Digital Colored Comics" with a set of files like "Bleach - Digital Colored Comics v02.1 (2021) (KojoZero Scans).cbz".

I edit via the UI to add a Localized Series named: "Bleach - Digital Colored ComicX" then added a new file "Bleach - Digital Colored ComicX v02.3 (2021) (KojoZero Scans).cbz" and did a Scan Series and everything grouped together correctly.

DieselTech commented 1 year ago

Is it possible that such a small change in the name didn't get picked up by the Localized Series name? What if you name them totally different things like:

Bleach - Digital Colored Comics and That book based on the chemical

DieselTech commented 1 year ago

Update: Adding comicinfo.xml with the LocalizedSeries defined as the JA-RO name type did cause the scanner to pick up both names as the same series. It just seems like when the API updates that field that it doesn't accept it anymore.

majora2007 commented 1 year ago

I took another look at this and it does look like if you set it in the API it should work. Once we exit out of finding and mashing the files together, we move to finding the series, which we do by looking up against Series name and Localized Name.

If the series in the DB has a localized name, as long as there is a match (ie file series/localize matches either/or db series/localize) then it will match with that series. In the unit test as well as my local test, I'm seeing the correct series come back.

private async Task SetupSeriesData()
    {
        var library = new LibraryBuilder("GetFullSeriesByAnyName Manga", LibraryType.Manga)
            .WithFolderPath(new FolderPathBuilder("C:/data/manga/").Build())
            .WithSeries(new SeriesBuilder("The Idaten Deities Know Only Peace")
                .WithLocalizedName("Heion Sedai no Idaten-tachi")
                .WithFormat(MangaFormat.Archive)
                .Build())
            .WithSeries(new SeriesBuilder("Hitomi-chan is Shy With Strangers")
                .WithLocalizedName("Hitomi-chan wa Hitomishiri")
                .WithFormat(MangaFormat.Archive)
                .Build())
            .Build();

        _unitOfWork.LibraryRepository.Add(library);
        await _unitOfWork.CommitAsync();
    }

    [Theory]
    [InlineData("The Idaten Deities Know Only Peace", MangaFormat.Archive, "", "The Idaten Deities Know Only Peace")] // Matching on series name in DB
    [InlineData("Heion Sedai no Idaten-tachi", MangaFormat.Archive, "The Idaten Deities Know Only Peace", "The Idaten Deities Know Only Peace")] // Matching on localized name in DB
    [InlineData("Heion Sedai no Idaten-tachi", MangaFormat.Pdf, "", null)]
    [InlineData("Hitomi-chan wa Hitomishiri", MangaFormat.Archive, "", "Hitomi-chan is Shy With Strangers")]
    public async Task GetFullSeriesByAnyName_Should(string seriesName, MangaFormat format, string localizedName, string? expected)
    {
        await ResetDb();
        await SetupSeriesData();

        var series =
            await _unitOfWork.SeriesRepository.GetFullSeriesByAnyName(seriesName, localizedName,
                2, format, false);
        if (expected == null)
        {
            Assert.Null(series);
        }
        else
        {
            Assert.NotNull(series);
            Assert.Equal(expected, series.Name);
        }
    }

I can't seem to reproduce this bug.

majora2007 commented 1 year ago

I found a case on my prod server where I was able to reproduce some funkiness around this bug using ComicInfo. I will look back into this.