mirror of
https://github.com/Readarr/Readarr
synced 2025-12-27 18:54:54 +01:00
New: Send genres to calibre as tags
This commit is contained in:
parent
3e32f7d49f
commit
eb95fe265a
4 changed files with 17 additions and 0 deletions
|
|
@ -24,6 +24,8 @@ public class CalibreBook
|
|||
|
||||
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 @@ public Dictionary<string, Tuple<string, string>> Diff(CalibreBook other)
|
|||
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));
|
||||
|
|
|
|||
|
|
@ -184,6 +184,9 @@ public void SetFields(BookFile file, CalibreSettings settings, bool updateCover
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ public void SetFields(BookFile file, CalibreSettings settings, bool updateCover
|
|||
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>
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ public class CalibreChanges
|
|||
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; }
|
||||
|
|
|
|||
|
|
@ -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 @@ private IEnumerable<RetagBookFilePreview> GetPreviews(List<BookFile> files)
|
|||
|
||||
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 @@ private IEnumerable<RetagBookFilePreview> GetPreviews(List<BookFile> files)
|
|||
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>
|
||||
|
|
|
|||
Loading…
Reference in a new issue