From 42a06409c4452510ec858294271c35d7191bd39e Mon Sep 17 00:00:00 2001 From: GDColon Date: Thu, 17 Oct 2019 00:22:20 -0400 Subject: [PATCH] Integrated Demon List! --- api/download.js | 17 ++++++++++++++++- html/api.html | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/api/download.js b/api/download.js index a169490..306c813 100644 --- a/api/download.js +++ b/api/download.js @@ -116,7 +116,9 @@ module.exports = async (app, req, res, api, ID, analyze) => { level.data = levelInfo[4] if (analyze) return app.modules.analyze(app, req, res, level) - else if (api) return res.send(level) + + function sendLevel() { + if (api) return res.send(level) else return fs.readFile('./html/level.html', 'utf8', function(err, data) { let html = data; @@ -127,6 +129,19 @@ module.exports = async (app, req, res, api, ID, analyze) => { }) return res.send(html) }) + } + + //demon list stuff + if (level.difficulty == "Extreme Demon") { + request.get('https://www.pointercrate.com/api/v1/demons/', async function(err, resp, demonList) { + let demons = JSON.parse(demonList) + let foundDemon = demons.find(x => x.name.trim().toLowerCase() == level.name.trim().toLowerCase()) + if (foundDemon) level.demonList = foundDemon.position + return sendLevel() + }) + } + + else return sendLevel() }) }) diff --git a/html/api.html b/html/api.html index a7ab940..4438476 100644 --- a/html/api.html +++ b/html/api.html @@ -114,6 +114,7 @@

songAuthor: The name of the author of said song

songSize: The size of the song in megabytes, if a custom song was used

songID: The ID of the song (again). If a non-custom song was used, this will return a string with the level number of the song

+

demonList: The level's position on the Demon List (Pointercrate). Extreme demons only

uploaded: Time since the level was uploaded (sent as "x days/weeks/months" ago, since it's all the API sends)

updated: Time since the level was last updated

password: The password to copy the level. 0 means the level isn't copyable and 1 means it's free to copy