gerben.dev

Perfect separator for Shoutcast 7.html file

If you use the Shoutcast 7.html trick to get some quick stats about your stream broadcast but are getting some inconsistencies with parsing the comma-separated input you get, try this!

To go along nicely with my previous Shoutcast tip, here is a trick to separate the data in the Shoutcast 7.html for displaying.

If you, like me, use the Shoutcast 7.html trick to get some quick stats about your stream broadcast but are getting some inconsistencies with parsing the comma-separated input you get, try this:

$data = preg_split("/[,]+/", $string, 7);

A possible outcome would be this:

Array (
    [0] => 1
    [1] => 1
    [2] => 1
    [3] => 1000
    [4] => 1
    [5] => 192
    [6] => "Woe, Is Me - Hell, or High Water"
)

If you were to explode() this string, you'd get the artist in 2 nodes and with this song title you'd get that one in 2 nodes as well.

The preg_split function has the nice ability to add a limit parameter, thus saying "Split this string on commas, but only do it for the first 7" and this will guarantee that your artist and song title are stuck together on the last index.

Leave a note

This website uses WebMentions and ActivityPub (via brid.gy), you can respond to this post by linking from your page or replying directly to the Fediverse post.

WebMention

or manually.

Fediverse

On the Fediverse or BlueSky you can search for the URL https://gerben.dev/posts/perfect-seperator-for-shoutcast-7-html-file or search for my handle @gerben.dev@gerben.dev.

View source

✨ It's dangerous out there, please take some space dust! ✨
This work is licensed under CC BY-NC-SA 4.0 | πŸ€– No AI | πŸ“Š Uptime Status