Add Webradio saves the url provided instead of the contents

Hello All

I found a bug trying to add a new webradio .
on Volumio 1.55 - the add new webradio saves the url provided and not the contents from the url provided.

the fix is :

change from : $ret = file_put_contents(’/var/lib/mpd/music/WEBRADIO/’.$name.’.pls’, $url);

to ==>> $ret = file_put_contents(’/var/lib/mpd/music/WEBRADIO/’.$name.’.pls’, file_get_contents($url));

the file name is : /var/www/_footer.php

Hi @brunogivos, I’ve taken this a step further…

if you add a link to a .pls file your trick works a treat! but if you add a link to an .m3u file it breaks, so…

in ‘_footer.php’ I changed this:

//WebRadio Add Dialog
if(isset($_POST['radio-name']) && isset($_POST['radio-url'])) {
    $url = $_POST['radio-url'];
    $name = $_POST['radio-name'];
    $ret = file_put_contents('/var/lib/mpd/music/WEBRADIO/'.$name.'.pls', $url);
	session_start();

to this

//WebRadio Add Dialog
if(isset($_POST['radio-name']) && isset($_POST['radio-url'])) {
    $url = $_POST['radio-url'];
    $name = $_POST['radio-name'];
    $extn = pathinfo($url, PATHINFO_EXTENSION);
    if($extn == 'pls'){ //if its a .pls file copy the contents to $name.pls
        $ret = file_put_contents('/var/lib/mpd/music/WEBRADIO/'.$name.'.pls', file_get_contents($url));
    }
    elseif($extn == 'm3u'){ // if its an m3u, get the link from the m3u and format it as a .pls file
        $rlink = fgets(fopen($url, 'r'));
        $filedata = "[playlist]\r\nnumberofentries=1\r\nFile1=$rlink\r\nTitle1=$name";
        $ret = file_put_contents('/var/lib/mpd/music/WEBRADIO/'.$name.'.pls', $filedata);
    }
    else{ //get the link entered and format it as a .pls file
        $filedata = "[playlist]\r\nnumberofentries=1\r\nFile1=$url\r\nTitle1=$name";
        $ret = file_put_contents('/var/lib/mpd/music/WEBRADIO/'.$name.'.pls', $filedata);
    }
	session_start();

Now you can put a link to a direct stream, an .m3u or a .pls file into the add webradio popup and it will accept it and work! (successes so far anyway!) :smiley:

Great!.

It works well, thanks :wink:

Hi
Under Volumio 1,55 the patch seems NOT to work.

When Browsing radios from the catalog of the Webradio, the Radio NAME is displayed and correctly added to the playlist.
BUT once being played, the radio name DISAPPEAR FOREVER and the list displays and updates only song TITLEs

The expected behaviour in the web Radio playLIST, should be to preserve the Radio name, and eventually add the song name being played.

The proposed patch does NOT solve this problem.

I tried also to save the current play-list, and the .pls file contains ONLY some http address.

Did you noticed this behaviors ?
Is it possible to patch the php code to have this behavior ?