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