Feature/local metadata more tags (#832)
* Stashing code * removed some debug code on series detail page. Now detail is collapsed by default. * Added AgeRating * Fixed a crash when NetVips tries to write a cover file and cover directory is not existing. * When a card is selected for bulk actions, show an outline in addition to select box * Added AgeRating into the metadata parsing. Added a hack where ComicInfo uses Number in ComicInfo rather than Volume. This is to test out the effects on users libraries. * Added AgeRating and ReleaseDate to the metadata implelentation.
This commit is contained in:
parent
46f37069db
commit
af24c928d7
31 changed files with 2825 additions and 101 deletions
|
@ -335,6 +335,33 @@ namespace API.Services
|
|||
return null;
|
||||
}
|
||||
|
||||
public static void CleanComicInfo(ComicInfo info)
|
||||
{
|
||||
if (info != null)
|
||||
{
|
||||
info.Writer = Parser.Parser.CleanAuthor(info.Writer);
|
||||
info.Colorist = Parser.Parser.CleanAuthor(info.Colorist);
|
||||
info.Editor = Parser.Parser.CleanAuthor(info.Editor);
|
||||
info.Inker = Parser.Parser.CleanAuthor(info.Inker);
|
||||
info.Letterer = Parser.Parser.CleanAuthor(info.Letterer);
|
||||
info.Penciller = Parser.Parser.CleanAuthor(info.Penciller);
|
||||
info.Publisher = Parser.Parser.CleanAuthor(info.Publisher);
|
||||
|
||||
if (!string.IsNullOrEmpty(info.Web))
|
||||
{
|
||||
// TODO: Validate this works through testing
|
||||
// ComicVine stores the Issue number in Number field and does not use Volume.
|
||||
if (info.Web.Contains("https://comicvine.gamespot.com/"))
|
||||
{
|
||||
if (info.Volume.Equals("1"))
|
||||
{
|
||||
info.Volume = Parser.Parser.DefaultVolume;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This can be null if nothing is found or any errors occur during access
|
||||
/// </summary>
|
||||
|
@ -365,16 +392,7 @@ namespace API.Services
|
|||
using var stream = entry.Open();
|
||||
var serializer = new XmlSerializer(typeof(ComicInfo));
|
||||
var info = (ComicInfo) serializer.Deserialize(stream);
|
||||
if (info != null)
|
||||
{
|
||||
info.Writer = Parser.Parser.CleanAuthor(info.Writer);
|
||||
info.Colorist = Parser.Parser.CleanAuthor(info.Colorist);
|
||||
info.Editor = Parser.Parser.CleanAuthor(info.Editor);
|
||||
info.Inker = Parser.Parser.CleanAuthor(info.Inker);
|
||||
info.Letterer = Parser.Parser.CleanAuthor(info.Letterer);
|
||||
info.Penciller = Parser.Parser.CleanAuthor(info.Penciller);
|
||||
info.Publisher = Parser.Parser.CleanAuthor(info.Publisher);
|
||||
}
|
||||
CleanComicInfo(info);
|
||||
return info;
|
||||
}
|
||||
|
||||
|
@ -394,16 +412,7 @@ namespace API.Services
|
|||
.Parser
|
||||
.MacOsMetadataFileStartsWith)
|
||||
&& Parser.Parser.IsXml(entry.Key)));
|
||||
if (info != null)
|
||||
{
|
||||
info.Writer = Parser.Parser.CleanAuthor(info.Writer);
|
||||
info.Colorist = Parser.Parser.CleanAuthor(info.Colorist);
|
||||
info.Editor = Parser.Parser.CleanAuthor(info.Editor);
|
||||
info.Inker = Parser.Parser.CleanAuthor(info.Inker);
|
||||
info.Letterer = Parser.Parser.CleanAuthor(info.Letterer);
|
||||
info.Penciller = Parser.Parser.CleanAuthor(info.Penciller);
|
||||
info.Publisher = Parser.Parser.CleanAuthor(info.Publisher);
|
||||
}
|
||||
CleanComicInfo(info);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
|
|
@ -133,7 +133,8 @@ public class ImageService : IImageService
|
|||
{
|
||||
using var thumbnail = Image.ThumbnailStream(stream, ThumbnailWidth);
|
||||
var filename = fileName + ".png";
|
||||
thumbnail.WriteToFile(_directoryService.FileSystem.Path.Join(_directoryService.CoverImageDirectory, fileName + ".png"));
|
||||
_directoryService.ExistOrCreate(_directoryService.CoverImageDirectory);
|
||||
thumbnail.WriteToFile(_directoryService.FileSystem.Path.Join(_directoryService.CoverImageDirectory, filename));
|
||||
return filename;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||
using System.Threading.Tasks;
|
||||
using API.Comparators;
|
||||
using API.Data;
|
||||
using API.Data.Metadata;
|
||||
using API.Data.Repositories;
|
||||
using API.Data.Scanner;
|
||||
using API.Entities;
|
||||
|
@ -90,11 +91,20 @@ public class MetadataService : IMetadataService
|
|||
var comicInfo = _readingItemService.GetComicInfo(firstFile.FilePath, firstFile.Format);
|
||||
if (comicInfo == null) return;
|
||||
|
||||
chapter.AgeRating = ComicInfo.ConvertAgeRatingToEnum(comicInfo.AgeRating);
|
||||
|
||||
if (!string.IsNullOrEmpty(comicInfo.Title))
|
||||
{
|
||||
chapter.TitleName = comicInfo.Title.Trim();
|
||||
}
|
||||
|
||||
if (comicInfo.Year > 0 && comicInfo.Month > 0)
|
||||
{
|
||||
var day = Math.Max(comicInfo.Day, 1);
|
||||
var month = Math.Max(comicInfo.Month, 1);
|
||||
chapter.ReleaseDate = DateTime.Parse($"{month}/{day}/{comicInfo.Year}");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(comicInfo.Colorist))
|
||||
{
|
||||
var people = comicInfo.Colorist.Split(",");
|
||||
|
@ -230,7 +240,8 @@ public class MetadataService : IMetadataService
|
|||
// Summary Info
|
||||
if (!string.IsNullOrEmpty(comicInfo.Summary))
|
||||
{
|
||||
series.Metadata.Summary = comicInfo.Summary; // NOTE: I can move this to the bottom as I have a comicInfo selection, save me an extra read
|
||||
// PERF: I can move this to the bottom as I have a comicInfo selection, save me an extra read
|
||||
series.Metadata.Summary = comicInfo.Summary;
|
||||
}
|
||||
|
||||
foreach (var chapter in series.Volumes.SelectMany(volume => volume.Chapters))
|
||||
|
@ -270,6 +281,13 @@ public class MetadataService : IMetadataService
|
|||
.Where(ci => ci != null)
|
||||
.ToList();
|
||||
|
||||
//var firstComicInfo = comicInfos.First(i => i.)
|
||||
|
||||
// Set the AgeRating as highest in all the comicInfos
|
||||
series.Metadata.AgeRating = comicInfos.Max(i => ComicInfo.ConvertAgeRatingToEnum(comicInfo.AgeRating));
|
||||
series.Metadata.ReleaseYear = series.Volumes
|
||||
.SelectMany(volume => volume.Chapters).Min(c => c.ReleaseDate.Year);
|
||||
|
||||
var genres = comicInfos.SelectMany(i => i.Genre.Split(",")).Distinct().ToList();
|
||||
var people = series.Volumes.SelectMany(volume => volume.Chapters).SelectMany(c => c.People).ToList();
|
||||
|
||||
|
@ -280,7 +298,6 @@ public class MetadataService : IMetadataService
|
|||
GenreHelper.UpdateGenre(allGenres, genres, false, genre => GenreHelper.AddGenreIfNotExists(series.Metadata.Genres, genre));
|
||||
GenreHelper.KeepOnlySameGenreBetweenLists(series.Metadata.Genres, genres.Select(g => DbFactory.Genre(g, false)).ToList(),
|
||||
genre => series.Metadata.Genres.Remove(genre));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -324,6 +341,7 @@ public class MetadataService : IMetadataService
|
|||
/// <param name="forceUpdate">Force updating cover image even if underlying file has not been modified or chapter already has a cover image</param>
|
||||
public async Task RefreshMetadata(int libraryId, bool forceUpdate = false)
|
||||
{
|
||||
// TODO: Think about splitting the comicinfo stuff into a separate task
|
||||
var library = await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(libraryId, LibraryIncludes.None);
|
||||
_logger.LogInformation("[MetadataService] Beginning metadata refresh of {LibraryName}", library.Name);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue