diff --git a/api/song.js b/api/song.js index a2b7348..f23791e 100644 --- a/api/song.js +++ b/api/song.js @@ -2,27 +2,7 @@ const request = require('request') module.exports = async (app, req, res) => { - // temporary solution until song api is re-enabled - - if (req.offline) return res.send('-1') - - let songID = req.params.song - req.gdRequest('getGJSongInfo', {songID: songID}, function(err, resp, body) { - if (err || !body || body.startsWith("<")) return res.send('-1') - else if (body < 0) return res.send(false) - request.get('https://www.newgrounds.com/audio/listen/' + songID, function(err2, resp2, song) { - console.log(resp2.statusCode) - return res.send(resp2.statusCode == 200) - }) - }) -} - - - //////////////////////////////////////////////////// - // RobTop disabled his song checking page soo.... // - //////////////////////////////////////////////////// - - /* let info = {error: true, exists: false, artist: { name: "", scouted: false, whitelisted: false }, song: { name: "", externalUse: false, allowed: false } } + let info = {error: true, exists: false, artist: { name: "", scouted: false, whitelisted: false }, song: { name: "", externalUse: false, allowed: false } } if (req.offline) return res.send(info) @@ -32,7 +12,7 @@ module.exports = async (app, req, res) => { request.post('http://boomlings.com/database/testSong.php?songID=' + songID, req.gdParams(), function(err, resp, body) { if (err || !body || body == '-1' || body.startsWith("<")) return res.send(info) else if (!body.includes("
")) testError = true - + req.gdRequest('getGJSongInfo', {songID: songID}, function(err2, resp, songAllowed) { if (err2 || !songAllowed || songAllowed < 0 || body.startsWith("<")) return res.send(info) @@ -52,5 +32,4 @@ module.exports = async (app, req, res) => { }) }) - -} */ \ No newline at end of file +} \ No newline at end of file diff --git a/html/api.html b/html/api.html index 888212a..8f2f37d 100644 --- a/html/api.html +++ b/html/api.html @@ -745,12 +745,7 @@
-

Response (1)

-
-

literally just returns true or false (or -1 if there's an error)

-

there used to be more but rob disabled his song api sooo

-
- +
diff --git a/html/level.html b/html/level.html index 2e6dfa1..b94e24d 100644 --- a/html/level.html +++ b/html/level.html @@ -342,18 +342,18 @@ $('#checkSong').click(function() { $('#songLoading').show() fetch(`../api/song/[[SONGID]]`).then(res => res.json()).then(info => { $('#songLoading').hide() - $(info && info != -1 ? '#songAllowed' : '#songNotAllowed').show().addClass('songStatus') - // if (info.error) return - // if (!info.artist.scouted) { - // $('#scout').attr('src', '../assets/x.png') - // $('#scout').attr('title', $('#scout').attr('title').replace('is ', 'is NOT ')) - // $('#scout').css('filter', 'saturate(0.4)') - // } - // if (!info.artist.whitelisted) { - // $('#whitelist').attr('src', '../assets/x.png') - // $('#whitelist').attr('title', $('#whitelist').attr('title').replace('is ', 'is NOT ')) - // } - // $('#scout').show(); $('#whitelist').show() + $(info.song.allowed ? '#songAllowed' : '#songNotAllowed').show().addClass('songStatus') + if (info.error) return + if (!info.artist.scouted) { + $('#scout').attr('src', '../assets/x.png') + $('#scout').attr('title', $('#scout').attr('title').replace('is ', 'is NOT ')) + $('#scout').css('filter', 'saturate(0.4)') + } + if (!info.artist.whitelisted) { + $('#whitelist').attr('src', '../assets/x.png') + $('#whitelist').attr('title', $('#whitelist').attr('title').replace('is ', 'is NOT ')) + } + $('#scout').show(); $('#whitelist').show() }) })