Jump to content
SlicK

Micro online radio(perl)

Recommended Posts

Primeste un playlist de winamp care sa contina mp3'uri(cu altceva nu am incercat)

Testat cu Active Perl 5.8.7.815 si Winamp 2.95 dar probabil merge cu orice perl si orice winamp

Trebuiesc setate "$PORT","$LIST" si "$NAME"

Versiune formatata: http://rootb0x.com/0X0/rad-0.1.txt


#!/usr/bin/perl
use IO::Socket;
$SIG{CHLD}=sub {wait ()};

$PORT=8000;
$LIST="playlist.m3u";
$NAME="<<My tiny online radio station>>";

open(PLAYLIST,$LIST) || die("Error: Could not open $LIST\r\n"); @songs=<PLAYLIST>; close PLAYLIST;

$server=IO::Socket::INET->new(Proto =>'tcp',
LocalPort=>$PORT,
Listen =>SOMAXCONN,
Reuse =>1);
if($server)
{
while(1)
{
while($client=$server->accept())
{
$client->autoflush(1);
if(!fork())
{
foreach $song (@songs)
{
chomp($song);
if(index($song,'#')==-1)
{
print("playing song: $song\n");
print $client "ICY 200 OK\r\n";
print $client "Content-Type: audio/x-mp3stream\r\n";
print $client "Cache-Control: no-cache\r\n";
print $client "Pragma: no-cache\r\n";
print $client "Connection: close\r\n";
print $client "icy-name: $NAME\r\n";
print $client "icy-metadata: 0\r\n\r\n";

open (SONG,"$song");
binmode(SONG);
$read_status =1;
$print_status=1;
$chunk;
while($read_status && $print_status)
{
$read_status=read(SONG,$chunk,1024);
if(defined $chunk && defined $read_status)
{
$print_status=print $client $chunk;
}
undef $chunk;
}
close SONG;
}
}
exit(0);
}
close($client);
}
}
}

Am uitat... Winamp->ADD->ADD URL->"IP:PORT"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...