• English
  • Deutsch
  • Español
  • Русский
Professional Radio Automation at a price you can afford.Professional Radio Automation at a price you can afford.
RadioBOSS box
RadioBOSS makes automating your broadcast to the world, your business or shop professional, simple, affordable, reliable.

Author Topic: [Web site] Song request demo script  (Read 24528 times)

0 Members and 1 Guest are viewing this topic.

djsoft

  • Administrator
  • Posts: 10406
    • http://www.djsoft.net
Re: Song request demo script
« Reply #15 on: June 10, 2018, 06:04:41 AM »
Could a script be incorporated into the next release of RB which could do this automatically if desired?
The script has to be installed on your web site, and you can always get the updated version here.
Dmitry  •  DJSoft.Net Team  •  Email: support@djsoft.net

stokemusic

  • Posts: 22
Re: Song request demo script
« Reply #16 on: June 11, 2018, 03:59:01 AM »
yes I understand that. The trouble is the script provided here doesn't seem to work, either for me or anyone else.

djsoft

  • Administrator
  • Posts: 10406
    • http://www.djsoft.net
Re: Song request demo script
« Reply #17 on: June 11, 2018, 03:25:47 PM »
yes I understand that. The trouble is the script provided here doesn't seem to work, either for me or anyone else.
The script is pretty simple and, if configured correctly it will work. You also need to make sure that it's able to communicate with RadioBOSS. If it doesn't work for you, please contact us at support@djsoft.net, and attach the script you use.
Dmitry  •  DJSoft.Net Team  •  Email: support@djsoft.net

diabolix

  • Posts: 44
Re: Song request demo script
« Reply #18 on: September 24, 2018, 06:06:05 AM »

You can make a video demonstration, because I do not know anything and I do not know how it is done, it would be so kind to resign or some soul that understands how it is done, to make a video for those who do not understand how it is done please, thank you

djsoft

  • Administrator
  • Posts: 10406
    • http://www.djsoft.net
Re: Song request demo script
« Reply #19 on: September 24, 2018, 06:28:12 AM »
You can make a video demonstration, because I do not know anything and I do not know how it is done, it would be so kind to resign or some soul that understands how it is done, to make a video for those who do not understand how it is done please, thank you
This requires some (little) web programming knowledge. This topic is huge so it can't be covered here.
The general idea is that you modify access parameters in the script so it connects with your RadioBOSS installation, and then upload the script to your web site. 
Dmitry  •  DJSoft.Net Team  •  Email: support@djsoft.net

diabolix

  • Posts: 44
