New: Send genres to calibre as tags

This commit is contained in:
ta264
2021-12-09 21:55:13 +00:00
parent 3e32f7d49f
commit eb95fe265a
4 changed files with 17 additions and 0 deletions

View File

@@ -24,6 +24,8 @@ namespace NzbDrone.Core.Books.Calibre
public List<string> Languages { get; set; }
public List<string> Tags { get; set; }
public string Comments { get; set; }
public double Rating { get; set; }
@@ -72,6 +74,11 @@ namespace NzbDrone.Core.Books.Calibre
output.Add("Languages", Tuple.Create(string.Join(" / ", Languages), string.Join(" / ", other.Languages)));
}
if (!Tags.OrderBy(x => x).SequenceEqual(other.Tags.OrderBy(x => x)))
{
output.Add("Tags", Tuple.Create(string.Join(" / ", Tags), string.Join(" / ", other.Tags)));
}
if (Comments != other.Comments)
{
output.Add("Comments", Tuple.Create(Comments, other.Comments));

View File

@@ -184,6 +184,9 @@ namespace NzbDrone.Core.Books.Calibre
}
}
var textInfo = CultureInfo.InvariantCulture.TextInfo;
var genres = book.Genres.Select(x => textInfo.ToTitleCase(x.Replace('-', ' '))).ToList();
var payload = new CalibreChangesPayload
{
LoadedBookIds = new List<int> { file.CalibreId },
@@ -195,6 +198,7 @@ namespace NzbDrone.Core.Books.Calibre
PubDate = book.ReleaseDate,
Publisher = edition.Publisher,
Languages = edition.Language.CanonicalizeLanguage(),
Tags = genres,
Comments = edition.Overview,
Rating = (int)(edition.Ratings.Value * 2),
Identifiers = new Dictionary<string, string>

View File

@@ -20,6 +20,7 @@ namespace NzbDrone.Core.Books.Calibre
public DateTime? PubDate { get; set; }
public string Publisher { get; set; }
public string Languages { get; set; }
public List<string> Tags { get; set; }
public string Comments { get; set; }
public decimal Rating { get; set; }
public Dictionary<string, string> Identifiers { get; set; }

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.IO.Abstractions;
using System.Linq;
@@ -226,6 +227,9 @@ namespace NzbDrone.Core.MediaFiles
var oldTags = dict[file.CalibreId];
var textInfo = CultureInfo.InvariantCulture.TextInfo;
var genres = book.Genres.Select(x => textInfo.ToTitleCase(x.Replace('-', ' '))).ToList();
var newTags = new CalibreBook
{
Title = edition.Title,
@@ -233,6 +237,7 @@ namespace NzbDrone.Core.MediaFiles
PubDate = book.ReleaseDate,
Publisher = edition.Publisher,
Languages = new List<string> { edition.Language.CanonicalizeLanguage() },
Tags = genres,
Comments = edition.Overview,
Rating = (int)(edition.Ratings.Value * 2) / 2.0,
Identifiers = new Dictionary<string, string>