Added official song searching

This commit is contained in:
GDColon 2021-02-01 14:30:40 -05:00
parent b7e1c92d55
commit 71d66458af
16 changed files with 144 additions and 134 deletions

View file

@ -215,7 +215,7 @@ dragscroll.js - Used on several pages for drag scrolling
level.json - An array of the official GD tracks, and also difficulty face stuff for level searching
music.json - An array of the official GD tracks (name, artist)

View file

@ -1,6 +1,7 @@
const request = require('request')
const fs = require('fs')
const Level = require('../classes/Level.js')
module.exports = async (app, req, res, api, ID, analyze) => {
if (req.offline) {
@ -55,24 +56,7 @@ module.exports = async (app, req, res, api, ID, analyze) => {
req.gdRequest('getGJSongInfo', { songID: level.customSong }, function (err, resp, songRes) {
if (!err && songRes != '-1') {
let songData = app.parseResponse(songRes, '~|~')
level.songName = songData[2] || "Unknown"
level.songAuthor = songData[4] || "Unknown"
level.songSize = (songData[5] || "0") + "MB"
level.songID = songData[1] || String(level.customSong)
if (songData[10]) level.songLink = decodeURIComponent(songData[10])
if (!songData[2]) level.invalidSong = true
}
else {
let foundSong = require('../misc/level.json').music[parseInt(levelInfo[12]) + 1] || { "null": true }
level.songName = foundSong[0] || "Unknown"
level.songAuthor = foundSong[1] || "Unknown"
level.songSize = "0MB"
level.songID = "Level " + [parseInt(levelInfo[12]) + 1]
}
level = level.getSongInfo(app.parseResponse(songRes, '~|~'))
level.extraString = levelInfo[36]
level.data = levelInfo[4]
if (req.isGDPS) level.gdps = (req.onePointNine ? "1.9/" : "") + req.endpoint

View file

@ -33,23 +33,7 @@ module.exports = async (app, req, res, api, analyze) => {
song = app.parseResponse(song, '~|~')
let levelInfo = app.parseResponse(preRes[0])
let level = new Level(levelInfo, req.server, false, author)
if (level.customSong) {
level.songName = song[2] || "Unknown"
level.songAuthor = song[4] || "Unknown"
level.songSize = (song[5] || "0") + "MB"
level.songID = song[1] || String(level.customSong)
if (song[10]) level.songLink = decodeURIComponent(song[10])
}
else {
let foundSong = require('../misc/level.json').music[parseInt(levelInfo[12]) + 1] || { "null": true }
level.songName = foundSong[0] || "Unknown"
level.songAuthor = foundSong[1] || "Unknown"
level.songSize = "0MB"
level.songID = "Level " + [parseInt(levelInfo[12]) + 1]
}
let level = new Level(levelInfo, req.server, false, author).getSongInfo(song)
if (req.isGDPS) level.gdps = (req.onePointNine ? "1.9/" : "") + req.endpoint
if (level.author != "-") app.userCache(req.id, level.accountID, level.playerID, level.author)

View file

@ -1,5 +1,5 @@
const request = require('request')
const levels = require('../misc/level.json').music
const music = require('../misc/music.json')
const Level = require('../classes/Level.js')
let demonList = {}
// list: [], lastUpdated: 0
@ -55,10 +55,6 @@ module.exports = async (app, req, res) => {
count: amount
}
if (req.query.songID && filters.customSong == 0 && levels.find(x => req.query.songID.toLowerCase() == x[0].toLowerCase())) {
filters.song = levels.findIndex(x => req.query.songID.toLowerCase() == x[0].toLowerCase())
}
if (req.query.type) {
let filterCheck = req.query.type.toLowerCase()
switch(filterCheck) {
@ -94,7 +90,6 @@ module.exports = async (app, req, res) => {
}
if (filters.str == "*") delete filters.str
req.gdRequest('getGJLevels21', req.gdParams(filters), function(err, resp, body) {
if (err || !body || body == '-1' || body.startsWith("<")) return res.send("-1")
@ -116,27 +111,12 @@ module.exports = async (app, req, res) => {
levelArray.forEach((x, y) => {
let level = new Level(x, req.server)
let songSearch = songs.find(y => y['~1'] == x[35]) || []
let level = new Level(x, req.server).getSongInfo(songSearch)
level.author = authorList[x[6]] ? authorList[x[6]][0] : "-";
level.accountID = authorList[x[6]] ? authorList[x[6]][1] : "0";
if (level.customSong) {
level.songName = app.clean(songSearch[2] || "Unknown")
level.songAuthor = songSearch[4] || "Unknown"
level.songSize = (songSearch[5] || "0") + "MB"
level.songID = songSearch[1] || level.customSong
if (songSearch[10]) level.songLink = decodeURIComponent(songSearch[10])
}
else {
let foundSong = require('../misc/level.json').music[parseInt(x[12]) + 1] || {"null": true}
level.songName = foundSong[0] || "Unknown"
level.songAuthor = foundSong[1] || "Unknown"
level.songSize = "0MB"
level.songID = "Level " + [parseInt(x[12]) + 1]
}
if (demonMode) {
if (!y) level.demonList = req.server.demonList
level.demonPosition = demonList[req.id].list.indexOf(level.id) + 1

View file

@ -1213,6 +1213,10 @@ input::-webkit-inner-spin-button {
color: #ffaaaa;
}
.gray {
filter: grayscale(100%);
}
.grayscale {
filter: grayscale(100%) brightness(0.7);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

BIN
assets/song-custom.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

BIN
assets/song-normal.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View file

@ -1,4 +1,5 @@
const XOR = require(__dirname + "/../classes/XOR");
const music = require(__dirname + "/../misc/music.json");
let orbs = [0, 0, 50, 75, 125, 175, 225, 275, 350, 425, 500]
let length = ['Tiny', 'Short', 'Medium', 'Long', 'XL']
@ -32,7 +33,7 @@ class Level {
this.version = +levelInfo[5];
this.copiedID = levelInfo[30]
this.twoPlayer = levelInfo[31] > 0
this.officialSong = levelInfo[12] != 0 ? parseInt(levelInfo[12]) + 1 : 0
this.officialSong = +levelInfo[35] ? 0 : parseInt(levelInfo[12]) + 1
this.customSong = +levelInfo[35]
this.coins = +levelInfo[37]
this.verifiedCoins = levelInfo[38] > 0
@ -66,6 +67,25 @@ class Level {
if (this.editorTime == 1 && this.totalEditorTime == 2) { this.editorTime = 0; this.totalEditorTime = 0 } // remove GDPS default values
}
getSongInfo(songInfo) {
if (this.customSong) {
this.songName = songInfo[2] || "Unknown"
this.songAuthor = songInfo[4] || "Unknown"
this.songSize = (songInfo[5] || "0") + "MB"
this.songID = songInfo[1] || this.customSong
if (songInfo[10]) this.songLink = decodeURIComponent(songInfo[10])
}
else {
let foundSong = music[this.officialSong] || {"null": true}
this.songName = foundSong[0] || "Unknown"
this.songAuthor = foundSong[1] || "Unknown"
this.songSize = "0MB"
this.songID = "Level " + this.officialSong
}
return this
}
}
module.exports = Level;

View file

@ -23,9 +23,17 @@
<div style="margin-bottom: 6%"><h1><input type="checkbox" id="box-nostar" url="&noStar"><label for="box-nostar" class="gdcheckbox gdButton"></label>No Star</h1></div>
<div><h1><input type="checkbox" id="box-original" url="&original"><label for="box-original" class="gdcheckbox gdButton"></label>Original</h1></div>
<div><h1><input type="checkbox" id="box-2player" url="&twoPlayer"><label for="box-2player" class="gdcheckbox gdButton"></label>2-Player</h1></div>
<div style="margin-bottom: 9%"><h1><input type="checkbox" id="box-coins" url="&coins"><label for="box-coins" class="gdcheckbox gdButton"></label>Coins</h1></div>
<div style="margin-bottom: 5%"><h1><input type="checkbox" id="box-coins" url="&coins"><label for="box-coins" class="gdcheckbox gdButton"></label>Coins</h1></div>
<h1 class="smallerer lessSpaced">Song</h1>
<input id="songID" type="text" placeholder="Song ID or Level Name" style="height: 15%; width: 70%; text-align: center;" maxlength="22">
<img id="normalSong" class="gdButton inline gray" style="margin-right: 0.5%" src="../assets/song-normal.png" height="8%">
<img id="customSong" class="gdButton inline" style="margin-left: 0.5%" src="../assets/song-custom.png" height="8%">
<br>
<input id="songID" type="number" placeholder="Custom Song ID" style="height: 15%; width: 70%; text-align: center; margin-top: 2%" maxlength="22">
<div id="songSelect" style="width: 100%; display: none; margin-top: 3%; text-align: center">
<img style="width: 4%" id="songDown" class="gdButton inline valign songChange" jump="-1" src="../assets/whitearrow-left.png">
<h1 class="inline valign smallerer center" id="songName" style="min-width: 60%"></h1>
<img style="width: 4%" id="songUp" class="gdButton inline valign songChange" jump="1" id="nextSong" src="../assets/whitearrow-right.png">
</div>
</div>
</div>
@ -139,10 +147,14 @@
<script type="text/javascript" src="../sizecheck.js?"></script>
<script>
$('#filters').show()
let filters = []
let minusCheck = []
let demons = []
let demonMode = false;
let demonMode = false
let customSong = true
let officialSong = 1
function undupe(array) {
if (!Array.isArray(array)) return array
@ -180,14 +192,18 @@ $('.levelSearch').click(function() {
// === SONG === //
if ($('#songID').val()) {
let selectedOfficial = customSong ? null : officialSong
let selectedCustom = customSong && $('#songID').val() ? $('#songID').val() : null
let selectedSong = selectedCustom || selectedOfficial
url += "&songID=" + $('#songID').val()
if (/^\d+$/.test($('#songID').val())) url += "&customSong"
if (selectedSong) {
url += "&songID=" + selectedSong
if (customSong) url += "&customSong"
}
if (url.endsWith('?type=0')) url = url.slice(0, -7)
// === FINISHING UP === //
if (url.endsWith('?type=0')) url = url.slice(0, -7)
window.location.href = url.replace(/\?type=0&/, "?")
})
@ -264,14 +280,46 @@ $('#listLevels, #listName').on('input blur', function (event) {
})
// some gdps magic
Fetch(`../api/gdps?current=1`).then(res => {
$('#normalSong').click(function() {
customSong = false
$('#customSong').addClass('gray')
$('#normalSong').removeClass('gray')
$('#songSelect').show()
$('#songID').hide()
})
$('#customSong').click(function() {
customSong = true
$('#normalSong').addClass('gray')
$('#customSong').removeClass('gray')
$('#songID').show()
$('#songSelect').hide()
})
Fetch(`../api/music`).then(music => {
$('#songName').html("1: " + music[1][0])
$(document).on('click', '.songChange', function () {
officialSong += Number($(this).attr('jump'))
if (officialSong < 1) officialSong = 1
$('#songName').html(`${officialSong}: ${music[officialSong] ? music[officialSong][0] : officialSong == 69 ? "Nice" : "Unknown"}`)
})
$(document).keydown(function(k) {
if (customSong) return;
if (k.which == 37) $('#songDown').trigger('click') // left
if (k.which == 39) $('#songUp').trigger('click') // right
});
if (onePointNine) {
$('#userSearch').hide()
$('#followedSearch').addClass('menuDisabled')
$('#levelName').css('width', '76%')
}
if (res.demonList) $('#demonList').show()
if (gdps) Fetch(`../api/gdps?current=1`).then(res => { if (res.demonList) $('#demonList').show() })
else $('#demonList').show()
})
</script>

View file

@ -84,7 +84,7 @@
<p class="bigger center" style="line-height: 6vh; margin-top: 1.5vh;">
Are you sure you want to <span style="color: #F05C5C">delete</span> this message?
</p>
<img src="../assets/btn-cancel.png" height=29%; class="gdButton center" onclick="$('#confirmDelete').hide()">
<img src="../assets/btn-cancel-green.png" height=29%; class="gdButton center" onclick="$('#confirmDelete').hide()">
<img src="../assets/btn-delete.png" height=29%; id="deleteCurrentMessage" class="gdButton center sideSpaceB">
</div>

View file

@ -38,6 +38,7 @@ let achievements = require('./misc/achievements.json')
let achievementTypes = require('./misc/achievementTypes.json')
let shopIcons = require('./misc/shops.json')
let colorList = require('./icons/colors.json')
let music = require('./misc/music.json')
let gdIcons = fs.readdirSync('./assets/previewicons')
let assetPage = fs.readFileSync('./html/assets.html', 'utf8')
@ -74,6 +75,7 @@ app.use(async function(req, res, next) {
req.isGDPS = req.server.endpoint != "http://boomlings.com/database/"
if (req.isGDPS) res.set("gdps", (req.onePointNine ? "1.9/" : "") + req.id)
if (req.query.online > 0) req.offline = false
req.gdParams = function(obj={}, substitute=true) {
Object.keys(app.config.params).forEach(x => { if (!obj[x]) obj[x] = app.config.params[x] })
@ -213,7 +215,7 @@ let downloadDisabled = ['daily', 'weekly']
let gdpsHide = ['achievements', 'messages']
app.get("/", function(req, res) {
if (req.offline && !req.query.hasOwnProperty("home")) res.sendFile(__dirname + "/html/offline.html")
if (req.query.hasOwnProperty("offline") || (req.offline && !req.query.hasOwnProperty("home"))) res.sendFile(__dirname + "/html/offline.html")
else {
fs.readFile('./html/home.html', 'utf8', function (err, data) {
let html = data;
@ -294,6 +296,7 @@ app.get("/icon/:text", function(req, res) { app.run.icon(app, req, res) })
app.get("/api/userCache", function(req, res) { res.send(app.accountCache) })
app.get("/api/gdps", function(req, res) { res.send(req.query.hasOwnProperty("current") ? req.server : app.servers) })
app.get("/api/achievements", function(req, res) { res.send({achievements, types: achievementTypes, shopIcons, colors: colorList }) })
app.get("/api/music", function(req, res) { res.send(music) })
app.get('/api/icons', function(req, res) {
let sample = [JSON.stringify(sampleIcons[Math.floor(Math.random() * sampleIcons.length)].slice(1))]
let iconserver = req.isGDPS ? req.server.name : undefined

View file

@ -1,63 +0,0 @@
{
"music": [
["Stay Inside Me", "OcularNebula"],
["Stereo Madness", "ForeverBound"],
["Back on Track", "DJVI"],
["Polargeist", "Step"],
["Dry Out", "DJVI"],
["Base After Base", "DJVI"],
["Can't Let Go", "DJVI"],
["Jumper", "Waterflame"],
["Time Machine", "Waterflame"],
["Cycles", "DJVI"],
["xStep", "DJVI"],
["Clutterfunk", "Waterflame"],
["Theory of Everything", "DJ-Nate"],
["Electroman Adventures", "Waterflame"],
["Clubstep", "DJ-Nate"],
["Electrodynamix", "DJ-Nate"],
["Hexagon Force", "Waterflame"],
["Blast Processing", "Waterflame"],
["Theory of Everything 2", "DJ-Nate"],
["Geometrical Dominator", "Waterflame"],
["Deadlocked", "F-777"],
["Fingerdash", "MDK"],
["The Seven Seas", "F-777"],
["Viking Arena", "F-777"],
["Airborne Robots", "F-777"],
["The Challenge", "RobTop"],
["Payload", "Dex Arson"],
["Beast Mode", "Dex Arson"],
["Machina", "Dex Arson"],
["Years", "Dex Arson"],
["Frontlines", "Dex Arson"],
["Space Pirates", "Waterflame"],
["Striker", "Waterflame"],
["Embers", "Dex Arson"],
["Round 1", "Dex Arson"],
["Monster Dance Off", "F-777"],
["Press Start", "MDK"],
["Nock Em", "Bossfight"],
["Power Trip", "Boom Kitty"]
],
"difficulties": {
"easy": "1",
"normal": "2",
"hard": "3",
"harder": "4",
"insane": "5",
"demon": "-2",
"easydemon": "-2&demonFilter=1",
"mediumdemon": "-2&demonFilter=2",
"harddemon": "-2&demonFilter=3",
"insanedemon": "-2&demonFilter=4",
"extremedemon": "-2&demonFilter=5",
"auto": "-3",
"unrated": "-1",
"na": "-1",
"n/a": "-1"
}
}

41
misc/music.json Normal file
View file

@ -0,0 +1,41 @@
[
["Stay Inside Me", "OcularNebula"],
["Stereo Madness", "ForeverBound"],
["Back on Track", "DJVI"],
["Polargeist", "Step"],
["Dry Out", "DJVI"],
["Base After Base", "DJVI"],
["Can't Let Go", "DJVI"],
["Jumper", "Waterflame"],
["Time Machine", "Waterflame"],
["Cycles", "DJVI"],
["xStep", "DJVI"],
["Clutterfunk", "Waterflame"],
["Theory of Everything", "DJ-Nate"],
["Electroman Adventures", "Waterflame"],
["Clubstep", "DJ-Nate"],
["Electrodynamix", "DJ-Nate"],
["Hexagon Force", "Waterflame"],
["Blast Processing", "Waterflame"],
["Theory of Everything 2", "DJ-Nate"],
["Geometrical Dominator", "Waterflame"],
["Deadlocked", "F-777"],
["Fingerdash", "MDK"],
["The Seven Seas", "F-777"],
["Viking Arena", "F-777"],
["Airborne Robots", "F-777"],
["The Challenge", "RobTop"],
["Payload", "Dex Arson"],
["Beast Mode", "Dex Arson"],
["Machina", "Dex Arson"],
["Years", "Dex Arson"],
["Frontlines", "Dex Arson"],
["Space Pirates", "Waterflame"],
["Striker", "Waterflame"],
["Embers", "Dex Arson"],
["Round 1", "Dex Arson"],
["Monster Dance Off", "F-777"],
["Press Start", "MDK"],
["Nock Em", "Bossfight"],
["Power Trip", "Boom Kitty"]
]

View file

@ -89,6 +89,15 @@
"endpoint": "http://cnekgdps.7m.pl/cnekgdpsdtb/"
},
{
"name": "Zombie Dash",
"link": "http://zombiedashoficial.ddns.net/",
"author": "Ghost Power 13",
"authorLink": "https://www.youtube.com/channel/UCC_S4bHTIGVJiCfZsKU15Gw",
"id": "zombiedash",
"endpoint": "http://zombiedashoficial.ddns.net/"
},
{
"name": "Geometry Dash Gravity",
"link": "https://discord.gg/qpUJgBC",