Re: Song request demo script
« Reply #20 on: September 24, 2018, 02:25:02 PM »
Until then I understand but I do not understand how to do it and I would like some video guide how to do step by step because I have no idea how to do it :(

BN-Julian

  • Posts: 42
Re: Song request demo script
« Reply #21 on: September 24, 2018, 08:47:03 PM »
Please use google and read into coding or ask and pay a coder, if you are not interested in learning the easiest steps to modify code!

This demoscript is a fantastic service of Dmitry and thanks on this way for his fantastic work!

djsoft

  • Administrator
  • Posts: 10406
    • http://www.djsoft.net
Re: Song request demo script
« Reply #22 on: September 25, 2018, 03:35:45 AM »
Until then I understand but I do not understand how to do it and I would like some video guide how to do step by step because I have no idea how to do it :(
Video guide is not possible, the topic is too broad so there's no step by step guide possible as there are lots of ways how web sites are managed. The exact procedure would be different for different web sites. You'll need to obtain some general knowledge of the topic. Or, as BN-Julian suggested, pay someone to do this for you (but still it is advisable to understand how it works).
Dmitry  •  DJSoft.Net Team  •  Email: support@djsoft.net

Marcel Märtl

  • Posts: 1
Re: Song request demo script
« Reply #23 on: October 15, 2018, 02:05:09 PM »
So I inserted the script and now I get this Error-Message:
Quote (selected)
Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /var/customers/webs/ni268724_1/wp-content/plugins/insert-php/includes/shortcodes.php(66) : eval()'d code on line 71 Warning: file_get_contents(*******************************&action=library&filename=Datenbank+Musik): failed to open stream: no suitable wrapper could be found in /var/customers/webs/ni268724_1/wp-content/plugins/insert-php/includes/shortcodes.php(66) : eval()'d code on line 71

The Problem is I cant acces my php.ini to enable xml. Is there any workaround?

djsoft

  • Administrator
  • Posts: 10406
    • http://www.djsoft.net
Re: Song request demo script
« Reply #24 on: October 16, 2018, 02:20:30 AM »
The Problem is I cant acces my php.ini to enable xml. Is there any workaround?
I don't think so - this is a requirement for the script to work. You should contact your web host to enable this feature. Or change the host to a less restrictive one.
Dmitry  •  DJSoft.Net Team  •  Email: support@djsoft.net

NICKY G DJ

  • Posts: 100
SONGREQUEST PHP script problem
« Reply #25 on: November 08, 2018, 09:52:21 AM »
hello,
I think the php script "songrequest.php" provided has some problems.
In practice, if I create the complete list manually from the browser, the thing works.

Song request example:

h t t p://192.168.1.106:9001/?pass=JOWHjWTqdH&action=songrequest&filename=C:\Users\XXXX\Desktop\RADIO\AUDIO\MUSIC\elviso%20presley%20-%20trouble.mp3&message=hello%20Elvis

example displays my library:

h t t p://192.168.1.106:9001/?pass=JOWHjWTqdH&action=library&filename=my_music

if I do the request through the form in the PHP script instead, I will return this error

"Song request failed: unable to load music library."

my php file settings:

// details to connect to RadioBOSS API
$ rb_server = '192.168.1.106'; // RadioBOSS hostname (IP)
$ rb_port = '9001'; // RadioBOSS port
$ rb_password = 'JOWHjWTqdH'; // Password API
// music library name (omitting the .xml extension, the library is loaded from
$ rb_library = 'my_music';


where am I wrong? where is the script wrong?

because I manually manage to access my xml list on my computer and through php form I can not access it ?? so I suppose it's the wrong php code !!!
« Last Edit: November 08, 2018, 10:43:56 AM by NICKY G DJ »

djsoft

  • Administrator
  • Posts: 10406
    • http://www.djsoft.net
Re: SONGREQUEST PHP script problem
« Reply #26 on: November 09, 2018, 05:23:30 AM »
If you have uploaded PHP script to an external server, then the problem could be that 192.168.1.106 is not accessible from there, or that port 9001 is not accessible.

If this is a Windows server, access it via a remote desktop, start a web browser there and see if http://192.168.1.106:9001/?pass=JOWHjWTqdH&action=library&filename=my_music is accessible from there. If browser gives you an error, the script will not work either.
Dmitry  •  DJSoft.Net Team  •  Email: support@djsoft.net

djsoft

  • Administrator
  • Posts: 10406
    • http://www.djsoft.net
Re: Song request demo script
« Reply #27 on: November 09, 2018, 05:57:01 AM »
Song request script updated to include $show_errors configuration option that enables detailed error messages when something's not working, details in the first post and the script itself.
Dmitry  •  DJSoft.Net Team  •  Email: support@djsoft.net

NICKY G DJ

  • Posts: 100
Re: Song request script [The problem is solved]
« Reply #28 on: November 09, 2018, 12:19:57 PM »
in practice I had to:

1. create a Forewarding rule in the router by setting the service port (i.e. 80), local IP (the PC IP) and local port (the one in RB)

2. the php script:
in $ RB_Server put the public IP assigned to my router
in $ RB_Server put service port (80)

3. the php script provided on the site works, but in my case I had to modify it, because I had problems with my altervista.com server because it does not accept the "file_get_contents" statement so I modified the php by changing it with cURL.
Now it works with all web hosting.


------------------------->>> explanations and other ideas <<<

I would like to ask for clarifications and implementations regarding the songrequest function:

1. if this function is used automatically by the seduler, then airing when there is nobody on the radio it can be fine, indeed very well.
But I would like to understand how it could be useful for a live with the speaker who could announce the requested song.

a) practically once I get the requests in RB I display them in the request song panel (ctrl + Y)

b) if I insert a message of very few characters the speaker could read the message and then send the song to the playlist, if the message is long, the song request window (ctrl + Y) makes this reading operation inconvenient.

c) if for example I would like to insert the requested songs into playlists and then the speaker wants to announce the requested song, making the applicant's name and reading the message sent via web form, what happens, when the song request window (ctrl + y ) the song is inserted into playlists for airing, all the information regarding the message sent (which could be hello are mary and I want to dedicate this song to robert because I love it), are lost.

d) I believe that this information should always be available in some way, maybe create a specific TAB in RB (such as a notepad file) where you can set the size of the text and the rarity for easy reading live.
maybe connect with a color highlighting the song on the air required with the message of that song so as to have track that this requested song was associated with that message sent by that listener.


