• If you need help or want to discuss things, you now can also join us on our Discord Server!
  • A first preview of the unlimited version of SinusBot can be found in the Upcoming Changes thread. A version for Windows will follow, but we don't have a release date, yet.

EN [BETA] SinusBot Webstream

Zahzi

Member
I rewrote this webstream plugin to make it prettier, and have more functionality.
Github: https://github.com/Zahzi/SinusBot-Stream

Features
- Stream music from your SinusBot bot bots in your browser
- Webpage using Bootstrap and VideoJS
- Displays album art from cached file or from youtube based on metadata
- Displays song name with link to video (if found in metadata) or link to google search
- Support to switch between multiple bot instances via a dropdown or URL
- Last used bot instance and volume stored in cookies
- Links to join Teamspeak server and login to SinusBot's webpanel on the navigation bar

More information (including a demo) can be found on the Github page.
 

Kamikaze

Well-Known Member
Contributor
Thank you very much! Works perfekt :)

Found 1 issue. It don't display current Track.
upload_2016-12-5_15-59-25.png

I implemented your Webstream in my Project and added the current Song with refreshing iframe.
upload_2016-12-5_16-0-51.png
 

Zahzi

Member
Thank you very much! Works perfekt :)

Found 1 issue. It don't display current Track.
View attachment 897

I implemented your Webstream in my Project and added the current Song with refreshing iframe.

Can you provide me with the steps to replicate that issue?
I installed SinusBot and the webplayer on a fresh Ubuntu16.04 VPS, and it seemed to load the song name just fine.
Also, is it just the song name that's not loading, or does the image not load as well (it defaults to a music note).
 

Kamikaze

Well-Known Member
Contributor
Can you provide me with the steps to replicate that issue?
I installed SinusBot and the webplayer on a fresh Ubuntu16.04 VPS, and it seemed to load the song name just fine.
Also, is it just the song name that's not loading, or does the image not load as well (it defaults to a music note).

Thats you code in index.php
HTML:
<div id="songnamediv" align="center"><h5 id="songname">Loading song name...</h5></div>

my Webspace is running on a windows server. i just extracted your folder see here:
http://xkamikaze.de/tsbot/control/stream1/

It's only the songname image is loading.
In browser console I get spammed with this:
11P5zAz.png


May you need to check your function loadSearch()
I commented it out then it dont spam:
Code:
            function loadSearch() {
                var xhttp = new XMLHttpRequest();
                xhttp.onreadystatechange = function() {
                    if (xhttp.readyState == 4 && xhttp.status == 200) {
                        document.getElementById("songname").innerHTML = xhttp.responseText;
                    }
                };/*
                xhttp.open("GET", "getSongURL.php", true);
                xhttp.send();*/
            }
 
Last edited:

Zahzi

Member
http://xkamikaze.de/tsbot/control/stream1/getSongURL.php seems to be throwing an error. Any chance you could send me your PHP error log after trying to call this?
I'm thinking the error is being caused by one of the functions in getSong.php because getImg.php is also not working properly, and both rely on functions in that file.

Also, what method did you use to get the song onto the server? If something other than youtube-dl, can I see the metadata? That's my best guess without seeing the error log.
 

Kamikaze

Well-Known Member
Contributor
Code:
[06-Dec-2016 09:29:40 UTC] PHP Fatal error:  Can't use function return value in write context in C:\Inetpub\vhosts\xkamikaze.de\httpdocs\tsbot\control\stream1\getSongURL.php on line 11

That's in Line 11-15 in getSongURL.php
PHP:
if(!empty(getArtist())) {
    echo '<a class="songlink" href="'.$link.'" target="_blank">Song: '.getName().' from ' .getArtist(). '</a>';
} else {
    echo '<a class="songlink" href="'.$link.'" target="_blank">Song: '.getName().'</a>';
}

I may know why I get this error. I got problems with artist in my script, too.
Thats your "$artist":
Code:
$artist = $status["currentTrack"]["artist"];

But artist isn't set on all songs. That's how i solved it:
PHP:
If (($status["currentTrack"]["type"] == "url")) {
        $artist = $status["currentTrack"]["tempArtist"];
    } else {
        $artist = isset($status["currentTrack"]["artist"]);
    }
    If (($status["currentTrack"]["type"] == "ytdl")) {
        $artist = $status["currentTrack"]["album"];
    } else {
        $artist = "Unbekannt";
    }



All songs on my Bot are downloaded from youtube with the yt-dl. And a few songs are from my local computer.
 

Zahzi

Member
Code:
[06-Dec-2016 09:29:40 UTC] PHP Fatal error:  Can't use function return value in write context in C:\Inetpub\vhosts\xkamikaze.de\httpdocs\tsbot\control\stream1\getSongURL.php on line 11

That's in Line 11-15 in getSongURL.php
PHP:
if(!empty(getArtist())) {
    echo '<a class="songlink" href="'.$link.'" target="_blank">Song: '.getName().' from ' .getArtist(). '</a>';
} else {
    echo '<a class="songlink" href="'.$link.'" target="_blank">Song: '.getName().'</a>';
}

I may know why I get this error. I got problems with artist in my script, too.
Thats your "$artist":
Code:
$artist = $status["currentTrack"]["artist"];

But artist isn't set on all songs. That's how i solved it:
PHP:
If (($status["currentTrack"]["type"] == "url")) {
        $artist = $status["currentTrack"]["tempArtist"];
    } else {
        $artist = isset($status["currentTrack"]["artist"]);
    }
    If (($status["currentTrack"]["type"] == "ytdl")) {
        $artist = $status["currentTrack"]["album"];
    } else {
        $artist = "Unbekannt";
    }



