xiph / Icecast-Server

Icecast streaming media server (Mirror) - Please report bugs at https://gitlab.xiph.org/xiph/icecast-server/issues
https://icecast.org
GNU General Public License v2.0
465 stars 127 forks source link

New track information via socket #26

Closed ohld closed 6 years ago

ohld commented 6 years ago

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.

dm8tbr commented 6 years ago

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

ohld commented 6 years ago

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
dm8tbr commented 6 years ago

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.

ohld commented 6 years ago

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.

dm8tbr commented 6 years ago

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

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

ohld commented 6 years ago

Thanks