676

Re: Скрипты для Icecast

какой именно кинте сюда

677

Re: Скрипты для Icecast

пишет onix007:

какой именно кинте сюда

Ну неужели так было тяжело прочитать всю страницу обсуждения?!!! Тебе сказали, на предыдущей странице
http://radiotalk.ru/viewtopic.php?pid=36041#p36041

В здоровом теле - здоровый дух!

678

Re: Скрипты для Icecast

пишет dimajak:

Нужен был список маунтов с внешнего Icecast, обычные скрипты не работали из-за наличия символа запятой в названии трека:

$mass=explode(",", $text);

набросал небольшой скрипт:

<?php
function add_mnt($val) {
  $mnt_p = array();
  for($i = 0, $pos = 0; $i < 6; $i++) {
      $pos = strpos($val, ',');
      $znach = ($pos == 0 ? ($i==5 ? $val : '') : substr($val, 0, $pos));
      switch($i) {
      case 0:
          $mnt_p['mnt'] = $znach;
          break;
      case 3:
          $mnt_p['lst'] = $znach;
          break;
      case 5:
          $mnt_p['cur'] = $znach;
          break;
      }
    $val = substr($val, $pos+1);
  }
  return $mnt_p;
}

$handle = file("http://192.168.0.1:8000/status2.xsl");
$mass = $handle[5];
$mnt = array();
while($mass<>'') {
  $pos = strpos($mass, ',/');
  if($pos == 0) {
    $mnt[] = add_mnt($mass);
    break;
  } else {
    $mnt[] = add_mnt(substr($mass, 0, $pos));
    $mass = substr($mass, $pos+1);
  }
}

foreach ($mnt as $val) {
  echo $val['mnt'] ." ". $val['lst']."<br>";
}

echo "Stations=".count($mnt).'<br>';
?>

на выходе $mnt['mnt'] - маунт, $mnt['lst'] - количество текущих слушателей, $mnt['cur'] - текущий трек.
Может кому пригодится.

Забыл сказать, что он сделан под стандартный веб айса, под KH не подойдет.

В здоровом теле - здоровый дух!

679

Re: Скрипты для Icecast

пишет dimajak:

пишет KyPIIaToB:

Забыл сказать, что он сделан под стандартный веб айса, под KH не подойдет.

Про KH не знаю совсем ничего, что это? Где про него почитать?.

http://www.xiphicecast.webspace.virginmedia.com/
У него чутка веб другой, как пример http://radio.kazantip-fm.ru:8000/status2.xsl

В здоровом теле - здоровый дух!

680

Re: Скрипты для Icecast

народ помогите пожалуйста как мне в етом скрипте вывести кто в эфире и как туда пихнуть накрутку слушателей в 7 раз !


?php
///////////////////////////////////////////////////
//icecast2 status refined v1.1 xsl refined
// Author: that dude over there at casterclub.com
// Bugs: post in the forums at casterclub
//////////////////////////////////////////////////
//start the madness already
//////////////////////////////////////////////////
//start the configurations
$ip = "78.46.15.217";               //your server address in the form of mydomain.com or 192.161.1.1
$port = "8000";             //the port of your server
$ice2_station = "RpgFm";     // your station or stream name






////////////////start the parsin action\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//opening socket
$fp = fsockopen("$ip", $port, &$errno, &$errstr, 30); //open connection
if(!$fp) {
    $success=2;  //set if no connection



//edit html to fit your stations site, this display is for offline status
echo'<table>
     <tr>
        <td width="100%" colspan="2">
        <img border="0" src="images/offline.gif" width="22" height="22">
        <b><font face="Arial" size="2" color="#FF0000">'.$ice2_station.' is currently offline</font></b></td>
      </tr>
</table>';
}




