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 5 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
33 changes: 32 additions & 1 deletion API.Tests/Services/ArchiveServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,40 @@ public void CanParseComicInfo()
Web = "https://www.comixology.com/BTOOOM/digital-comic/450184"
};

Assert.NotStrictEqual(expected, actual);
Assert.StrictEqual(expected, actual);
}

#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 actual = _archiveService.GetComicInfo(archive);
var expected = new ComicInfo()
{
Publisher = "Dark Horse Comics",
Genre = "Supernatural/Occult, Horror, Action/Adventure",
Summary = "When strangeness threatens to engulf the world, a strange man will come to save it. Sent to investigate a mystery with supernatural overtones, Hellboy discovers the secrets of his own origins, and his link to the Nazi occultists who promised Hitler a final solution in the form of a demonic avatar.",
PageCount = 147,
LanguageISO = "en",
Notes = "Scraped metadata from Comixology [CMXDB450184]",
Series = "Hellboy",
Title = "The Right Hand of Doom",
Number = "",
Count = 0,
Volume = "4",
Web = "https://comicvine.gamespot.com/hellboy-the-right-hand-of-doom-1-volume-4/4000-194124/"

};

Assert.StrictEqual(expected, actual);
}


#endregion

#region FindCoverImageFilename
Expand Down
Binary file not shown.
19 changes: 19 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 Expand Up @@ -120,4 +125,18 @@ public static void CleanComicInfo(ComicInfo info)
}


// TODO: Example of Equals() implementation. This currently only
tjarls marked this conversation as resolved.
Show resolved Hide resolved
// covers enough fields to cover the unit tests
public override bool Equals(object obj)
{
return obj is ComicInfo info &&
this.Count == info.Count &&
this.Genre == info.Genre &&
this.Number == info.Number &&
this.PageCount == info.PageCount &&
this.Series == info.Series &&
this.Summary.Trim() == info.Summary.Trim() &&
this.Title == info.Title &&
this.Volume == info.Volume;
}
}
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