e) I think it is right to insert other fields in the web form which name and surname of who forward the message, this is possible by implementing the php script, but the song request is not enabled to read and show other fields on the screen.
further fields could also be the city of origin, the telephone number and other things that I do not know now.

f) we admit that I have received a list of 100 requests, is it possible to click on the various items to rearrange by artist, title, time of request?
I think that instead of "160 minute ago" better enter the date / time field 09/11/2018 at 18:07 I think it's more practical.

2. expand the PHP script so that there are some fields of research.

author, song, year, genre

For example, through the form I could search within the xml database all the songs of elvis presley, the search shows me that in the list (database) there are 30 songs, near each song I could go out a selection check, then once selected the song below I could fill in other fields such as first name (of the listener requesting the song) and then the message to send ...
so it would be easier and safer to let the artist know which tracks are available in RB

3. another interesting feature for the song request could be this:

The possibility of using a website to make a request for a song, (author - title) and instead of the text message, insert the sending of a voice audio file.

so we admit a seduler song request playlist ....
I could set ...

jingle
      [song request block]
      - posta_vocale.mp3 (voice message of the listener requesting the song)
      - author-titolo.mp3    file

then play the jingle (optional)
first list the file associated with the request received from the website
and then the song file taken from the music library ...

the file with the voice message could be mounted on the intro of the song if sufficiently long, or it starts under a preset base, then fades the base and the song starts and the vocal ending must end on the intro of the requested song.

