mirror of
https://github.com/ibratabian17/OpenParty.git
synced 2026-01-15 14:22:54 -03:00
Add Layered Data ability
This commit is contained in:
22
README.md
22
README.md
@@ -24,9 +24,25 @@ This project is an effort by ibratabian17 to provide an alternative server to Ju
|
||||
|
||||
## Directory Structure
|
||||
|
||||
- **database/Platforms/openparty-all/songdbs.json**: contains the song database.
|
||||
- **database/nohud/chunk.json**: contains no-HUD configuration.
|
||||
- **database/Platforms/jd2017-{Platform}/**: contains sku packages.
|
||||
The directory structure of OpenParty is organized to facilitate ease of access and modification of the server's functionalities and data. Here's a detailed breakdown:
|
||||
|
||||
### `database/Platforms/openparty-all/songdbs.json`
|
||||
- **Purpose**: Contains the song database.
|
||||
- **Description**: This JSON file holds the list of songs available on the server. Users can edit this file to customize the song list without changing the server code. If a song list is found in the `SaveData`, it will override this file, allowing dynamic changes without needing to restart the server.
|
||||
|
||||
### `database/nohud/chunk.json`
|
||||
- **Purpose**: Contains no-HUD Videos.
|
||||
- **Description**: This JSON file manages the HUD-less video of the game. Similar to the song database, if a configuration file is in `SaveData`, it will take precedence over this file, making it easy to quickly adjust settings.
|
||||
|
||||
### `database/Platforms/jd2017-{Platform}/sku-packages.json`
|
||||
- **Purpose**: Contains SKU packages.
|
||||
- **Description**: This directory includes platform-specific SKU packages, which are bundles of songs and content specific to a version or platform of Just Dance. These can be tailored to suit different platforms such as PC, Xbox, or PlayStation. The platform-specific files in the `SaveData` directory will override these if available, providing an easy way to customize content per platform without altering the base server files.
|
||||
|
||||
### SaveData Directory
|
||||
- **Purpose**: Overrides default settings and data.
|
||||
- **Description**: The `SaveData` directory is used to store user-specific or modified versions of the data files and settings. If a file exists in this directory, it will automatically override the corresponding file in the `database` directory. This hierarchical file structure allows users to make changes to configurations, song lists, and other settings without touching the core server code. They can simply reload the server to apply changes, enhancing flexibility and user control.
|
||||
|
||||
In summary, the directory structure and the layered data in OpenParty make it easy for users to customize and manage the server. By placing custom files in the `SaveData` directory, users can override default settings and data provided by the server, ensuring that modifications are both simple and reversible.
|
||||
|
||||
## Configuration of settings.json
|
||||
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
console.log(`[CAROUSEL] Initializing....`);
|
||||
|
||||
const { CloneObject, readDatabaseJson } = require('../helper');
|
||||
const { CloneObject, readDatabaseJson, loadJsonFile } = require('../helper');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const cClass = require("./classList.json");
|
||||
const songdb = require("../../database/Platforms/openparty-all/songdbs.json");
|
||||
const songdb = loadJsonFile('Platforms/openparty-all/songdbs.json', '../database/Platforms/openparty-all/songdbs.json');
|
||||
const helper = require('../helper')
|
||||
var mostPlayed = {}
|
||||
|
||||
if (fs.existsSync(path.join(helper.getSavefilePath(), 'carousel/mostplayed.json'))) {
|
||||
mostPlayed = require(path.join(helper.getSavefilePath(), 'carousel/mostplayed.json'));
|
||||
} else if (fs.existsSync(`${__dirname}/../../database/carousel/mostplayed.json`)) {
|
||||
mostPlayed = require(`${__dirname}/../../database/carousel/mostplayed.json`)
|
||||
}
|
||||
mostPlayed = loadJsonFile('carousel/mostplayed.json', '../database/carousel/mostplayed.json');
|
||||
var carousel = {}; //avoid list cached
|
||||
|
||||
const WEEKLY_PLAYLIST_PREFIX = 'DFRecommendedFU';
|
||||
|
||||
@@ -12,6 +12,7 @@ function CloneObject(ObjectC) {
|
||||
function readDatabaseJson(path) {
|
||||
return JSON.parse(fs.readFileSync(`${__dirname}/../database/${path}`, 'utf8'));
|
||||
}
|
||||
var donotlog = {}
|
||||
|
||||
downloader.getJson = async (url, options) => {
|
||||
const response = await axios.get(url, options);
|
||||
@@ -56,7 +57,20 @@ if (!fs.existsSync(getSavefilePath())) {
|
||||
fs.mkdirSync(path.join(getSavefilePath(), 'server-log'), { recursive: true });
|
||||
}
|
||||
|
||||
function loadJsonFile(layeredPath, originalPath) {
|
||||
const savedDataPath = path.join(getSavefilePath(), layeredPath);
|
||||
if (fs.existsSync(savedDataPath)) {
|
||||
return require(savedDataPath);
|
||||
} else {
|
||||
if (!donotlog[path.basename(savedDataPath)]) {
|
||||
console.log(`[HELPER] Serving ${path.basename(savedDataPath)} from Static Database`)
|
||||
donotlog[path.basename(savedDataPath)] = true
|
||||
}
|
||||
return require(originalPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
CloneObject, readDatabaseJson, downloader, extractSkuIdInfo, getSavefilePath
|
||||
CloneObject, readDatabaseJson, downloader, extractSkuIdInfo, getSavefilePath, loadJsonFile
|
||||
}
|
||||
@@ -1,28 +1,29 @@
|
||||
//Songdbs Property
|
||||
const settings = require('../../settings.json')
|
||||
const fs = require('fs');
|
||||
const path = require('path')
|
||||
const { loadJsonFile } = require('../helper')
|
||||
const songdbF = {}
|
||||
const main = {
|
||||
songdb: { "2016": {}, "2017": {}, "2018": {}, "2019": {}, "2020": {}, "2021": {}, "2022": {} },
|
||||
localisation: require('../../database/Platforms/openparty-all/localisation.json')
|
||||
localisation: {}
|
||||
}
|
||||
songdbF.db = {}
|
||||
|
||||
//Use layered songdb if available
|
||||
main.localisation = loadJsonFile('Platforms/openparty-all/localisation.json', '../database/Platforms/openparty-all/localisation.json');
|
||||
songdbF.db = loadJsonFile('Platforms/openparty-all/songdbs.json', '../database/Platforms/openparty-all/songdbs.json');
|
||||
|
||||
songdbF.db = require('../../database/Platforms/openparty-all/songdbs.json')
|
||||
songdbF.missingAssets = { pc: [] }
|
||||
songdbF.assetsPlaceholder = {
|
||||
"banner_bkgImageUrl": "https://cdn.discordapp.com/attachments/1119503808653959218/1119518680733192222/New_Project_82_Copy_0ED1403.png",
|
||||
"coach1ImageUrl": "https://jd-s3.cdn.ubi.com/public/map/WantUBack/x1/WantUBack_Coach_1.tga.ckd/5e3b1feb1e38f523cbab509a1590df59.ckd",
|
||||
"phoneCoach1ImageUrl": "https://jd-s3.cdn.ubi.com/public/map/WantUBack/WantUBack_Coach_1_Phone.png/5541105eacbc52648bd1462e564d2680.png",
|
||||
"coach2ImageUrl": "https://jd-s3.cdn.ubi.com/public/map/WantUBack/x1/WantUBack_Coach_1.tga.ckd/5e3b1feb1e38f523cbab509a1590df59.ckd",
|
||||
"phoneCoach2ImageUrl": "https://jd-s3.cdn.ubi.com/public/map/WantUBack/WantUBack_Coach_1_Phone.png/5541105eacbc52648bd1462e564d2680.png",
|
||||
"coach3ImageUrl": "https://jd-s3.cdn.ubi.com/public/map/WantUBack/x1/WantUBack_Coach_1.tga.ckd/5e3b1feb1e38f523cbab509a1590df59.ckd",
|
||||
"phoneCoach3ImageUrl": "https://jd-s3.cdn.ubi.com/public/map/WantUBack/WantUBack_Coach_1_Phone.png/5541105eacbc52648bd1462e564d2680.png",
|
||||
"coach4ImageUrl": "https://jd-s3.cdn.ubi.com/public/map/WantUBack/x1/WantUBack_Coach_1.tga.ckd/5e3b1feb1e38f523cbab509a1590df59.ckd",
|
||||
"phoneCoach4ImageUrl": "https://jd-s3.cdn.ubi.com/public/map/WantUBack/WantUBack_Coach_1_Phone.png/5541105eacbc52648bd1462e564d2680.png",
|
||||
"coverImageUrl": "https://jd-s3.cdn.ubi.com/public/map/WantUBack/x1/WantUBack_Cover_Generic.tga.ckd/f61d769f960444bec196d94cfd731185.ckd",
|
||||
"cover_1024ImageUrl": "https://jd-s3.cdn.ubi.com/public/map/WantUBack/WantUBack_Cover_1024.png/9e82873097800b27569f197e0ce848cd.png",
|
||||
"cover_smallImageUrl": "https://cdn.discordapp.com/attachments/1119503808653959218/1119518681039384627/New_Project_82_8981698.png",
|
||||
"expandBkgImageUrl": "https://jd-s3.cdn.ubi.com/public/map/WantUBack/x1/WantUBack_Cover_AlbumBkg.tga.ckd/6442844a971a9690bd2bf43f1f635696.ckd",
|
||||
"expandCoachImageUrl": "https://jd-s3.cdn.ubi.com/public/map/WantUBack/x1/WantUBack_Cover_AlbumCoach.tga.ckd/dc01eb7b94e0b10c0f52a0383e51312e.ckd",
|
||||
"phoneCoverImageUrl": "https://cdn.discordapp.com/attachments/1119503808653959218/1119518681039384627/New_Project_82_8981698.png",
|
||||
"videoPreviewVideoURL": "",
|
||||
"map_bkgImageUrl": "https://cdn.discordapp.com/attachments/1119503808653959218/1119518680733192222/New_Project_82_Copy_0ED1403.png"
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ var md5 = require('md5');
|
||||
const core = {
|
||||
main: require('../var').main,
|
||||
CloneObject: require('../helper').CloneObject,
|
||||
loadJsonFile: require('../helper').loadJsonFile,
|
||||
generateCarousel: require('../carousel/carousel').generateCarousel, generateSweatCarousel: require('../carousel/carousel').generateSweatCarousel, generateCoopCarousel: require('../carousel/carousel').generateCoopCarousel, updateMostPlayed: require('../carousel/carousel').updateMostPlayed,
|
||||
signer: require('../lib/signUrl')
|
||||
}
|
||||
@@ -13,6 +14,9 @@ const path = require('path');
|
||||
const signer = require('../lib/signUrl')
|
||||
const deployTime = Date.now()
|
||||
|
||||
//load nohud list
|
||||
const chunk = core.loadJsonFile('nohud/chunk.json', '../database/nohud/chunk.json');
|
||||
|
||||
function checkAuth(req, res) {
|
||||
if (req.header('X-SkuId')) {
|
||||
if (!(req.header('X-SkuId').startsWith("jd") || req.header('X-SkuId').startsWith("JD")) || !req.headers["authorization"].startsWith("Ubi")) {
|
||||
@@ -337,7 +341,6 @@ exports.initroute = (app, express, server) => {
|
||||
app.get('/content-authorization/v1/maps/*', (req, res) => {
|
||||
if (checkAuth(req, res)) {
|
||||
var maps = req.url.split("/").pop();
|
||||
const chunk = require('../../database/nohud/chunk.json');
|
||||
try {
|
||||
if (chunk[maps]) {
|
||||
var placeholder = core.CloneObject(require('../../database/nohud/placeholder.json'))
|
||||
|
||||
15
core/var.js
15
core/var.js
@@ -1,5 +1,6 @@
|
||||
const axios = require('axios');
|
||||
const fs = require('fs');
|
||||
const { loadJsonFile } = require('./helper');
|
||||
const songdb = require('./lib/songdb').songdbF;
|
||||
const settings = require('../settings.json');
|
||||
|
||||
@@ -22,11 +23,11 @@ const replaceDomainPlaceholder = (obj, domain) => {
|
||||
|
||||
const main = {
|
||||
skupackages: {
|
||||
pc: require('../database/Platforms/jd2017-pc/sku-packages.json'),
|
||||
nx: require('../database/Platforms/jd2017-nx/sku-packages.json'),
|
||||
wiiu: require('../database/Platforms/jd2017-wiiu/sku-packages.json'),
|
||||
durango: require('../database/Platforms/jd2017-durango/sku-packages.json'),
|
||||
orbis: require('../database/Platforms/jd2017-orbis/sku-packages.json')
|
||||
pc: loadJsonFile('Platforms/jd2017-pc/sku-packages.json', '../database/Platforms/jd2017-pc/sku-packages.json'),
|
||||
nx: loadJsonFile('Platforms/jd2017-nx/sku-packages.json', '../database/Platforms/jd2017-nx/sku-packages.json'),
|
||||
wiiu: loadJsonFile('Platforms/jd2017-wiiu/sku-packages.json', '../database/Platforms/jd2017-wiiu/sku-packages.json'),
|
||||
durango: loadJsonFile('Platforms/jd2017-durango/sku-packages.json', '../database/Platforms/jd2017-durango/sku-packages.json'),
|
||||
orbis: loadJsonFile('Platforms/jd2017-orbis/sku-packages.json', '../database/Platforms/jd2017-orbis/sku-packages.json'),
|
||||
},
|
||||
entities: replaceDomainPlaceholder(require('../database/v2/entities.json'), settings.server.domain),
|
||||
configuration: replaceDomainPlaceholder(require('../database/v1/configuration.json'), settings.server.domain),
|
||||
@@ -50,11 +51,11 @@ const main = {
|
||||
playlists: require("../database/db/playlists.json"),
|
||||
create_playlist: require("../database/carousel/pages/create_playlist.json"),
|
||||
songdb: { "2016": {}, "2017": {}, "2018": {}, "2019": {}, "2020": {}, "2021": {}, "2022": {} },
|
||||
localisation: require('../database/Platforms/openparty-all/localisation.json')
|
||||
localisation: loadJsonFile('Platforms/openparty-all/localisation.json', '../database/Platforms/openparty-all/localisation.json')
|
||||
};
|
||||
|
||||
main.songdb = songdb.generateSonglist();
|
||||
|
||||
module.exports = {
|
||||
main
|
||||
main
|
||||
}
|
||||
Reference in New Issue
Block a user