Transform arrays in native tags into transformed
This commit is contained in:
parent
e466b92b3a
commit
062f7f8386
|
@ -6,3 +6,5 @@ env:
|
||||||
extends:
|
extends:
|
||||||
- airbnb-base
|
- airbnb-base
|
||||||
- prettier
|
- prettier
|
||||||
|
rules:
|
||||||
|
no-param-reassign: off
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "publikator",
|
"name": "publikator",
|
||||||
"version": "0.17.0",
|
"version": "0.17.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": "https://github.com/aengl/publikator.git",
|
"repository": "https://github.com/aengl/publikator.git",
|
||||||
"author": "Lynn Smeria <ae@cephea.de>",
|
"author": "Lynn Smeria <ae@cephea.de>",
|
||||||
|
|
23
src/tags.js
23
src/tags.js
|
@ -6,12 +6,29 @@ module.exports = {
|
||||||
/**
|
/**
|
||||||
* Reads tags from a track.
|
* Reads tags from a track.
|
||||||
*/
|
*/
|
||||||
readTags: file =>
|
readTags: async file => {
|
||||||
mm.parseFile(file, {
|
const metaData = await mm.parseFile(file, {
|
||||||
duration: true,
|
duration: true,
|
||||||
native: true,
|
native: true,
|
||||||
skipCovers: 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.
|
* Extracts the cover art into a file stream.
|
||||||
|
|
Loading…
Reference in a new issue