From a75669eb999f52c14ebb144a045d16e3015e3f06 Mon Sep 17 00:00:00 2001 From: CASEY GUNGEON Date: Tue, 16 Jul 2024 11:21:44 -0700 Subject: [PATCH 01/14] init --- code/game/machinery/dance_machine_online.dm | 71 +++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 code/game/machinery/dance_machine_online.dm diff --git a/code/game/machinery/dance_machine_online.dm b/code/game/machinery/dance_machine_online.dm new file mode 100644 index 0000000000..23df181db0 --- /dev/null +++ b/code/game/machinery/dance_machine_online.dm @@ -0,0 +1,71 @@ +#define SONG_TITLE 1 +#define SONG_START 2 +#define SONG_END 3 +#define SONG_URL 4 + + +/obj/machinery/jukebox_online + name = "Online Jukebox" + desc = "A music player. This one has a massive selection." + icon = 'icons/obj/stationobjs.dmi' + icon_state = "jukebox" + verb_say = "intones" + density = TRUE + var/active = FALSE + var/stop = 0 + var/volume = 70 + var/datum/sound/playingsound = null + var/list/songdata = list() + var/soundchannel = 0 + +/obj/machinery/jukebox_online/on_attack_hand(mob/living/user, act_intent, unarmed_attack_flags) + + + +/obj/machinery/jukebox_online/parse_url(string/url) + var/ytdl = CONFIG_GET(string/invoke_youtubedl) + if(!ytdl) + to_chat(src, span_boldwarning("yt-dlp was not configured, action unavailable")) //Check config.txt for the INVOKE_YOUTUBEDL value + return FALSE + if(length(url)) + url = trim(url) + if(findtext(url, ":") && !findtext(url, GLOB.is_http_protocol)) + to_chat(src, span_boldwarning("Non-http(s) URIs are not allowed.")) + to_chat(src, span_warning("For yt-dlp shortcuts like ytsearch: please use the appropriate full url from the website.")) + return FALSE + var/shell_scrubbed_input = shell_url_scrub(url) + var/list/output = world.shelleo("[ytdl] --format \"bestaudio\" --dump-single-json --no-playlist -- \"[shell_scrubbed_input]\"") + var/errorlevel = output[SHELLEO_ERRORLEVEL] + var/stdout = output[SHELLEO_STDOUT] + var/stderr = output[SHELLEO_STDERR] + if(!errorlevel) + var/list/data + try + data = json_decode(stdout) + catch(var/exception/e) + to_chat(src, span_boldwarning("yt-dlp JSON parsing FAILED:")) + to_chat(src, span_warning("[e]: [stdout]")) + return FALSE + + if (data["url"]) + var/storeddata = list() + storeddata[SONG_TITLE] = data["title"] + storeddata[SONG_START] = data["start_time"] + storeddata[SONG_END] = data["end_time"] + storeddata[SONG_URL] = data["webpage_url"] + songdata += storeddata + +/obj/machinery/jukebox_online/it_begins() + soundchannel = pick(SSjukeboxes.freejukeboxchannels) + SSjukeboxes.freejukeboxchannels -= soundchannel + + + +/obj/machinery/jukebox_online/its_over() + + playsound(src, 'sound/machines/terminal_off.ogg', 50, 1) + +#undef SONG_TITLE +#undef SONG_START +#undef SONG_END +#undef SONG_URL From 0462266bc72156ffb04e87b168efa32d5909ebb5 Mon Sep 17 00:00:00 2001 From: CASEY GUNGEON Date: Tue, 16 Jul 2024 12:01:09 -0700 Subject: [PATCH 02/14] input --- code/game/machinery/dance_machine_online.dm | 22 +++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/code/game/machinery/dance_machine_online.dm b/code/game/machinery/dance_machine_online.dm index 23df181db0..87e822f53e 100644 --- a/code/game/machinery/dance_machine_online.dm +++ b/code/game/machinery/dance_machine_online.dm @@ -19,7 +19,10 @@ var/soundchannel = 0 /obj/machinery/jukebox_online/on_attack_hand(mob/living/user, act_intent, unarmed_attack_flags) - + var/songinput = input(user, "Enter URL (supported sites only, leave blank to stop playing)", "Online Jukebox") as text|null + if(isnull(songinput) || !length(songinput)) + stop = world.time + 100 + var/adminmessage = "[user.name] wants to play " /obj/machinery/jukebox_online/parse_url(string/url) @@ -34,7 +37,7 @@ to_chat(src, span_warning("For yt-dlp shortcuts like ytsearch: please use the appropriate full url from the website.")) return FALSE var/shell_scrubbed_input = shell_url_scrub(url) - var/list/output = world.shelleo("[ytdl] --format \"bestaudio\" --dump-single-json --no-playlist -- \"[shell_scrubbed_input]\"") + var/list/output = world.shelleo("[ytdl] --format \"bestaudio\" -P \"./config/jukebox_music/online\" --dump-single-json --no-playlist -- \"[shell_scrubbed_input]\"") var/errorlevel = output[SHELLEO_ERRORLEVEL] var/stdout = output[SHELLEO_STDOUT] var/stderr = output[SHELLEO_STDERR] @@ -58,12 +61,27 @@ /obj/machinery/jukebox_online/it_begins() soundchannel = pick(SSjukeboxes.freejukeboxchannels) SSjukeboxes.freejukeboxchannels -= soundchannel + var/soundtoplay = sound(file("config/jukebox_music/online/" + songdata[1][SONG_TITLE])) + var/jukeboxturf = get_turf(src) + for(var/mob/M in GLOB.player_list) + if(!M.client) + continue + if(!(M.client.prefs.toggles & SOUND_INSTRUMENTS) || !M.can_hear()) + M.stop_sound_channel(jukeinfo[2]) + continue + if(jukebox.z == M.z) //todo - expand this to work with mining planet z-levels when robust jukebox audio gets merged to master + soundtoplay.status = SOUND_UPDATE + else + soundtoplay.status = SOUND_MUTE | SOUND_UPDATE //Setting volume = 0 doesn't let the sound properties update at all, which is lame. + M.playsound_local(currentturf, null, 100, channel = soundchannel, S = soundtoplay) + CHECK_TICK /obj/machinery/jukebox_online/its_over() playsound(src, 'sound/machines/terminal_off.ogg', 50, 1) + SSjukeboxes.freejukeboxchannels += soundchannel #undef SONG_TITLE #undef SONG_START From 3a25f14beeb0c12d60ce9bc13b7d050c2c537682 Mon Sep 17 00:00:00 2001 From: CASEY GUNGEON Date: Tue, 16 Jul 2024 12:22:00 -0700 Subject: [PATCH 03/14] dance_machine_online.dm --- fortune13.dme | 1 + 1 file changed, 1 insertion(+) diff --git a/fortune13.dme b/fortune13.dme index 30adc683ce..34f8132b35 100644 --- a/fortune13.dme +++ b/fortune13.dme @@ -898,6 +898,7 @@ #include "code\game\machinery\constructable_frame.dm" #include "code\game\machinery\cryopod.dm" #include "code\game\machinery\dance_machine.dm" +#include "code\game\machinery\dance_machine_online.dm" #include "code\game\machinery\defibrillator_mount.dm" #include "code\game\machinery\dish_drive.dm" #include "code\game\machinery\dna_scanner.dm" From 224e273a524fcef12ccd7738345fbaf65e42a23e Mon Sep 17 00:00:00 2001 From: CASEY GUNGEON Date: Tue, 16 Jul 2024 12:22:16 -0700 Subject: [PATCH 04/14] compile error fixes --- code/game/machinery/dance_machine_online.dm | 24 ++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/code/game/machinery/dance_machine_online.dm b/code/game/machinery/dance_machine_online.dm index 87e822f53e..d626020895 100644 --- a/code/game/machinery/dance_machine_online.dm +++ b/code/game/machinery/dance_machine_online.dm @@ -14,18 +14,22 @@ var/active = FALSE var/stop = 0 var/volume = 70 - var/datum/sound/playingsound = null + var/sound/playingsound = null var/list/songdata = list() var/soundchannel = 0 /obj/machinery/jukebox_online/on_attack_hand(mob/living/user, act_intent, unarmed_attack_flags) + var/pwdoutput = world.shelleo("pwd") + to_chat(user, pwdoutput[1] + pwdoutput[2] + pwdoutput[3]) var/songinput = input(user, "Enter URL (supported sites only, leave blank to stop playing)", "Online Jukebox") as text|null if(isnull(songinput) || !length(songinput)) stop = world.time + 100 var/adminmessage = "[user.name] wants to play " + for(var/admin in GLOB.admins.Copy()) + to_chat(admin, adminmessage, confidential = TRUE) -/obj/machinery/jukebox_online/parse_url(string/url) +/obj/machinery/jukebox_online/proc/parse_url(var/url) var/ytdl = CONFIG_GET(string/invoke_youtubedl) if(!ytdl) to_chat(src, span_boldwarning("yt-dlp was not configured, action unavailable")) //Check config.txt for the INVOKE_YOUTUBEDL value @@ -40,7 +44,7 @@ var/list/output = world.shelleo("[ytdl] --format \"bestaudio\" -P \"./config/jukebox_music/online\" --dump-single-json --no-playlist -- \"[shell_scrubbed_input]\"") var/errorlevel = output[SHELLEO_ERRORLEVEL] var/stdout = output[SHELLEO_STDOUT] - var/stderr = output[SHELLEO_STDERR] + //var/stderr = output[SHELLEO_STDERR] if(!errorlevel) var/list/data try @@ -58,7 +62,7 @@ storeddata[SONG_URL] = data["webpage_url"] songdata += storeddata -/obj/machinery/jukebox_online/it_begins() +/obj/machinery/jukebox_online/proc/it_begins() soundchannel = pick(SSjukeboxes.freejukeboxchannels) SSjukeboxes.freejukeboxchannels -= soundchannel var/soundtoplay = sound(file("config/jukebox_music/online/" + songdata[1][SONG_TITLE])) @@ -68,17 +72,17 @@ if(!M.client) continue if(!(M.client.prefs.toggles & SOUND_INSTRUMENTS) || !M.can_hear()) - M.stop_sound_channel(jukeinfo[2]) + M.stop_sound_channel(soundchannel) continue - if(jukebox.z == M.z) //todo - expand this to work with mining planet z-levels when robust jukebox audio gets merged to master - soundtoplay.status = SOUND_UPDATE + if(src.z == M.z) //todo - expand this to work with mining planet z-levels when robust jukebox audio gets merged to master + playingsound.status = SOUND_UPDATE else - soundtoplay.status = SOUND_MUTE | SOUND_UPDATE //Setting volume = 0 doesn't let the sound properties update at all, which is lame. + playingsound.status = SOUND_MUTE | SOUND_UPDATE //Setting volume = 0 doesn't let the sound properties update at all, which is lame. - M.playsound_local(currentturf, null, 100, channel = soundchannel, S = soundtoplay) + M.playsound_local(jukeboxturf, null, 100, channel = soundchannel, S = soundtoplay) CHECK_TICK -/obj/machinery/jukebox_online/its_over() +/obj/machinery/jukebox_online/proc/its_over() playsound(src, 'sound/machines/terminal_off.ogg', 50, 1) SSjukeboxes.freejukeboxchannels += soundchannel From 75ba9935cb9a618b6c45d26a2af6d228c4e2f439 Mon Sep 17 00:00:00 2001 From: CASEY GUNGEON Date: Tue, 16 Jul 2024 13:05:57 -0700 Subject: [PATCH 05/14] fix overflow job null error --- code/controllers/subsystem/job.dm | 2 +- config/game_options.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/controllers/subsystem/job.dm b/code/controllers/subsystem/job.dm index 01fdf6657f..403e7c2d7f 100644 --- a/code/controllers/subsystem/job.dm +++ b/code/controllers/subsystem/job.dm @@ -13,7 +13,7 @@ SUBSYSTEM_DEF(job) var/list/prioritized_jobs = list() var/list/latejoin_trackers = list() //Don't read this list, use GetLateJoinTurfs() instead - var/overflow_role = "Wastelander" //CHANGE + var/overflow_role = "Customer" //CHANGE var/debug_admins_are_exempt_from_timelocks = FALSE diff --git a/config/game_options.txt b/config/game_options.txt index b1029876cf..6e1a1802e1 100644 --- a/config/game_options.txt +++ b/config/game_options.txt @@ -502,7 +502,7 @@ ROUNDSTART_RACES dragon #JOIN_WITH_MUTANT_HUMANS ##Overflow job. Default is assistant -OVERFLOW_JOB Wastelander +OVERFLOW_JOB Customer ## Overflow slot cap. Set to -1 for unlimited. If limited, it will still open up if every other job is full. OVERFLOW_CAP -1 From 734619d590a03e582567cf340dc777344808fb5e Mon Sep 17 00:00:00 2001 From: CASEY GUNGEON Date: Tue, 16 Jul 2024 13:06:11 -0700 Subject: [PATCH 06/14] admin responsibility --- code/game/machinery/dance_machine_online.dm | 24 ++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/code/game/machinery/dance_machine_online.dm b/code/game/machinery/dance_machine_online.dm index d626020895..8b03796661 100644 --- a/code/game/machinery/dance_machine_online.dm +++ b/code/game/machinery/dance_machine_online.dm @@ -17,17 +17,34 @@ var/sound/playingsound = null var/list/songdata = list() var/soundchannel = 0 + var/pendingsongurl = "" + /obj/machinery/jukebox_online/on_attack_hand(mob/living/user, act_intent, unarmed_attack_flags) - var/pwdoutput = world.shelleo("pwd") - to_chat(user, pwdoutput[1] + pwdoutput[2] + pwdoutput[3]) var/songinput = input(user, "Enter URL (supported sites only, leave blank to stop playing)", "Online Jukebox") as text|null if(isnull(songinput) || !length(songinput)) stop = world.time + 100 - var/adminmessage = "[user.name] wants to play " + return + pendingsongurl = songinput + var/adminmessage = "[user.name] wants to play [pendingsongurl]
You can
Allow or Deny." for(var/admin in GLOB.admins.Copy()) to_chat(admin, adminmessage, confidential = TRUE) +/obj/machinery/jukebox_online/Topic(href, href_list[]) + if(pendingsongurl == href_list["url"]) + if(href_list["action"] == "allow") + parse_url(pendingsongurl) + it_begins() + message_admins("[usr] approved [pendingsongurl]") + pendingsongurl = "" + return + if(href_list["action"] == "deny") + pendingsongurl = "" + message_admins("[usr] denied [pendingsongurl]") + return + else + to_chat(usr, "Someone else must have responded already.") + /obj/machinery/jukebox_online/proc/parse_url(var/url) var/ytdl = CONFIG_GET(string/invoke_youtubedl) @@ -86,6 +103,7 @@ playsound(src, 'sound/machines/terminal_off.ogg', 50, 1) SSjukeboxes.freejukeboxchannels += soundchannel + songdata -= songdata[1] #undef SONG_TITLE #undef SONG_START From 6047708dd870470a39303fc435ed96b5f06a7071 Mon Sep 17 00:00:00 2001 From: CASEY GUNGEON Date: Tue, 16 Jul 2024 13:46:33 -0700 Subject: [PATCH 07/14] fix hrefs --- code/game/machinery/dance_machine_online.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/game/machinery/dance_machine_online.dm b/code/game/machinery/dance_machine_online.dm index 8b03796661..d8d0d7155b 100644 --- a/code/game/machinery/dance_machine_online.dm +++ b/code/game/machinery/dance_machine_online.dm @@ -26,7 +26,7 @@ stop = world.time + 100 return pendingsongurl = songinput - var/adminmessage = "[user.name] wants to play [pendingsongurl]
You can
Allow or Deny.
" + var/adminmessage = "[user.name] wants to play [pendingsongurl]
You can Allow or Deny.
" for(var/admin in GLOB.admins.Copy()) to_chat(admin, adminmessage, confidential = TRUE) @@ -35,12 +35,12 @@ if(href_list["action"] == "allow") parse_url(pendingsongurl) it_begins() - message_admins("[usr] approved [pendingsongurl]") + message_admins("[usr] approved [href_list["url"]]") pendingsongurl = "" return if(href_list["action"] == "deny") pendingsongurl = "" - message_admins("[usr] denied [pendingsongurl]") + message_admins("[usr] denied [href_list["url"]]") return else to_chat(usr, "Someone else must have responded already.") From 2d76ac4b5ebfacdc2df3c0bf7e3ba70426edd5d2 Mon Sep 17 00:00:00 2001 From: CASEY GUNGEON Date: Tue, 16 Jul 2024 13:54:17 -0700 Subject: [PATCH 08/14] parse_url logic --- code/game/machinery/dance_machine_online.dm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/code/game/machinery/dance_machine_online.dm b/code/game/machinery/dance_machine_online.dm index d8d0d7155b..87b42d98e1 100644 --- a/code/game/machinery/dance_machine_online.dm +++ b/code/game/machinery/dance_machine_online.dm @@ -33,8 +33,8 @@ /obj/machinery/jukebox_online/Topic(href, href_list[]) if(pendingsongurl == href_list["url"]) if(href_list["action"] == "allow") - parse_url(pendingsongurl) - it_begins() + if(parse_url(pendingsongurl)) + it_begins() message_admins("[usr] approved [href_list["url"]]") pendingsongurl = "" return @@ -47,16 +47,17 @@ /obj/machinery/jukebox_online/proc/parse_url(var/url) + . = FALSE var/ytdl = CONFIG_GET(string/invoke_youtubedl) if(!ytdl) to_chat(src, span_boldwarning("yt-dlp was not configured, action unavailable")) //Check config.txt for the INVOKE_YOUTUBEDL value - return FALSE + return if(length(url)) url = trim(url) if(findtext(url, ":") && !findtext(url, GLOB.is_http_protocol)) to_chat(src, span_boldwarning("Non-http(s) URIs are not allowed.")) to_chat(src, span_warning("For yt-dlp shortcuts like ytsearch: please use the appropriate full url from the website.")) - return FALSE + return var/shell_scrubbed_input = shell_url_scrub(url) var/list/output = world.shelleo("[ytdl] --format \"bestaudio\" -P \"./config/jukebox_music/online\" --dump-single-json --no-playlist -- \"[shell_scrubbed_input]\"") var/errorlevel = output[SHELLEO_ERRORLEVEL] @@ -69,7 +70,7 @@ catch(var/exception/e) to_chat(src, span_boldwarning("yt-dlp JSON parsing FAILED:")) to_chat(src, span_warning("[e]: [stdout]")) - return FALSE + return if (data["url"]) var/storeddata = list() @@ -78,6 +79,7 @@ storeddata[SONG_END] = data["end_time"] storeddata[SONG_URL] = data["webpage_url"] songdata += storeddata + . = TRUE /obj/machinery/jukebox_online/proc/it_begins() soundchannel = pick(SSjukeboxes.freejukeboxchannels) From 5eb85a258cf84f6753c068377fe239fdef75a079 Mon Sep 17 00:00:00 2001 From: CASEY GUNGEON Date: Tue, 16 Jul 2024 14:06:29 -0700 Subject: [PATCH 09/14] jukebox save loc modified --- code/game/machinery/dance_machine_online.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/game/machinery/dance_machine_online.dm b/code/game/machinery/dance_machine_online.dm index 87b42d98e1..f69f30fadc 100644 --- a/code/game/machinery/dance_machine_online.dm +++ b/code/game/machinery/dance_machine_online.dm @@ -59,7 +59,7 @@ to_chat(src, span_warning("For yt-dlp shortcuts like ytsearch: please use the appropriate full url from the website.")) return var/shell_scrubbed_input = shell_url_scrub(url) - var/list/output = world.shelleo("[ytdl] --format \"bestaudio\" -P \"./config/jukebox_music/online\" --dump-single-json --no-playlist -- \"[shell_scrubbed_input]\"") + var/list/output = world.shelleo("[ytdl] --format \"bestaudio\" -P \"./jukeboxdownloaded\" --dump-single-json --no-playlist -- \"[shell_scrubbed_input]\"") var/errorlevel = output[SHELLEO_ERRORLEVEL] var/stdout = output[SHELLEO_STDOUT] //var/stderr = output[SHELLEO_STDERR] @@ -84,7 +84,7 @@ /obj/machinery/jukebox_online/proc/it_begins() soundchannel = pick(SSjukeboxes.freejukeboxchannels) SSjukeboxes.freejukeboxchannels -= soundchannel - var/soundtoplay = sound(file("config/jukebox_music/online/" + songdata[1][SONG_TITLE])) + var/soundtoplay = sound(file("data/jukeboxdownloaded/" + songdata[1][SONG_TITLE])) var/jukeboxturf = get_turf(src) for(var/mob/M in GLOB.player_list) From 5073baec6afd90b0410c416d0a2cb3f740359a95 Mon Sep 17 00:00:00 2001 From: CASEY GUNGEON Date: Tue, 16 Jul 2024 16:45:13 -0700 Subject: [PATCH 10/14] replace single quotes with double --- code/__HELPERS/shell.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/__HELPERS/shell.dm b/code/__HELPERS/shell.dm index 662efb7eac..3438f38b85 100644 --- a/code/__HELPERS/shell.dm +++ b/code/__HELPERS/shell.dm @@ -25,7 +25,7 @@ shelleo_ids[shelleo_id] = TRUE out_file = "[SHELLEO_NAME][shelleo_id][SHELLEO_OUT]" err_file = "[SHELLEO_NAME][shelleo_id][SHELLEO_ERR]" - errorcode = shell("[interpreter] '[command]' > [out_file] 2> [err_file]") + errorcode = shell("[interpreter] \"[command]\" > [out_file] 2> [err_file]") if(fexists(out_file)) stdout = file2text(out_file) fdel(out_file) From c66a3277784db253942961f7153ce77be62eb517 Mon Sep 17 00:00:00 2001 From: CASEY GUNGEON Date: Tue, 16 Jul 2024 16:45:20 -0700 Subject: [PATCH 11/14] just use tgui panel whatever --- code/game/machinery/dance_machine_online.dm | 71 ++++++--------------- 1 file changed, 21 insertions(+), 50 deletions(-) diff --git a/code/game/machinery/dance_machine_online.dm b/code/game/machinery/dance_machine_online.dm index f69f30fadc..309afbd275 100644 --- a/code/game/machinery/dance_machine_online.dm +++ b/code/game/machinery/dance_machine_online.dm @@ -1,9 +1,3 @@ -#define SONG_TITLE 1 -#define SONG_START 2 -#define SONG_END 3 -#define SONG_URL 4 - - /obj/machinery/jukebox_online name = "Online Jukebox" desc = "A music player. This one has a massive selection." @@ -11,15 +5,8 @@ icon_state = "jukebox" verb_say = "intones" density = TRUE - var/active = FALSE - var/stop = 0 - var/volume = 70 - var/sound/playingsound = null - var/list/songdata = list() - var/soundchannel = 0 var/pendingsongurl = "" - /obj/machinery/jukebox_online/on_attack_hand(mob/living/user, act_intent, unarmed_attack_flags) var/songinput = input(user, "Enter URL (supported sites only, leave blank to stop playing)", "Online Jukebox") as text|null if(isnull(songinput) || !length(songinput)) @@ -33,8 +20,7 @@ /obj/machinery/jukebox_online/Topic(href, href_list[]) if(pendingsongurl == href_list["url"]) if(href_list["action"] == "allow") - if(parse_url(pendingsongurl)) - it_begins() + parse_url(pendingsongurl) message_admins("[usr] approved [href_list["url"]]") pendingsongurl = "" return @@ -59,7 +45,7 @@ to_chat(src, span_warning("For yt-dlp shortcuts like ytsearch: please use the appropriate full url from the website.")) return var/shell_scrubbed_input = shell_url_scrub(url) - var/list/output = world.shelleo("[ytdl] --format \"bestaudio\" -P \"./jukeboxdownloaded\" --dump-single-json --no-playlist -- \"[shell_scrubbed_input]\"") + var/list/output = world.shelleo("[ytdl] --format \"bestaudio\" -q -P \"data/jukeboxdownloaded\"-o \"tmpdl.%(ext)s\" --dump-single-json --no-playlist -- \"[shell_scrubbed_input]\"") var/errorlevel = output[SHELLEO_ERRORLEVEL] var/stdout = output[SHELLEO_STDOUT] //var/stderr = output[SHELLEO_STDERR] @@ -74,40 +60,25 @@ if (data["url"]) var/storeddata = list() - storeddata[SONG_TITLE] = data["title"] - storeddata[SONG_START] = data["start_time"] - storeddata[SONG_END] = data["end_time"] - storeddata[SONG_URL] = data["webpage_url"] - songdata += storeddata + storeddata["start"] = data["start_time"] + storeddata["end"] = data["end_time"] + storeddata["link"] = data["webpage_url"] + storeddata["title"] = data["title"] + play_online_song(url, storeddata) . = TRUE -/obj/machinery/jukebox_online/proc/it_begins() - soundchannel = pick(SSjukeboxes.freejukeboxchannels) - SSjukeboxes.freejukeboxchannels -= soundchannel - var/soundtoplay = sound(file("data/jukeboxdownloaded/" + songdata[1][SONG_TITLE])) - var/jukeboxturf = get_turf(src) - - for(var/mob/M in GLOB.player_list) - if(!M.client) - continue - if(!(M.client.prefs.toggles & SOUND_INSTRUMENTS) || !M.can_hear()) - M.stop_sound_channel(soundchannel) - continue - if(src.z == M.z) //todo - expand this to work with mining planet z-levels when robust jukebox audio gets merged to master - playingsound.status = SOUND_UPDATE - else - playingsound.status = SOUND_MUTE | SOUND_UPDATE //Setting volume = 0 doesn't let the sound properties update at all, which is lame. - - M.playsound_local(jukeboxturf, null, 100, channel = soundchannel, S = soundtoplay) - CHECK_TICK - -/obj/machinery/jukebox_online/proc/its_over() - - playsound(src, 'sound/machines/terminal_off.ogg', 50, 1) - SSjukeboxes.freejukeboxchannels += soundchannel - songdata -= songdata[1] +/obj/machinery/jukebox_online/proc/play_online_song(url, extradata) + for(var/m in GLOB.player_list) + var/mob/M = m + var/client/C = M?.client + if(C) + if(C.prefs.toggles & SOUND_MIDI) + C.tgui_panel?.play_music(url, extradata) -#undef SONG_TITLE -#undef SONG_START -#undef SONG_END -#undef SONG_URL +/obj/machinery/jukebox_online/proc/stop_online_song() + for(var/m in GLOB.player_list) + var/mob/M = m + var/client/C = M?.client + if(C) + if(C.prefs.toggles & SOUND_MIDI) + C.tgui_panel?.stop_music() From 85f2672e05aa4d47712748540cc93c0417329377 Mon Sep 17 00:00:00 2001 From: CASEY GUNGEON Date: Tue, 16 Jul 2024 19:35:00 -0700 Subject: [PATCH 12/14] playing songs through tgui panel --- code/game/machinery/dance_machine_online.dm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/code/game/machinery/dance_machine_online.dm b/code/game/machinery/dance_machine_online.dm index 309afbd275..d13cb5f6cf 100644 --- a/code/game/machinery/dance_machine_online.dm +++ b/code/game/machinery/dance_machine_online.dm @@ -10,7 +10,7 @@ /obj/machinery/jukebox_online/on_attack_hand(mob/living/user, act_intent, unarmed_attack_flags) var/songinput = input(user, "Enter URL (supported sites only, leave blank to stop playing)", "Online Jukebox") as text|null if(isnull(songinput) || !length(songinput)) - stop = world.time + 100 + stop_online_song() return pendingsongurl = songinput var/adminmessage = "[user.name] wants to play [pendingsongurl]
You can Allow or Deny.
" @@ -20,7 +20,8 @@ /obj/machinery/jukebox_online/Topic(href, href_list[]) if(pendingsongurl == href_list["url"]) if(href_list["action"] == "allow") - parse_url(pendingsongurl) + var/toplay = pendingsongurl + parse_url(toplay) message_admins("[usr] approved [href_list["url"]]") pendingsongurl = "" return @@ -59,12 +60,13 @@ return if (data["url"]) + var/hyperlink = "[data["title"]]" var/storeddata = list() storeddata["start"] = data["start_time"] storeddata["end"] = data["end_time"] storeddata["link"] = data["webpage_url"] storeddata["title"] = data["title"] - play_online_song(url, storeddata) + play_online_song(hyperlink, storeddata) . = TRUE /obj/machinery/jukebox_online/proc/play_online_song(url, extradata) From 18caf672f40411095120a37113563a4fbdd14d96 Mon Sep 17 00:00:00 2001 From: CASEY GUNGEON Date: Wed, 17 Jul 2024 00:03:59 -0700 Subject: [PATCH 13/14] whagever --- code/game/machinery/dance_machine_online.dm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/code/game/machinery/dance_machine_online.dm b/code/game/machinery/dance_machine_online.dm index d13cb5f6cf..cb96a347fc 100644 --- a/code/game/machinery/dance_machine_online.dm +++ b/code/game/machinery/dance_machine_online.dm @@ -46,7 +46,7 @@ to_chat(src, span_warning("For yt-dlp shortcuts like ytsearch: please use the appropriate full url from the website.")) return var/shell_scrubbed_input = shell_url_scrub(url) - var/list/output = world.shelleo("[ytdl] --format \"bestaudio\" -q -P \"data/jukeboxdownloaded\"-o \"tmpdl.%(ext)s\" --dump-single-json --no-playlist -- \"[shell_scrubbed_input]\"") + var/list/output = world.shelleo("[ytdl] --format \"bestaudio\" --dump-single-json --no-playlist --skip-download -- \"[shell_scrubbed_input]\"") var/errorlevel = output[SHELLEO_ERRORLEVEL] var/stdout = output[SHELLEO_STDOUT] //var/stderr = output[SHELLEO_STDERR] @@ -60,13 +60,12 @@ return if (data["url"]) - var/hyperlink = "[data["title"]]" var/storeddata = list() storeddata["start"] = data["start_time"] storeddata["end"] = data["end_time"] storeddata["link"] = data["webpage_url"] storeddata["title"] = data["title"] - play_online_song(hyperlink, storeddata) + play_online_song(data["url"], storeddata) . = TRUE /obj/machinery/jukebox_online/proc/play_online_song(url, extradata) From 870f78d96d73bc8d483a0fc3b728518dc72cea43 Mon Sep 17 00:00:00 2001 From: CASEY GUNGEON Date: Wed, 17 Jul 2024 16:11:12 -0700 Subject: [PATCH 14/14] makes it work --- code/game/machinery/dance_machine_online.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/game/machinery/dance_machine_online.dm b/code/game/machinery/dance_machine_online.dm index cb96a347fc..eebbbd9301 100644 --- a/code/game/machinery/dance_machine_online.dm +++ b/code/game/machinery/dance_machine_online.dm @@ -33,7 +33,7 @@ to_chat(usr, "Someone else must have responded already.") -/obj/machinery/jukebox_online/proc/parse_url(var/url) +/obj/machinery/jukebox_online/proc/parse_url(url) . = FALSE var/ytdl = CONFIG_GET(string/invoke_youtubedl) if(!ytdl) @@ -46,7 +46,7 @@ to_chat(src, span_warning("For yt-dlp shortcuts like ytsearch: please use the appropriate full url from the website.")) return var/shell_scrubbed_input = shell_url_scrub(url) - var/list/output = world.shelleo("[ytdl] --format \"bestaudio\" --dump-single-json --no-playlist --skip-download -- \"[shell_scrubbed_input]\"") + var/list/output = world.shelleo("[ytdl] --format \"bestaudio\[ext=mp3]/best\[ext=mp4]\[height<=360]/bestaudio\[ext=m4a]/bestaudio\[ext=aac]\" --dump-single-json --no-playlist -- \"[shell_scrubbed_input]\"") var/errorlevel = output[SHELLEO_ERRORLEVEL] var/stdout = output[SHELLEO_STDOUT] //var/stderr = output[SHELLEO_STDERR]