From 8cbde0fdb5f1946118192ee01407b24d962fdd94 Mon Sep 17 00:00:00 2001 From: Martchus Date: Wed, 13 Feb 2019 21:42:50 +0100 Subject: [PATCH] renaming utility: Support album artist --- renamingutility/tageditorobject.cpp | 9 +++++---- resources/scripts/renamefiles/example1.js | 12 +++++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/renamingutility/tageditorobject.cpp b/renamingutility/tageditorobject.cpp index 0f7282e..653653b 100644 --- a/renamingutility/tageditorobject.cpp +++ b/renamingutility/tageditorobject.cpp @@ -46,10 +46,11 @@ TAGEDITOR_JS_VALUE &operator<<(TAGEDITOR_JS_VALUE &diagObject, const Diagnostics TAGEDITOR_JS_VALUE &operator<<(TAGEDITOR_JS_VALUE &tagObject, const Tag &tag) { // add text fields - static const char *fieldNames[] = { "title", "artist", "album", "year", "comment", "genre", "encoder", "language", "description", nullptr }; - static const KnownField fields[] = { KnownField::Title, KnownField::Artist, KnownField::Album, KnownField::Year, KnownField::Comment, - KnownField::Genre, KnownField::Encoder, KnownField::Language, KnownField::Description }; - const char **fieldName = fieldNames; + static const char *const fieldNames[] + = { "title", "artist", "albumartist", "album", "year", "comment", "genre", "encoder", "language", "description", nullptr }; + static const KnownField fields[] = { KnownField::Title, KnownField::Artist, KnownField::AlbumArtist, KnownField::Album, KnownField::Year, + KnownField::Comment, KnownField::Genre, KnownField::Encoder, KnownField::Language, KnownField::Description }; + const char *const *fieldName = fieldNames; const KnownField *field = fields; for (; *fieldName; ++fieldName, ++field) { try { diff --git a/resources/scripts/renamefiles/example1.js b/resources/scripts/renamefiles/example1.js index f4d881c..4c90fb5 100644 --- a/resources/scripts/renamefiles/example1.js +++ b/resources/scripts/renamefiles/example1.js @@ -114,8 +114,11 @@ if (fileInfo.currentSuffix === "tmp") { // define an array for the fields to be joined later var fields = [] -// get the artist, remove invalid characters and add it to fields array -var artist = validFileName(tag.artist) +// get the artist (preferably album artist), remove invalid characters and add it to fields array +var artist = validFileName(tag.albumartist) +if (artist.length === 0) { + artist = validFileName(tag.artist) +} if (includeArtist && !isPartOfCollection(tag) && notEmpty(artist)) { fields.push(artist) } @@ -183,7 +186,10 @@ if (!distDir) { return } var path = [distDir] -var artist = validDirectoryName(tag.artist) +var artist = validDirectoryName(tag.albumartist) +if (artist.length === 0) { + artist = validDirectoryName(tag.artist) +} if (isPartOfCollection(tag)) { path.push(collectionsDir) } else if (isMiscFile(tag)) {