This commit is contained in:
MeowcaTheoRange 2024-02-21 12:07:18 -06:00
parent c5f65fda78
commit 2b8a8fde1b

View file

@ -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 }); 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) { 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 }) { async function downloadFromCobalt({ url }) {
@ -177,7 +177,7 @@ async function uploadToNextcloud({ fileStream, url, name, channelName, tags, alb
if (albumCover) { if (albumCover) {
const albumBufferStream = new PassThrough().end(albumCover); const albumBufferStream = new PassThrough().end(albumCover);
await finished(albumBufferStream.pipe(nextcloudClient.createWriteStream(path.join(process.env.NEXTCLOUD_FOLDER, tags.album, "cover.png")))); 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; let albumCover;
if (!(await checkNextcloudAlbum({ ...video }, nextcloudClient))) { if (!(await checkNextcloudAlbum(video, nextcloudClient))) {
albumCover = await downloadAlbumCover(video); albumCover = await downloadAlbumCover(video);
} }