diff --git a/code/modules/admin/verbs/playsound.dm b/code/modules/admin/verbs/playsound.dm index 29d95c639f..58189e98b0 100644 --- a/code/modules/admin/verbs/playsound.dm +++ b/code/modules/admin/verbs/playsound.dm @@ -80,14 +80,32 @@ to_chat(src, "For youtube-dl shortcuts like ytsearch: please use the appropriate full url from the website.") return var/shell_scrubbed_input = shell_url_scrub(web_sound_input) - var/list/output = world.shelleo("[ytdl] --format \"bestaudio\[ext=mp3]/best\[ext=mp4]\[height<=360]/bestaudio\[ext=m4a]/bestaudio\[ext=aac]\" --get-url \"[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] if(!errorlevel) - var/static/regex/content_url_regex = regex("https?://\\S+") - if(content_url_regex.Find(stdout)) - web_sound_url = content_url_regex.match + var/list/data + try + data = json_decode(stdout) + catch(var/exception/e) + to_chat(src, "Youtube-dl JSON parsing FAILED:") + to_chat(src, "[e]: [stdout]") + return + + if (data["url"]) + web_sound_url = data["url"] + var/title = "[data["title"]]" + var/webpage_url = title + if (data["webpage_url"]) + webpage_url = "[title]" + + var/res = alert(usr, "Show the title of and link to this song to the players?\n[title]",, "No", "Yes", "Cancel") + switch(res) + if("Yes") + to_chat(world, "An admin played: [webpage_url]") + if("Cancel") + return if(SSevents.holidays && SSevents.holidays[APRIL_FOOLS]) pitch = pick(0.5, 0.7, 0.8, 0.85, 0.9, 0.95, 1.1, 1.2, 1.4, 1.6, 2.0, 2.5)