From b41f54341a75f6c460a94cd134f4533fee729ba3 Mon Sep 17 00:00:00 2001 From: Seia-Soto Date: Fri, 14 Feb 2020 10:39:47 +0900 Subject: [PATCH] Add metadata update automation --- config.js | 4 ++-- utils/anilist/worker/index.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/config.js b/config.js index 37b03c9..a25ab21 100644 --- a/config.js +++ b/config.js @@ -26,10 +26,10 @@ module.exports = { } }, ohys: { - passUpdateAtStart: true, refreshRate: 30 * 1000 }, anilist: { - api: 'https://graphql.anilist.co' + api: 'https://graphql.anilist.co', + refreshRate: 2 * 60 * 60 * 1000 } } diff --git a/utils/anilist/worker/index.js b/utils/anilist/worker/index.js index f243c93..ea3366a 100644 --- a/utils/anilist/worker/index.js +++ b/utils/anilist/worker/index.js @@ -1,3 +1,4 @@ +const config = require('../../../config') const log = require('../../../log') const crypto = require('../../crypto') const database = require('../../database') @@ -71,7 +72,7 @@ class AnilistWorker { hash: crypto.hash.md5(data[k].series) }) - if (!list.includes(data[k].series) && !existingMeta.length) { + if ((!list.includes(data[k].series) && !existingMeta.length) || Date.now() - new Date(existingMeta[0].updated_at) > config.anilist.refreshRate) { list.push(data[k].series) this.enqueue(data[k].series) }