I would like from http://player.radiopilatus.ch the interpreter and the song annouce in the irc in realtime when change the Song an new annouce
I have testet with this, but unfortunately I have no issue
set radio_url "http://player.radiopilatus.ch"
bind pub - !radio radio_get
proc radio_get { nick uhost handle channel text } {
global radio_url
set file [open "|lynx -source $radio_url" r]
set html "[gets $file]"
regsub -all "<br>" $html " " html
regsub -all "<\[^b]{0,1}b{0,1}>" $html "" html
regsub "text1=" $html "" html
regsub "NOW PLAYING:" $html "Now on http://player.radiopilatus.ch playing \002" html
putnow "PRIVMSG $channel :$html";
}
At the end I would like something like:
!song Interpret Song Unixtimestamp !song MARLON_ROUDETTE NEW_AGE 1483293195
Typically, you need to ask the website every so often what the current state (i.e., the current song) is and report when you see a change. The more frequently you ask, the more accurate the results, but the greater the load on the site (and many people object to having their sites hammered by others' code). So let's poll every 10 seconds, i.e., 10000 milliseconds.
We also need to store the current value in a global variable so that we can detect when a change has happened. When the change does happen, we update the global. It's going to be simpler if we break the code up into several procedures, each with its own simpler job.
Notice that there are now 4 procedures.
get_current_song
talks to the website to scrape the current song and returns that. It does nothing else.get_current_song_if_changed
builds on that to detect song changes.poll_and_report_song_changes
builds on that to periodically poll, and if a change is detected, report it on the channel.radio_control
is what is actually bound to actions, and lets you turn on and off the polling.