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

Metadata Bugfixes #1511

Merged
merged 6 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 32 additions & 16 deletions API.Tests/Services/ArchiveServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,24 +276,40 @@ public void CanParseComicInfo()
{
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"
};

Assert.NotStrictEqual(expected, actual);
var comicInfo = _archiveService.GetComicInfo(archive);

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
Expand Down
Binary file not shown.
5 changes: 5 additions & 0 deletions API/Data/Metadata/ComicInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;


Expand All @@ -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;

Expand Down
11 changes: 5 additions & 6 deletions API/Services/BookService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,10 @@ public ComicInfo GetComicInfo(string filePath)
case "calibre:title_sort":
info.TitleSort = metadataItem.Content;
break;
case "calibre:series":
info.Series = metadataItem.Content;
info.SeriesSort = metadataItem.Content;
break;
}
}

Expand Down Expand Up @@ -609,15 +613,10 @@ public ParserInfo ParseInfo(string filePath)
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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion API/Services/Tasks/Scanner/ProcessSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ void AddTag(Tag tag, bool added)
{
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);
Expand Down