xiph / Icecast-Server

Icecast streaming media server (Mirror) - Please report bugs at https://gitlab.xiph.org/xiph/icecast-server/issues

Home Page:https://icecast.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

New track information via socket

ohld opened this issue · comments

Hi there and thanks for the project!

Can anyone help me to solve my problem, I can't find anything useful on the Internet.

I need to log out all tracks that have been played on the stream. Since I have found only REST API for statistics, I'm asking you is there any solution to receive the updates about new tracks? It can be also useful to display correct track name on the website.

Thanks.

There is a data stream that contains server stats:
https://icecast.org/news/icecast-release-2_3_0/

Also you could just use the playlist.log:
https://icecast.org/docs/icecast-2.4.1/config-file.html#log

Thanks for the answer!

So can I somehow force Icecast to pass new log line not to text file but to my own script that would parse it and put into the DB?

Like this

new_line_from_playlist | log_parser_and_db_writer.sh

tail -f /path/to/playlist.log | xargs -L1 /path/to/log_parser_and_db_writer.sh

Note that xargs will pass the line as arguments to the script, not through a pipe.
Also make sure that if you use logrotate, that you reopen the file upon rotation of logs. Else you'll stay attached to the now renamed log which won't have any new lines appended.

Thanks a lot!
But still can I set up Icecast to trigger my script then a new song appears? All our songs have different duration so I can't launch my script via crontab or similar scheduler.

Maybe I should change the source code and recompile it by myself?

So I need to receive events of new songs somehow. What solution can you give here? Thanks.

if you run the above you do not need to run it multiple times.
What this does:

  • tail -f opens the file permanently and forwards every new log line through the pipe
  • the pipe | forwards output as input
  • xargs -L1 takes input and for each new line it receives will execute the command /path/to/log_parser_and_db_writer.sh with the content of that line as its arguments.

This is very basic shell scripting. No changes to Icecast are required.