-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds Play Internet Sound #28183
base: master
Are you sure you want to change the base?
Adds Play Internet Sound #28183
Conversation
I would like to request a test merge to see how this impacts the server and players. |
Two major hesitancy points on this
|
I don't think TG or its downstream have had any issues with using a shell here but I understand the hesitancy. Unfortunately, I I could try to help you with a rustg module but again I don't know how much help I would be. I am starting from zero knowledge.
TG switched from youtube-dl to yt-dlp for this reason and it's kind of a back and forth between Youtube and yt-dlp right now. yt-dlp does have utility outside of Youtube. SoundCloud and Bandcamp work and are great sources of music which were commonly used. |
https://github.com/Absolucy/ss13-yt-wrap @Absolucy made this which removes the need for shell calls so I'll get this deployed and advise on PR changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the config option to a URL for ytdl_service_url
and maybe add a link to https://github.com/Absolucy/ss13-yt-wrap in the comment, telling them to include the full path including the /get
.
The way this is done is a GET
request to http://10.0.0.10:23432/get
with the following body
{
"url": "https://soundcloud.com/affectedarc07/ss13-remix-2-quarantine-edition"
}
This returns
{
"title": "SS13 Remix 2 - Quarantine Edition",
"webpage_url": "https://soundcloud.com/affectedarc07/ss13-remix-2-quarantine-edition",
"sound_url": "https://cf-media.sndcdn.com/1GpwbLvtIvC7.128.mp3?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiKjovL2NmLW1lZGlhLnNuZGNkbi5jb20vMUdwd2JMdnRJdkM3LjEyOC5tcDMqIiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNzM4MjczMDA1fX19XX0_&Signature=BqECQUH4Nc6VXsr7Mx3dn2B3ap1gk~PcX4WMB9MBStm~RN33TSvqJP-8B0ZX35B8ujvTYsnLU543BEOcjN~ztL~cvGTPNDgY0rgj2rU4oHMFyCqEmArNTzhtrnLzMftEe~6pgUUvCNAwxI~7tfYpoR6shPtEs4IxCqAXZedqsBaXNDOh5dzY5QePF9wM3LJRxSHt05xBTKpgGVLrc13933DlLvM6f1g0VQwcGIgZMQqlgUzYF0oxi9FnJK7MSCvBNakN5yPqqOd~QuTLNGSLreyYziCscyHzeXTxs-kDQjJNB~mwS1wi0NaMzs1Bk9FoU6qftOzLtmzHlGjfiNVH2A__&Key-Pair-Id=APKAI6TU7MMXM5DG6EPQ",
"duration": 223.269,
"start": 0,
"end": 223.269,
"upload_date": null,
"channel": "AffectedArc07",
"artist": null,
"album": null,
"track": null
}
I used my own soundcloud because it wasnt working with YT without the cookies, but works with many other websites
This removes the need for shell calls and drastically simplifies the PR. If you need me to spin up an instance for you to test this lmk. Also the fact we are sending a body with a GET request is not good
A client SHOULD NOT generate content in a GET request unless it is made directly to an origin server that has previously indicated, in or out of band, that such a request has a purpose and will be adequately supported. An origin server SHOULD NOT rely on private agreements to receive content, since participants in HTTP communication are often unaware of intermediaries along the request chain
code/__HELPERS/shell.dm
Outdated
@@ -0,0 +1,57 @@ | |||
//Runs the command in the system's shell, returns a list of (error code, stdout, stderr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops
The alert/inputs are tgui now |
Co-authored-by: AffectedArc07 <[email protected]> Signed-off-by: Bm0n <[email protected]>
@@ -1,4 +1,5 @@ | |||
GLOBAL_DATUM_INIT(filename_forbidden_chars, /regex, regex(@{""|[\\\n\t/?%*:|<>]|\.\."}, "g")) | |||
GLOBAL_DATUM_INIT(is_color, /regex, regex("^#\[0-9a-fA-F]{6}$")) | |||
GLOBAL_DATUM_INIT(regex_rgb_text, /regex, regex(@"^#?(([0-9a-fA-F]{8})|([0-9a-fA-F]{6})|([0-9a-fA-F]{3}))$")) | |||
GLOBAL_DATUM_INIT(is_http_protocol, /regex, regex("^https?://")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo this (and several of these tbh) is global pollution and could be just fine as a /proc/is_http_protocol(url)
that just has the regex as a static variable inside the proc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i personally think it's fine, these are kept to a bare minimum on paradise compared to tg
the original system to play oggs will still be there correct? |
yeah it's still there |
|
||
|
||
var/web_sound_input = tgui_input_text(src, "Enter content URL (supported sites only, leave blank to stop playing)", "Play Internet Sound", null) | ||
if(istext(web_sound_input)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't trust reading indents on a phone but if the entire proc is indented after this if, surely its better to guard clause it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not completely indented after that if statement. There is an else statement that returns a var to stop sounds if there is no input text and another if statement to check for HTTPS in the URL (if there is no https it returns) and finally a last if statement to actually send data to tgchat or stop sounds (this should catch everything)
yeah it's not the prettiest code in the world
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nevermind I am just dumb and was looking at the wrong if statement.
I added a return to the end of the proc on that if statement
Did we get anywhere on 516 yet? Its almost in mainline and I want this PR in soon. |
(I know we talked about this on Discord, this is mostly to reiterate for the benefit of others) In a nutshell, no. There's an issue with
The silver lining to all of this is that Not sure how much longer we're going to be on 515 but for the time being I can put a check in for it to do nothing on 516 clients. |
Bounty claimed - cmss13-devs/cmss13#8606 |
Confirmed that the new player is working on 516 and 515. |
What Does This PR Do
Ports:
tgstation/tgstation#30457
tgstation/tgstation#30598
tgstation/tgstation#33839
tgstation/tgstation#36080
tgstation/tgstation#52426 (Playsound/TGchat elements MOST SIMILAR TO THIS VERSION)
tgstation/tgstation#72805 (Some elements)
tgstation/tgstation#74170 (Some elements)
tgstation/tgstation#85953
Monkestation/Monkestation2.0#3826 (Server originally a part of this PR)
If I missed any I am sorry, I tried my best.
cmss13-devs/cmss13#8606 (516 player)
Adds an admin verb that uses yt-dlp to play internet sounds instead of having to upload OGGs to the server.
yt-dlp can play more than just
YouTube videos(unlikely to work with youtube unless there's some server fuckery going on with passing cookies), SoundCloud and Bandcamp are two other examples. You can read up on it here: https://github.com/yt-dlp/yt-dlpConfig set to
null
by default. yt-dlp requires an HTTP server to send sound requests to: https://github.com/Absolucy/ss13-yt-wrapBig shoutout to affected for helping with the HTTP server stuff and code
Why It's Good For The Game
Play sound but actually good.
A proven reliable system from TG and its downstream to play music.
And if my experience from using this on TG is anything to go off of it shouldn't lag the shit out of the server or players when used.
Images of changes
To note: The terminal is only seen by the server host.
2025.01.30-04.17.1.mp4
Testing
I used a VM for most of my testing to ensure everything was working with multiple clients.
Ran the verb many many many times to make sure it was working.
Declaration
Changelog
🆑
add: Added Play Internet Sound to the Event tab.
/:cl: