From 062f7f8386106dfbc143f5180b93810993976ee5 Mon Sep 17 00:00:00 2001 From: Lynn Smeria Date: Thu, 30 Aug 2018 16:48:15 +0200 Subject: [PATCH] Transform arrays in native tags into `transformed` --- .eslintrc.yaml | 2 ++ package.json | 2 +- src/tags.js | 23 ++++++++++++++++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 888dd18..9f93d72 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -6,3 +6,5 @@ env: extends: - airbnb-base - prettier +rules: + no-param-reassign: off diff --git a/package.json b/package.json index b530d52..717144b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "publikator", - "version": "0.17.0", + "version": "0.17.1", "main": "index.js", "repository": "https://github.com/aengl/publikator.git", "author": "Lynn Smeria ", diff --git a/src/tags.js b/src/tags.js index a8ebc3b..fdaf006 100644 --- a/src/tags.js +++ b/src/tags.js @@ -6,12 +6,29 @@ module.exports = { /** * Reads tags from a track. */ - readTags: file => - mm.parseFile(file, { + readTags: async file => { + const metaData = await mm.parseFile(file, { duration: true, native: true, skipCovers: true, - }), + }); + // Transform arrays to objects, so we can access them easily in Jekyll + metaData.transformed = _.transform( + metaData.native, + (result, value, key) => { + result[key] = value.reduce((all, item) => { + if (item.value && item.value.text && item.value.description) { + all[item.value.description] = item.value.text; + } else { + all[item.id] = item.value; + } + return all; + }, {}); + }, + {} + ); + return metaData; + }, /** * Extracts the cover art into a file stream.