updating time to 10s timeout and adding channel to redis to check if is already downloaded

This commit is contained in:
unknown 2023-03-25 13:27:23 +01:00
parent d5f3a89231
commit bec646149f
1 changed files with 8 additions and 2 deletions

View File

@ -15,7 +15,13 @@ async function handleCheck() {
const channels = await prisma.autodownload.findMany() const channels = await prisma.autodownload.findMany()
for (c of channels) { for (c of channels) {
if (await redis.get(c.channel)) {
logger.info({ message: `${c.channel} is already being downloaded` })
} else {
await redis.set(c.channel, 'downloading')
await handleDownload(c.channel) await handleDownload(c.channel)
await redis.del(c.channel)
}
} }
} }
@ -49,7 +55,7 @@ async function handleDownload(channelId) {
await redis.set(id, 'downloading') await redis.set(id, 'downloading')
downloadIndex++ downloadIndex++
await delay(downloadIndex * 15000) await delay(downloadIndex * 10000)
logger.info({ message: `Starting to download ${video.title}, ${id}` }) logger.info({ message: `Starting to download ${video.title}, ${id}` })