diff --git a/code/modules/media/media_tracks.dm b/code/modules/media/media_tracks.dm index 31a1dc6035..dd0f0b77c0 100644 --- a/code/modules/media/media_tracks.dm +++ b/code/modules/media/media_tracks.dm @@ -38,21 +38,36 @@ var/global/list/all_lobby_tracks = list() // Read the jukebox configuration file on system startup. /hook/startup/proc/load_jukebox_tracks() var/jukebox_track_file = "config/jukebox.json" + var/jukebox_track_file_private = "config/jukebox_private.json" // Uncommitted + if(!fexists(jukebox_track_file)) warning("File not found: [jukebox_track_file]") return 1 + var/list/jsonData = json_decode(file2text(jukebox_track_file)) + if(!istype(jsonData)) warning("Failed to read tracks from [jukebox_track_file], json_decode failed.") + return 1 + + // Optional + if(fexists(jukebox_track_file_private)) + var/list/jsonData_private = json_decode(file2text(jukebox_track_file_private)) + if(istype(jsonData_private)) + jsonData += jsonData_private // Pack more tracks in + else + warning("Failed to read tracks from [jukebox_track_file_private], json_decode failed.") + //return 1 // Not worth failing over, as this file is optional + for(var/entry in jsonData) if(!istext(entry["url"])) - warning("[jukebox_track_file] entry [entry]: bad or missing 'url'") + warning("Jukebox entry [entry]: bad or missing 'url'") continue if(!istext(entry["title"])) - warning("[jukebox_track_file] entry [entry]: bad or missingg 'title'") + warning("Jukebox entry [entry]: bad or missing 'title'") continue if(!isnum(entry["duration"])) - warning("[jukebox_track_file] entry [entry]: bad or missing 'duration'") + warning("Jukebox entry [entry]: bad or missing 'duration'") continue var/datum/track/T = new(entry["url"], entry["title"], entry["duration"]) if(istext(entry["artist"])) diff --git a/config/.gitignore b/config/.gitignore index ffa5d037d9..0367235fe4 100644 --- a/config/.gitignore +++ b/config/.gitignore @@ -6,3 +6,4 @@ #!custom_sprites.txt #!alienwhitelist.txt #!jobwhitelist.txt +#!jukebox.json diff --git a/config/example/jukebox.json b/config/example/jukebox.json new file mode 100644 index 0000000000..d2baa92532 --- /dev/null +++ b/config/example/jukebox.json @@ -0,0 +1,42 @@ +[ + { + "url": "https://s.put.re/bkZYkYwX.mp3", + "title": "Flip-Flap (Title One)", + "duration": 1500, + "artist": "X-CEED", + "secret": false, + "lobby": true, + "jukebox": false, + "genre": "Jazz" + }, + { + "url": "https://s.put.re/EzLP21Mp.mp3", + "title": "Robocop Theme (Title Two)", + "duration": 1180, + "artist": "Cboyardee", + "secret": false, + "lobby": true, + "jukebox": false, + "genre": "Electronic" + }, + { + "url": "https://s.put.re/uDpZrL1L.mp3", + "title": "Tin Tin on the Moon (Remix)", + "duration": 2320, + "artist": "Jeroen Tel (Remixed by Cuboos)", + "secret": false, + "lobby": true, + "jukebox": true, + "genre": "Electronic" + }, + { + "url": "https://s.put.re/nNXTd9ko.mp3", + "title": "Phoron Will Make Us Rich", + "duration": 1370, + "artist": "Earthcrusher", + "secret": false, + "lobby": true, + "jukebox": true, + "genre": "Electronic" + } +] \ No newline at end of file diff --git a/config/example/jukebox.txt b/config/example/jukebox.txt deleted file mode 100644 index 08ae86b398..0000000000 --- a/config/example/jukebox.txt +++ /dev/null @@ -1,30 +0,0 @@ -#Jukebox configuration file -#Sound file | Song Title | <0 = normal or 1 = secret> - -# Normal songs -sound/music/jukebox/SongAboutHares.ogg | A Song About Hares | 0 -sound/music/jukebox/BelowTheAsteroids.ogg | Below The Asteroids | 0 -sound/ambience/ambispace.ogg | Beyond | 0 -sound/music/clouds.s3m | Clouds of Fire | 0 -sound/music/title2.ogg | D`Bert | 0 -sound/ambience/song_game.ogg | D`Fort | 0 -sound/music/jukebox/DuckTalesMoon.mid | Duck Tales - Moon | 0 -sound/music/space.ogg | Endless Space | 0 -sound/music/main.ogg | Floating | 0 -sound/music/jukebox/Fly_Me_To_The_Moon.ogg | Fly Me To The Moon | 0 -sound/music/jukebox/Cantina.ogg | Mad About Me | 0 -sound/music/jukebox/MinorTurbulenceFull.ogg | Minor Turbulence | 0 -sound/music/jukebox/OdeToGreed.ogg | Ode to Greed | 0 -sound/misc/TestLoop1.ogg | Part A | 0 -sound/music/jukebox/Ransacked.ogg | Ransacked | 0 -sound/music/jukebox/russianrapdisco.ogg | Russkiy rep Diskoteka | 0 -sound/music/title1.ogg | Scratch | 0 -sound/music/space_oddity.ogg | Space Oddity | 0 -sound/music/THUNDERDOME.ogg | Thunderdome | 0 -sound/music/traitor.ogg | Trai`Tor | 0 -sound/music/jukebox/WelcomeToJurassicPark.mid | Welcome To Jurassic Park | 0 - -# Secret songs! -sound/music/jukebox/bandit_radio.ogg | Bandit Radio | 1 -sound/music/space_asshole.ogg | Space Asshole | 1 -sound/music/THUNDERDOME.ogg | THUNDERDOME | 1 diff --git a/config/example/jukebox_private.json b/config/example/jukebox_private.json new file mode 100644 index 0000000000..0637a088a0 --- /dev/null +++ b/config/example/jukebox_private.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/config/jukebox.json b/config/jukebox.json new file mode 100644 index 0000000000..0637a088a0 --- /dev/null +++ b/config/jukebox.json @@ -0,0 +1 @@ +[] \ No newline at end of file