if($success!=2){ //if connection
fputs($fp,"GET /status2.xsl HTTP/1.0\r
User-Agent: Icecast2 XSL Parser (Mozilla Compatible)\r
\r
"); //get status2.xsl
while(!feof($fp)) {
  $page .= fgets($fp, 1000);
}
fclose($fp); //close connection
$page = ereg_replace(".*<pre>", "", $page); //extract data
$page = ereg_replace("</pre>.*", ",", $page); //extract data

$numbers = explode(",",$page); //bomb it and extract data
$mount = $numbers[0];
$connections = $numbers[1];
$stream_n = $numbers[2];
$listeners = $numbers[3];
$desc = $numbers[4];
$cur_song = $numbers[5];
$str_url = $numbers[6];
$client_info = $numbers[7];
$test1 = $numbers[8];   //set vars that where empty and still dont know what the heck those values are ;-)
$test2 = $numbers[9];  //set vars that where empty and still dont know what the heck those values are ;-)
$test3 = $numbers[10];   //set vars that where empty and still dont know what the heck those values are ;-)
$mount = $numbers[11];
$connections = $numbers[12];
$station =$numbers[13];
$listeners = $numbers[14];
$description = $numbers[15];
$cur_song = $numbers[16];
$www_url  = $numbers[17];


//edit html to fit your stations site, this display is for online status
echo'


<fieldset><legend>Информация о радио</legend>
<html>
<head>
</head>
<body>
<font size=1><font color=white>Радиостанция:</font></font><font size=1> <font color=#0ee63b><b>Работает</b></font><div class=line></div><font color=white>Cлушает: </font><font color=white> - 3'.$listeners.' -  </font><div class=line></div><font color=white>В эфире:</font> <font color=red><b>'.$connections.'</b></font> <div class=line></div><center><marquee scrolldelay=20 scrollamount=1 truespeed width=100%><font color=#00FF00 style=font-size:11px;font-family: tahoma;><b><font color=#fff></font></b></font></marquee></font></center>
</body>
</html>
<center><marquee scrolldelay=20 scrollamount=1 truespeed width=100%><font color=#00FF00 style=font-size:11px;font-family: tahoma;><b><font color=white>'.$cur_song.'</font></b></font></marquee></center>
';
}


?>

681

Re: Скрипты для Icecast

кто в эфире - если прописано в stream title (name) то здесь $stream_n
если прописано в description то здесь $desc

накрутка ? зачем ? но если так то просто умножить $listeners на 7

682

Re: Скрипты для Icecast

Привет всем!
Использую скрипт по выводу 10 проигравших песен.
Но есть проблема как сделать так чтобы когда проиграли 10 песен, 11 появлялась в этом списке а 1 убиралась.

683

Re: Скрипты для Icecast

конкретнее какой скрипт

684

Re: Скрипты для Icecast

http://radiotalk.ru/viewtopic.php?pid=37457#p37457

685

Re: Скрипты для Icecast

это тот что через last.fm ?

686

Re: Скрипты для Icecast

tarasian666/ Да но я ласт фм не подключал.

687

Re: Скрипты для Icecast

пишет Jon-coool:

Да но я ласт фм не подключал.

Тот виджет без скробблинга на ласт работать не будет. И да, он так и выводит - 1-й трек исчезает, 11-й появляется.

688

Re: Скрипты для Icecast

Нет он выводит 10 потом заново с первого

689

Re: Скрипты для Icecast

ну и как он тогда может выводить если last.fm не подключен ?

690

Re: Скрипты для Icecast

пишет Jon-coool:

Нет он выводит 10 потом заново с первого

Подозреваю что это скрипт который постил здесь Metra, это он так выводит. Но тот скрипт в Last.fm не нуждается и пишет треки в MySQL.

691

Re: Скрипты для Icecast

А как исправить знает кто?
Или дайте тот скрипт который с ласт фм.
Тольок с инструкцией если можно.

Отредактировано Jon-coool (22-04-2012 14:59:52)

692

Re: Скрипты для Icecast

Всем привет.
Интересует как сделать автообновление скрипта.

<?php

    $data = file_get_contents('http://**********/status.xsl?mount=/live');

    function antara($string, $start, $end){
    $string = " ".$string;
    $ini = strpos($string,$start);
    if ($ini == 0) return "";
    $ini += strlen($start);
    $len = strpos($string,$end,$ini) - $ini;
    return substr($string,$ini,$len);
    }

if(antara($data, "Mount started:</td>\n<td class=\"streamdata\">","</td>")  ==''){$data = file_get_contents('http://localhost:88/status.xsl?mount=/nonstop');}
    $data = iconv("utf-8", "cp1251", $data);
    $title = antara($data, "Stream Title:</td>\n<td class=\"streamdata\">","</td>");
    $description = antara($data, "Stream Description:</td>\n<td class=\"streamdata\">","</td>");
    $content_type = antara($data, "Content Type:</td>\n<td class=\"streamdata\">","</td>");
    $Mount_started = antara($data, "Mount started:</td>\n<td class=\"streamdata\">","</td>");
    $Bitrate = antara($data, "Bitrate:</td>\n<td class=\"streamdata\">","</td>");
    $Current_listeners = antara($data, "Current Listeners:</td>\n<td class=\"streamdata\">","</td>");
    $Peak_listeners = antara($data, "Peak Listeners:</td>\n<td class=\"streamdata\">","</td>");
    $Stream_genre = antara($data, "Peak Listeners:</td>\n<td class=\"streamdata\">","</td>");
    $Stream_url = antara($data, "Stream URL:</td>\n<td class=\"streamdata\">","</td>");
    $Current_song = antara($data, "Current Song:</td>\n<td class=\"streamdata\">","</td>");
    $hellp_curr_listeners = antara($hellp, "Сейчас слушают:</td>\n<td class=\"streamdata\">","</td>");
    $hellp_peak_listeners = antara($hellp, "Максимум было</td>\n<td class=\"streamdata\">","</td>");
    $Curr_listens=$Current_listeners2+$Current_listeners+$hellp_curr_listeners;
    $Peak_listens=$Peak_listeners2+$Peak_listeners+$hellp_peak_listeners;

    $staylst=$Curr_listens+1;
    echo '<span style="font-size: 15px; font-family:Trebuchet MS, Tahoma, Arial, sans-serif; color:#3090c3"><b>Название радио:</b> '.$title.' <br>
    <b>За пультом:</b> '.$description.' <br>
    <b>Битрейт:</b> '.$Bitrate.'  <br>
    <b>Сейчас в эфире:<br /></b> '.$Current_song.' <br>
    <br>
    <center><input type="button" value="Слушать радио в плеере" onclick="location.href=\'http://************/live.m3u\'" /></center>';
    ?>

Скрипты выводится на DLE. В блоке с помощью инклуда

Отредактировано rattlesneyk (24-04-2012 16:02:16)

693

Re: Скрипты для Icecast

пишет rattlesneyk:

Всем привет.
Интересует как сделать автообновление скрипта.

Скрипты выводится на DLE. В блоке с помощью инклуда

Можно с помощью AJAX, в этой теме есть пример. Но это решение не очень хорошее так как может генерировать слишком много запросов к веб-серверу и с каждым разом выполнять php.

694

Re: Скрипты для Icecast

Как по мне, так проще использовать обычный мета

<META HTTP-EQUIV="REFRESH" CONTENT="30">
В здоровом теле - здоровый дух!

695

Re: Скрипты для Icecast

пишет KyPIIaToB:

Как по мне, так проще использовать обычный мета

<META HTTP-EQUIV="REFRESH" CONTENT="30">

Конечно проще. Но сути не меняет. Открыли 20 чел. страницу на весь день - и оно рефрешит каждые 3 сек. дергая php-скрипт у всех этих 20-ти чел., а скрипт в свою очередь, долбит запросами Icecast.
Если посещаемость маленькая и ограничений в ресурсах особых нет, то можно конечно хоть аяксом хоть мета рефреш.

696

Re: Скрипты для Icecast

можно отправлять в сон скрипт что генерирует статистику в файл, но сколько он "проживет" зависит от нескольких факторов )

или же после чтоб сна он запускал сам себя, а время сна = время трека

697

Re: Скрипты для Icecast

у меня скрипт на php дергает каждые 3 сек. крон, скрипт проверяет если трек сменился то пишет его в статический файл, с файла потом беру аяксом, в том же числе можно кроссдоменно с помощью jsonp

698

Re: Скрипты для Icecast

насколько я знаю крон может дергать раз в минуту, не чаще

или в кроне куча записей по типу
sleep 3 && sript.php
sleep 6 && script.php
и тд
?

699

Re: Скрипты для Icecast

пишет tarasian666:

насколько я знаю крон может дергать раз в минуту, не чаще

или в кроне куча записей по типу
sleep 3 && sript.php
sleep 6 && script.php
и тд
?

Да, так и есть, скрипт выполняется без апача и fast-cgi, потому посчитал таким методом дергать самое то, бесконечный цикл как то не надежно и стремно форк-бомбу получить.

700

Re: Скрипты для Icecast

да цикл фигово, но вот если в завершении скрипта, так сказать перед смертью пусть сам себя запускает
в крон
* * * * pgrep 'script.php'  || script.php

в скрипте в конце exec("sleep $sec && script.php >/dev/null");