diff --git a/index.js b/index.js index 5614f26..58caa27 100644 --- a/index.js +++ b/index.js @@ -96,14 +96,14 @@ async function getVideo() { }; } -async function checkNextcloud({ url, name, channelName }, nextcloudClient) { +async function checkNextcloud({ url, name, channelName, tags }, nextcloudClient) { const fileName = pathGenerator({ url, name, channelName }); - return await nextcloudClient.exists(path.join(process.env.NEXTCLOUD_FOLDER, fileName)); + return await nextcloudClient.exists(path.join(process.env.NEXTCLOUD_FOLDER, tags.album, fileName)); } async function checkNextcloudAlbum({ tags }, nextcloudClient) { - return await nextcloudClient.exists(path.join(process.env.NEXTCLOUD_FOLDER, tags, "cover.png")); + return await nextcloudClient.exists(path.join(process.env.NEXTCLOUD_FOLDER, tags.album, "cover.png")); } async function downloadFromCobalt({ url }) { @@ -177,7 +177,7 @@ async function uploadToNextcloud({ fileStream, url, name, channelName, tags, alb if (albumCover) { const albumBufferStream = new PassThrough().end(albumCover); - + await finished(albumBufferStream.pipe(nextcloudClient.createWriteStream(path.join(process.env.NEXTCLOUD_FOLDER, tags.album, "cover.png")))); } @@ -212,7 +212,7 @@ async function main() { }) let albumCover; - if (!(await checkNextcloudAlbum({ ...video }, nextcloudClient))) { + if (!(await checkNextcloudAlbum(video, nextcloudClient))) { albumCover = await downloadAlbumCover(video); }