Include cover path
This commit is contained in:
parent
4e2c11aabb
commit
7c8138c386
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "publikator",
|
"name": "publikator",
|
||||||
"version": "0.5.0",
|
"version": "0.6.0",
|
||||||
"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>",
|
||||||
|
|
|
@ -19,17 +19,16 @@ const getFileName = file =>
|
||||||
const extractCoverArt = async filePath => {
|
const extractCoverArt = async filePath => {
|
||||||
const pictures = await tags.extractCoverArt(filePath);
|
const pictures = await tags.extractCoverArt(filePath);
|
||||||
if (pictures) {
|
if (pictures) {
|
||||||
await Promise.all(
|
const picture = pictures[0];
|
||||||
pictures.map(async picture => {
|
const pictureExt = mime.extension(picture.format);
|
||||||
const pictureExt = mime.extension(picture.format);
|
const picturePath = `${filePath.replace(
|
||||||
const picturePath = `${filePath.replace(
|
path.extname(filePath),
|
||||||
path.extname(filePath),
|
''
|
||||||
''
|
)}.${pictureExt}`;
|
||||||
)}.${pictureExt}`;
|
await fs.writeFile(picturePath, picture.data);
|
||||||
await fs.writeFile(picturePath, picture.data);
|
return picturePath;
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -70,7 +69,7 @@ module.exports = {
|
||||||
const fileName = getFileName(file);
|
const fileName = getFileName(file);
|
||||||
const newPath = path.resolve(root, folderName, fileName);
|
const newPath = path.resolve(root, folderName, fileName);
|
||||||
await fs.copyFile(file.path, newPath);
|
await fs.copyFile(file.path, newPath);
|
||||||
await extractCoverArt(newPath);
|
const coverPath = await extractCoverArt(newPath);
|
||||||
return _.assign(
|
return _.assign(
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
|
@ -79,6 +78,13 @@ module.exports = {
|
||||||
folderName,
|
folderName,
|
||||||
fileName,
|
fileName,
|
||||||
},
|
},
|
||||||
|
coverPath
|
||||||
|
? {
|
||||||
|
coverPath,
|
||||||
|
relativeCoverPath: `${folderName}/${path.basename(coverPath)}`,
|
||||||
|
coverFileName: path.basename(coverPath),
|
||||||
|
}
|
||||||
|
: {},
|
||||||
_.omit(file, 'path')
|
_.omit(file, 'path')
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue