Rank: Newbie
Groups: Registered
Joined: 2/2/2017(UTC) Posts: 8 Location: Balen, Belgium
Thanks: 3 times
|
dark_ata wrote:This code should convert the html to xml, you can load in vmix using //xml //previous for the last song when is available, //xml //current for the current and //xml //next for the next if is available Code:<?php
$text = file_get_contents('http://www.trendyfm.be/rup/playlist.html');
$previus="<b>Net gemist:";
$current="<b>Nu on-air:";
$next="<b>Next:";
$sxe = new SimpleXMLElement('<xml/>');
$pos_prev=strpos($text, $previus);
if($pos_prev!=false){
$text_prev=substr(strchr($text,"#911419"),13);
$name_prev=substr($text_prev,0,strpos($text_prev,"<"));
$song_prev=substr(strchr($text_prev,"- </b><b>"),10);
$song_prev=substr($song_prev,0,strpos($song_prev,"<"));
$previ = $sxe->addChild('previous');
$previ->addChild("Artist", $name_prev);
$previ->addChild("Song", $song_prev);
}
$pos_current=strpos($text, $current);
if($pos_current!=false){
$text_cu=strchr($text,$current);
$text_current=substr(strchr($text_cu,"#911419"),13);
$name_current=substr($text_current,0,strpos($text_current,"<"));
$song_current=substr(strchr($text_current,"- </b><b>"),9);
$song_current=substr($song_current,0,strpos($song_current,"<"));
$curr = $sxe->addChild('current');
$curr->addChild("Artist", $name_current);
$curr->addChild("Song", $song_current);
}
$pos_next=strpos($text, $next);
if($pos_next!=false){
$text_ne=strchr($text,$next);
$text_next=substr(strchr($text_ne,"#911419"),13);
$name_next=substr($text_next,0,strpos($text_next,"<"));
$song_next=substr(strchr($text_next,"- </b><b>"),9);
$song_next=substr($song_next,0,strpos($song_next,"<"));
$nex = $sxe->addChild('next');
$nex->addChild("Artist", $name_next);
$nex->addChild("Song", $song_next);
}
echo $sxe->asXML();
?>
Hej Dark_ata thx for this !! YOU ARE THE BEST !! Thx !!
|