mirror of
https://github.com/Viren070/stremio-addons-list.git
synced 2025-12-01 23:19:02 +01:00
Get Data For When Manifests Were Last Reached From Cache
This commit is contained in:
+17
-1
@@ -2,6 +2,12 @@
|
||||
const needle = require('needle')
|
||||
const config = require('../config')
|
||||
|
||||
function isObject(obj) {
|
||||
return typeof obj === 'object' &&
|
||||
!Array.isArray(obj) &&
|
||||
obj !== null
|
||||
}
|
||||
|
||||
const getCached = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const cached = { catalog: [] }
|
||||
@@ -21,7 +27,17 @@ const getCached = () => {
|
||||
} else {
|
||||
console.log('warning: could not load old addon catalog')
|
||||
}
|
||||
resolve(cached)
|
||||
|
||||
needle.get(`https://${config['netlify-domain']}/lastReached.json`, config.needle, (err, resp, body) => {
|
||||
if (body && isObject(body) && Object.keys(body).length) {
|
||||
console.log('loaded last reached data')
|
||||
cached.lastReached = body
|
||||
} else {
|
||||
cached.lastReached = {}
|
||||
console.log('warning: could not last reached data')
|
||||
}
|
||||
resolve(cached)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user