All songs on my Bot are downloaded from youtube with the yt-dl. And a few songs are from my local computer.

I think I may have fixed it by adding some checks to make sure the artist is actually valid. Please update your getSong.php and getSongURL.php from the dev branch on the GitHub page. Let me know if this fixes it. Assuming it doesn't, please send me your error log again with the updated code.
 

Kamikaze

Well-Known Member
Contributor
Still the same. Now other line:
Code:
[06-Dec-2016 22:17:26 UTC] PHP Fatal error:  Can't use function return value in write context in C:\Inetpub\vhosts\xkamikaze.de\httpdocs\tsbot\control\stream1\getSongURL.php on line 10

getSongURL.php Line 10/11
PHP:
if(empty(getName()) || getName() == null || getName() == ""){
    $finalURL = '<p>No song name given. </p>';

As tipp may you try it like me, its working:
Code:
$(document).ready(function getSong(){
                setInterval(function() {
                $("#songname").load('http://xkamikaze.de/tsbot/control/stream/currentSong.php');
            }, 1000);
            });
 
Last edited:

Zahzi

Member
Still the same. Now other line:
Code:
[06-Dec-2016 22:17:26 UTC] PHP Fatal error:  Can't use function return value in write context in C:\Inetpub\vhosts\xkamikaze.de\httpdocs\tsbot\control\stream1\getSongURL.php on line 10

getSongURL.php Line 10/11
PHP:
if(empty(getName()) || getName() == null || getName() == ""){
    $finalURL = '<p>No song name given. </p>';

As tipp may you try it like me, its working:
Code:
$(document).ready(function getSong(){
                setInterval(function() {
                $("#songname").load('http://xkamikaze.de/tsbot/control/stream/currentSong.php');
            }, 1000);
            });

Hmm. Okay. From what I've just read about that error is that it can be caused by my empty() function in older versions of PHP (what version are you running?) I've removed those and restructured the code a bit. You can pull getSongURL.php from the dev branch again.

I noticed you've created currentSong.php to return the song name. Can I see the code for this if my new method doesn't work?

Also if it doesn't work and returns the same error, I'm not sure how much more debugging I'll be able to do without access. Can you try to isolate the cause if you're able? It could be in one of the methods of getSong.php as well.

It seems to be working just fine when I've tried it in Linux, but later I can try to replicate the issue on a windows server later if you can't find the cause; what version are you running?
 

Kamikaze

Well-Known Member
Contributor
Now it's working! :)
PHP Version 5.4.45

If you still want to see my currentSong.php
PHP:
<?php
require_once("../login.php");

$instances = $sinusbot->getInstances(); // Alle Instanzen
for ($i = 0; $i < count($instances); $i++) {
    $status = $sinusbot->getStatus($instances[$i]['uuid']);
    $botname = $instances[$i]["nick"];
    If (($status["currentTrack"]["type"] == "url")) {
        $artist = ' von ' . $status["currentTrack"]["tempArtist"];
    } else {
        $artist = ' von ' . isset($status["currentTrack"]["artist"]);
    }
    If (($status["currentTrack"]["type"] == "ytdl")) {
        $artist =' von ' .  $status["currentTrack"]["album"];
    } else {
        $artist = "";
    }
  
    $playing = (($status["currentTrack"]["type"] == "url") ? $status["currentTrack"]["tempTitle"] : $status["currentTrack"]["title"]) . $artist . '<br>';
    preg_replace( "<br>", "", $playing );
  
    $ytrack = str_replace(' ', '+', $playing);
  
    if ($status['playing']) {
      
        $playing = str_replace(['(', ')'], ["<br>\n(", ")<br>\n"], $playing);
  
        echo $playing;
      

    } else {
        echo $botname . ' ist gestoppt.<br>';
    }
  
}

?>

It's running on a Win Server 2012 R2

Do you know why the stream dont work on opera? :(
 
Last edited:

Zahzi

Member
Now it's working! :)
PHP Version 5.4.45

If you still want to see my currentSong.php
PHP:
<?php
require_once("../login.php");

$instances = $sinusbot->getInstances(); // Alle Instanzen
for ($i = 0; $i < count($instances); $i++) {
    $status = $sinusbot->getStatus($instances[$i]['uuid']);
    $botname = $instances[$i]["nick"];
    If (($status["currentTrack"]["type"] == "url")) {
        $artist = ' von ' . $status["currentTrack"]["tempArtist"];
    } else {
        $artist = ' von ' . isset($status["currentTrack"]["artist"]);
    }
    If (($status["currentTrack"]["type"] == "ytdl")) {
        $artist =' von ' .  $status["currentTrack"]["album"];
    } else {
        $artist = "";
    }

    $playing = (($status["currentTrack"]["type"] == "url") ? $status["currentTrack"]["tempTitle"] : $status["currentTrack"]["title"]) . $artist . '<br>';
    preg_replace( "<br>", "", $playing );

    $ytrack = str_replace(' ', '+', $playing);

    if ($status['playing']) {
    
        $playing = str_replace(['(', ')'], ["<br>\n(", ")<br>\n"], $playing);

        echo $playing;
    

    } else {
        echo $botname . ' ist gestoppt.<br>';
    }

}

?>

It's running on a Win Server 2012 R2

Do you know why the stream dont work on opera? :(

Okay.

Not sure off the top of my head why opera isn't compatible. I'll look into it further when I have time. Issue.
 

Lala Sabathil

Donor
is awesome!
Contributor
Insider
Lol, first time i see my old Version renewed.. then saw the time 2016 :eek: how the f*ck could i not see that..
 
Top