Skip to content

Instantly share code, notes, and snippets.

@mikezila
Last active November 6, 2017 00:36
Show Gist options
  • Save mikezila/b4f4733c0958f0711e5c5144f873f49f to your computer and use it in GitHub Desktop.
Save mikezila/b4f4733c0958f0711e5c5144f873f49f to your computer and use it in GitHub Desktop.
Generate a playlist of playstation games for Lakka when images are stored in their own folders.
const fs = require('fs');
const pathSlug = "/storage/roms/USB/PSX/";
const corePath = "DETECT";
const coreFriendlyName = "DETECT";
const crcSlug = "00000000|crc";
const playlistName = "Sony - PlayStation.lpl";
let games = [];
let rootListing = fs.readdirSync('.').sort();
for (romFolder of rootListing) {
if(romFolder === "generate.js" || romFolder === playlistName){
continue;
}
let game = {};
game.name = romFolder;
let romImageFileName;
let romListing = fs.readdirSync(romFolder);
for (romFile of romListing) {
if (romFile.endsWith(".cue")) {
romImageFileName = romFile;
}
if (romFile.endsWith(".m3u")) {
romImageFileName = romFile;
}
if (romFile.endsWith(".pbp")) {
romImageFileName = romFile;
}
}
game.path = pathSlug + romFolder + "/" + romImageFileName;
games.push(game);
}
let playlist = fs.openSync(playlistName, "w");
for(game of games) {
fs.writeSync(playlist, game.path + "\n");
fs.writeSync(playlist, game.name + "\n");
fs.writeSync(playlist, corePath + "\n");
fs.writeSync(playlist, coreFriendlyName + "\n");
fs.writeSync(playlist, crcSlug + "\n");
fs.writeSync(playlist, playlistName + "\n");
}
fs.closeSync(playlist);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment