[Web site] Song request demo script

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 :(
 
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!
 
diabolix said:
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).
 
So I inserted the script and now I get this Error-Message:
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?
 
Marcel M?rtl said:
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.
 
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 !!!
 
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.
 
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.
 
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.





<?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
<input size="30" name="artist"></label>
            <label>Title
<input size="30" name="title"></label>
            <label>Message
<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>
 

Attachments

  • code.jpg
    code.jpg
    579 KB · Views: 802
NICKY G DJ said:
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.

NICKY G DJ said:
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.

NICKY G DJ said:
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.

NICKY G DJ said:
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".
 
NICKY G DJ said:
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.
All this can be done on a web site, using the scripts - as you can get the full library from RadioBOSS, you can perform any kind of searches on it. As for inserting audio files, this is also possible using RadioBOSS API.
 
NICKY G DJ said:
how is it possible via RB API to send a voice file to the direction and put it in the queue before the requested song
Currently it is not possible to upload files using the API - you can only insert at a defined position. I'm sorry for misinformation
 
djsoft said:
NICKY G DJ said:
how is it possible via RB API to send a voice file to the direction and put it in the queue before the requested song
Currently it is not possible to upload files using the API - you can only insert at a defined position. I'm sorry for misinformation

I think it's a nice implementation for dedications with messages on demand (to be operated in total autonomy)
 

Attachments

  • messa.png
    messa.png
    45.8 KB · Views: 675
NICKY G DJ said:
I think it's a nice implementation for dedications with messages on demand (to be operated in total autonomy)
The uploaded audio files have to be moderated as users can upload anything like offensive language or something like this.
 
Boszor said:
Hello there is a possibility synonymous to play a message via TTS?
Currently this is not possible. Also, what if a user writes something offensive in it?
 
For this one could create a filter list beforehand, which filters out these words.

Is there a way to announce the song request event with a previous jinggle? My attempts have always failed miserably. Either he did not accept the command anymore or if I let it run directly through the script I only took one song out of the request. Can one also say that the song request is read out completely automatically in a timeframe and not just 1 song.
 
Hi

Works great!

At first it did not work.  There was same error that was described in the beginning of this topic.

The problem was that some hosting providers BLOCK some ports.  The minute port was unblocked, all started to work just great!

I have a question, however:

Is it possible to apply some filters for listeners:

number of allowed requests per hour and no more than X requests per day (ip based)

Is there a way to make a way for listeners to search for a song before they request it?

Thanks.



 
Back
Top