Metadata Bugfixes (#1511)

* Fix XML deserialization of empty elements to integers

* Fix assumption that environment uses US time format

* Use series name as SeriesSort in epub

* Address some PR comments

* Add partial Equals(0 implementation to ComicInfo

* Update ComicInfo unittest. Revert previous version
This commit is contained in:
tjarls 2022-09-14 14:03:20 +01:00 committed by GitHub
parent 0a6e64d767
commit a1c3f43656
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 22 deletions

View File

@ -276,24 +276,40 @@ public class ArchiveServiceTests
{
var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ArchiveService/ComicInfos");
var archive = Path.Join(testDirectory, "ComicInfo.zip");
var actual = _archiveService.GetComicInfo(archive);
var expected = new ComicInfo()
{
Publisher = "Yen Press",
Genre = "Manga, Movies & TV",
Summary =
"By all counts, Ryouta Sakamoto is a loser when he's not holed up in his room, bombing things into oblivion in his favorite online action RPG. But his very own uneventful life is blown to pieces when he's abducted and taken to an uninhabited island, where he soon learns the hard way that he's being pitted against others just like him in a explosives-riddled death match! How could this be happening? Who's putting them up to this? And why!? The name, not to mention the objective, of this very real survival game is eerily familiar to Ryouta, who has mastered its virtual counterpart-BTOOOM! Can Ryouta still come out on top when he's playing for his life!?",
PageCount = 194,
LanguageISO = "en",
Notes = "Scraped metadata from Comixology [CMXDB450184]",
Series = "BTOOOM!",
Title = "v01",
Web = "https://www.comixology.com/BTOOOM/digital-comic/450184"
};
var comicInfo = _archiveService.GetComicInfo(archive);
Assert.NotStrictEqual(expected, actual);
Assert.NotNull(comicInfo);
Assert.Equal(comicInfo.Publisher, "Yen Press");
Assert.Equal(comicInfo.Genre, "Manga, Movies & TV");
Assert.Equal(comicInfo.Summary, "By all counts, Ryouta Sakamoto is a loser when he's not holed up in his room, bombing things into oblivion in his favorite online action RPG. But his very own uneventful life is blown to pieces when he's abducted and taken to an uninhabited island, where he soon learns the hard way that he's being pitted against others just like him in a explosives-riddled death match! How could this be happening? Who's putting them up to this? And why!? The name, not to mention the objective, of this very real survival game is eerily familiar to Ryouta, who has mastered its virtual counterpart-BTOOOM! Can Ryouta still come out on top when he's playing for his life!?");
Assert.Equal(comicInfo.PageCount, 194);
Assert.Equal(comicInfo.LanguageISO, "en");
Assert.Equal(comicInfo.Notes, "Scraped metadata from Comixology [CMXDB450184]");
Assert.Equal(comicInfo.Series, "BTOOOM!");
Assert.Equal(comicInfo.Title, "v01");
Assert.Equal(comicInfo.Web, "https://www.comixology.com/BTOOOM/digital-comic/450184");
}
#endregion
#region CanParseComicInfo_DefaultNumberIsBlank
[Fact]
public void CanParseComicInfo_DefaultNumberIsBlank()
{
var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ArchiveService/ComicInfos");
var archive = Path.Join(testDirectory, "ComicInfo2.zip");
var comicInfo = _archiveService.GetComicInfo(archive);
Assert.NotNull(comicInfo);
Assert.Equal("Hellboy", comicInfo.Series);
Assert.Equal("The Right Hand of Doom", comicInfo.Title);
Assert.Equal("", comicInfo.Number);
Assert.Equal(0, comicInfo.Count);
Assert.Equal("4", comicInfo.Volume);
}
#endregion
#region FindCoverImageFilename

View File

@ -23,6 +23,7 @@ public class ComicInfo
/// <summary>
/// The total number of items in the series.
/// </summary>
[System.ComponentModel.DefaultValueAttribute(0)]
public int Count { get; set; } = 0;
public string Volume { get; set; } = string.Empty;
public string Notes { get; set; } = string.Empty;
@ -37,8 +38,11 @@ public class ComicInfo
/// This is the link to where the data was scraped from
/// </summary>
public string Web { get; set; } = string.Empty;
[System.ComponentModel.DefaultValueAttribute(0)]
public int Day { get; set; } = 0;
[System.ComponentModel.DefaultValueAttribute(0)]
public int Month { get; set; } = 0;
[System.ComponentModel.DefaultValueAttribute(0)]
public int Year { get; set; } = 0;
@ -54,6 +58,7 @@ public class ComicInfo
public string StoryArc { get; set; } = string.Empty;
public string SeriesGroup { get; set; } = string.Empty;
public string AlternateNumber { get; set; } = string.Empty;
[System.ComponentModel.DefaultValueAttribute(0)]
public int AlternateCount { get; set; } = 0;
public string AlternateSeries { get; set; } = string.Empty;

View File

@ -447,6 +447,10 @@ public class BookService : IBookService
case "calibre:title_sort":
info.TitleSort = metadataItem.Content;
break;
case "calibre:series":
info.Series = metadataItem.Content;
info.SeriesSort = metadataItem.Content;
break;
}
}
@ -609,15 +613,10 @@ public class BookService : IBookService
FullFilePath = filePath,
IsSpecial = false,
Series = series.Trim(),
SeriesSort = series.Trim(),
Volumes = seriesIndex
};
// Don't set titleSort if the book belongs to a group
if (!string.IsNullOrEmpty(titleSort) && string.IsNullOrEmpty(seriesIndex) && (groupPosition.Equals("series") || groupPosition.Equals("set")))
{
info.SeriesSort = titleSort;
}
return info;
}
}

View File

@ -647,7 +647,7 @@ public class ProcessSeries : IProcessSeries
{
var day = Math.Max(comicInfo.Day, 1);
var month = Math.Max(comicInfo.Month, 1);
chapter.ReleaseDate = DateTime.Parse($"{month}/{day}/{comicInfo.Year}");
chapter.ReleaseDate = new DateTime(comicInfo.Year, month, day);
}
var people = GetTagValues(comicInfo.Colorist);