From a0e2747004acddf110d39c754a2ffa738d0faa2e Mon Sep 17 00:00:00 2001 From: ta264 Date: Thu, 10 Jun 2021 21:51:12 +0100 Subject: [PATCH] New: More granular book year naming tokens --- .../MediaManagement/Naming/NamingModal.js | 4 +++- .../Organizer/FileNameBuilder.cs | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/frontend/src/Settings/MediaManagement/Naming/NamingModal.js b/frontend/src/Settings/MediaManagement/Naming/NamingModal.js index 0008ab534..c66eff38b 100644 --- a/frontend/src/Settings/MediaManagement/Naming/NamingModal.js +++ b/frontend/src/Settings/MediaManagement/Naming/NamingModal.js @@ -63,7 +63,9 @@ const bookTokens = [ ]; const releaseDateTokens = [ - { token: '{Release Year}', example: '2016' } + { token: '{Release Year}', example: '2016' }, + { token: '{Release YearFirst}', example: '2015' }, + { token: '{Edition Year}', example: '2016' } ]; const qualityTokens = [ diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs index cdbc6e684..f8f8cbf39 100644 --- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -244,10 +244,32 @@ namespace NzbDrone.Core.Organizer { tokenHandlers["{Release Year}"] = m => edition.ReleaseDate.Value.Year.ToString(); } + else if (edition.Book.Value.ReleaseDate.HasValue) + { + tokenHandlers["{Release Year}"] = m => edition.Book.Value.ReleaseDate.Value.Year.ToString(); + } else { tokenHandlers["{Release Year}"] = m => "Unknown"; } + + if (edition.ReleaseDate.HasValue) + { + tokenHandlers["{Edition Year}"] = m => edition.ReleaseDate.Value.Year.ToString(); + } + else + { + tokenHandlers["{Edition Year}"] = m => "Unknown"; + } + + if (edition.Book.Value.ReleaseDate.HasValue) + { + tokenHandlers["{Release YearFirst}"] = m => edition.Book.Value.ReleaseDate.Value.Year.ToString(); + } + else + { + tokenHandlers["{Release YearFirst}"] = m => "Unknown"; + } } private void AddBookFileTokens(Dictionary> tokenHandlers, BookFile bookFile)