4. would it be an idea to create a TAB for receiving emails (text only), for the reception of messages to be read on the speaker?
or always a tab that sends messages to RB via web form? (as happens with the reception of messages in the php script for the request of songs, but in this case only and exclusively for text messages.

also for receiving messages via whatsapp (I think Whatsapp does not make this possible), or receiving via telegram etc.





Quote (selected)
<?php
/*
    RadioBOSS Song Request demo script

    To play the requested songs in RadioBOSS, schedule an event with "playrequestedsong" command:
    http://manual.djsoft.net/radioboss/en/scheduler_commands.htm#songrequest

    Please make sure the RadioBOSS API is enabled and a password is set:
    http://manual.djsoft.net/radioboss/en/remote_controlapi.htm

   If RadioBOSS is installed on a server, please make sure the API port (9000 by default) is allowed in firewall.

    Home or studio PC:
   If RadioBOSS is installed on a home or studio PC, please make sure it has a static IP address.
    If a static IP address is not available, a Dynamic DNS address has to be used instead
    The IP address (or dynamic DNS address) is entered into the $rb_server variable (please do not include http://)
   
   If a computer is behing a NAT (this is usually the case when a router is used), then API port (9000 by default) has
   to be forwarded in router settings - see port forwarding documentation for your router.
*/

//---------------//
// CONFIGURATION //
//---------------//
//RadioBOSS API connection details
$rb_server = '95.xxx.xxx.xxx'; //RadioBOSS hostname or IP
$rb_port = '80'; //RadioBOSS port
$rb_password = 'YdVdfWTqdH'; //API password
//music library name, omitting the .xml extension, the library is loaded from "Music library folder" as set in RadioBOSS settings
$rb_library = 'my_library_music';


//show detailed error messages (1 - show error details, 0 - show only general error messages)
//IMPORTANT! Make sure this is set to 0 once everything is configured and working to avoid revealing too many details to users!
//Error messages may contain passwords and other sensitive information
//Set this to 1 only if something's not working to get more details
$show_errors = 0;

//-------------------//
// SONG REQUEST FORM //
//-------------- ----//
//API URL base
$rb_api = "http://$rb_server:$rb_port?pass=$rb_password";

function result($msg) {
    $back_link = '<a href="javascript:history.back();">Back</a>';
    exit("$msg $back_link");
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>RadioBOSS Song Request demo</title>
    <style>
        body {
            font-family: Tahoma, sans-serif;
            font-size: 0.8em;
        }
        label {
            display: block;
            margin-bottom: 5pt;
        }
    </style>
</head>
<body>
<?php
    $type = isset($_POST['type']) ? $_POST['type'] : '';
    if ($type === '') {
        echo '<form method="post">
            <input type="hidden" name="type" value="request">
            <label>Artist<br><input size="30" name="artist"></label>
            <label>Title<br><input size="30" name="title"></label>
            <label>Message<br><textarea cols="30" rows="3" name="message" maxlength="13"></textarea></label>
            <button>Request a song</button>
        </form>';
    } elseif ($type === 'request') {
        //requested artist
        $artist = mb_strtolower(trim($_POST['artist']));
        if ($artist === '')
            $artist = false;
        //requested title
        $title = mb_strtolower(trim($_POST['title']));
        if ($title === '')
            $title = false;
        if (($artist === false) && ($title === false))
            result('No artist or title entered.');
      
         //Start Original Code (No Altervista)
               //load library
               //$library_raw = @file_get_contents("$rb_api&action=library&filename=" . urlencode($rb_library));
               //if ($library_raw === false) {
               //    $err = 'Song request failed: unable to load music library.';
               //    if ($show_errors)
               //        $err .= ' Error: ' . error_get_last()['message'];
               //    result($err);
               // }
         //End Original Code (No Altervista)
         
         
         //Start of MyCode (Si Altervista)
         //load library
                  // Get cURL resource
                  $curl = curl_init();
                  // Set some options - we are passing in a useragent too here
                  curl_setopt_array($curl, array(
                     CURLOPT_RETURNTRANSFER => 1,
                     CURLOPT_URL => "$rb_api&action=library&filename=" . urlencode($rb_library),
                     CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0'
                  ));
                  // Send the request & save response to $resp
                  $library_raw = curl_exec($curl);
                  // Close request to clear up some resources
                  curl_close($curl);
               
                  echo $library_raw;
         //End of MyCode (Si Altervista)
      
      if ($library_raw === false) {
           $err = 'Song request failed: unable to load music library.';
           if ($show_errors)
               $err .= ' Error: ' . error_get_last()['message'];
           result($err);
        } 
      
        //parse XML data
        $xml = simplexml_load_string($library_raw);
        if ($xml === false)
            result('Song request failed: unable to parse music library XML data.');
        $fn = false;
        //search requested song in a music library
        foreach ($xml as $x) {
            if ($x->getName() !== 'Track')
                continue;
            $found = (($artist === false) || (mb_strtolower((string)$x['artist']) === $artist)) &&
                (($title === false) || (mb_strtolower((string)$x['title']) === $title));
            if ($found) {
                $fn = (string)$x['filename'];
                break;
            }
        }
        //song found, add to requested songs list in RadioBOSS
        if ($fn !== false) {
            $msg = isset($_POST['message']) ? $_POST['message'] : '';
            $res = @file_get_contents("$rb_api&action=songrequest&filename=" . urlencode($fn) . "&message=" . urlencode($msg));
            if ($res === "OK")
                result('Song requested successfully!');
            else {
                $err = 'An error occurred while adding song request.';
                if ($show_errors)
                    $err .= ' Error: ' . error_get_last()['message'];
                result($err);
            }
        }
        else
            result('Requested song not found in the music library.');
    }
?>
</body>
</html>

« Last Edit: November 09, 2018, 03:58:43 PM by NICKY G DJ »

djsoft

  • Administrator
  • Posts: 10406
    • http://www.djsoft.net
Re: Song request demo script
« Reply #29 on: November 10, 2018, 03:41:26 PM »
3. the php script provided on the site works, but in my case I had to modify it, because I had problems with my altervista.com server because it does not accept the "file_get_contents" statement so I modified the php by changing it with cURL.
Now it works with all web hosting.
Except those that do not support cURL :) It is a good addition, and we'll add the cURL option (configurable) to the demo script as well.

But I would like to understand how it could be useful for a live with the speaker who could announce the requested song.
You can open the requests window and use the "To player" button to insert the songs to the playlist manually.

b) if I insert a message of very few characters the speaker could read the message and then send the song to the playlist, if the message is long, the song request window (ctrl + Y) makes this reading operation inconvenient.

c) if for example I would like to insert the requested songs into playlists and then the speaker wants to announce the requested song, making the applicant's name and reading the message sent via web form, what happens, when the song request window (ctrl + y ) the song is inserted into playlists for airing, all the information regarding the message sent (which could be hello are mary and I want to dedicate this song to robert because I love it), are lost.

d) I believe that this information should always be available in some way, maybe create a specific TAB in RB (such as a notepad file) where you can set the size of the text and the rarity for easy reading live.
maybe connect with a color highlighting the song on the air required with the message of that song so as to have track that this requested song was associated with that message sent by that listener.

Thank you for the suggestions, we'll consider adding those improvements. It will certainly be possible to read long messages.

e) I think it is right to insert other fields in the web form which name and surname of who forward the message, this is possible by implementing the php script, but the song request is not enabled to read and show other fields on the screen.
further fields could also be the city of origin, the telephone number and other things that I do not know now.
This should be done by your script, and the info can be inserted into the "message".
Dmitry  •  DJSoft.Net Team  •  Email: support@djsoft.net