Skip to content

Instantly share code, notes, and snippets.

@mikezila
Created December 19, 2017 05:29
Show Gist options
  • Save mikezila/ed0d615a5a18ec3b9a238e01c5b828bc to your computer and use it in GitHub Desktop.
Save mikezila/ed0d615a5a18ec3b9a238e01c5b828bc to your computer and use it in GitHub Desktop.
Easily generate playlists from folders of disc images. For lakka/retroarch.
Game = Struct.new(:name, :path)
PATH_SLUG = '/storage/roms/USB/PSX/'.freeze
CORE_PATH = 'DETECT'.freeze
CORE_FRIENDLY_NAME = 'DETECT'.freeze
CRC_SLUG = '00000000|crc'.freeze
PLAYLIST_NAME = 'Sony - PlayStation.lpl'.freeze
games = []
Dir.foreach('.') do |folder|
# Skip self and parent dirs
next if [$PROGRAM_NAME, '..', '.'].include?(folder)
next unless File.directory?(folder)
game = Game.new
game.name = folder
rom_file_name = ''
Dir.foreach('./' + folder) do |rom|
next if ['..', '.'].include?(rom)
rom_file_name = rom if rom.end_with? '.cue'
rom_file_name = rom if rom.end_with? '.m3u'
rom_file_name = rom if rom.end_with? '.PBP'
end
game.path = PATH_SLUG + game.name + '/' + rom_file_name
games.push(game)
end
playlist = File.open(PLAYLIST_NAME, 'w')
games.each do |g|
playlist.puts(g.path, g.name, CORE_PATH, CORE_FRIENDLY_NAME, CRC_SLUG, PLAYLIST_NAME)
end
playlist.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment