Oops, committed broken code

check for album cover existing
This commit is contained in:
MeowcaTheoRange 2024-02-21 10:43:48 -06:00
parent 3104f0932f
commit c5f65fda78

View file

@ -99,7 +99,11 @@ async function getVideo() {
async function checkNextcloud({ url, name, channelName }, nextcloudClient) { async function checkNextcloud({ url, name, channelName }, nextcloudClient) {
const fileName = pathGenerator({ url, name, channelName }); const fileName = pathGenerator({ url, name, channelName });
return await nextcloudClient.exists(fileName); return await nextcloudClient.exists(path.join(process.env.NEXTCLOUD_FOLDER, fileName));
}
async function checkNextcloudAlbum({ tags }, nextcloudClient) {
return await nextcloudClient.exists(path.join(process.env.NEXTCLOUD_FOLDER, tags, "cover.png"));
} }
async function downloadFromCobalt({ url }) { async function downloadFromCobalt({ url }) {
@ -167,13 +171,16 @@ async function uploadToNextcloud({ fileStream, url, name, channelName, tags, alb
const fileBufferStream = new PassThrough().end(fileStream); const fileBufferStream = new PassThrough().end(fileStream);
const albumBufferStream = new PassThrough().end(albumCover);
const fileName = pathGenerator({ url, name, channelName }); const fileName = pathGenerator({ url, name, channelName });
await finished(fileBufferStream.pipe(nextcloudClient.createWriteStream(path.join(process.env.NEXTCLOUD_FOLDER, fileName)))); await finished(fileBufferStream.pipe(nextcloudClient.createWriteStream(path.join(process.env.NEXTCLOUD_FOLDER, tags.album, fileName))));
if (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, "cover.png"))));
return fileName; return fileName;
} }
@ -204,7 +211,10 @@ async function main() {
password: process.env.NOTIFICATION_SERVER_PASSWORD password: process.env.NOTIFICATION_SERVER_PASSWORD
}) })
const albumCover = await downloadAlbumCover(video); let albumCover;
if (!(await checkNextcloudAlbum({ ...video }, nextcloudClient))) {
albumCover = await downloadAlbumCover(video);
}
socket.emit('nodeMessage', { socket.emit('nodeMessage', {
message: `Cobalt download starting - ${video.name} from ${video.channelName}`, message: `Cobalt download starting - ${video.name} from ${video.channelName}`,
@ -238,7 +248,7 @@ async function main() {
); );
socket.emit('nodeMessage', { socket.emit('nodeMessage', {
message: `Nextcloud upload finished - ${tags.name} from ${tags.channelName}`, message: `Nextcloud upload finished - ${video.name} from ${video.channelName}`,
password: process.env.NOTIFICATION_SERVER_PASSWORD password: process.env.NOTIFICATION_SERVER_PASSWORD
}) })