plh/0000755000203200000620000000000010060466643012302 5ustar wavexxstaff00000000000000plh/ices/0000755000203200000620000000000010060466152013220 5ustar wavexxstaff00000000000000plh/ices/bin/0000755000203200000620000000000007714157737014012 5ustar wavexxstaff00000000000000plh/ices/bin/search-noc0000755000203200000620000000026210060466343015742 0ustar wavexxstaff00000000000000#!/bin/sh # search for ogg files without comments find $1 -name "*.ogg" | while read file do lines="`vorbiscomment -l \"$file\" | wc -l`" (( $lines == 0 )) && echo $file done plh/ices/bin/plh0000755000203200000620000000412407714156727014522 0ustar wavexxstaff00000000000000#!/usr/bin/env perl use warnings; use strict; use Fcntl ":flock"; # some needed modules use File::Basename "basename"; # compose some paths my $prg = basename $0; my $base = ($ARGV[0]? $ARGV[0]: "."); my $playlist = $base . "/etc/playlist.txt"; my $position = $base . "/var/position"; my $current = $base . "/var/current"; my $req = $base . "/var/requests"; # check needed files exit 1 if(!-f $playlist); # concurrent file read/writing sub shOpen($$) { my ($name, $mode) = @_; if($mode == LOCK_SH) { $name = "<$name"; } else { $name = ">$name"; } my $fd; open $fd, $name or return; flock $fd, $mode or close $fd and return; return $fd; } sub shClose($) { my ($fd) = @_; flock $fd, LOCK_UN; close $fd; } # load files into arrays sub loadArr($\@) { my ($file, $arr) = @_; my $fd = shOpen $file, LOCK_SH or return; while(<$fd>) { next if(/^\s*$/); push @$arr, $_; } shClose $fd; } sub saveArr($\@) { my ($file, $arr) = @_; my $fd = shOpen $file, LOCK_EX or die; foreach my $e(@$arr) { print $fd $e; } shClose $fd; } sub loadPos() { my $fd = shOpen $position, LOCK_SH or return 0; $_ = <$fd>; my ($number) = /(\d+)/; shClose $fd; return $number; } sub savePos($) { my ($pos) = @_; my $fd = shOpen $position, LOCK_EX or die; print $fd "$pos\n"; shClose $fd; } sub saveCur($) { my ($cur) = @_; my $fd = shOpen $current, LOCK_EX or die; print $fd "$cur\n"; shClose $fd; } # load basic files my @plArr; my @reqArr; my $pos; loadArr $playlist, @plArr; loadArr $req, @reqArr; if(@reqArr) { # satisfy requests, discarding consecutive duplicates $_ = shift @reqArr; ($pos) = /(\d+)/; while(@reqArr && $reqArr[0] == $_) { shift @reqArr; } # check for upper bounds $pos = 0 if(!$pos || $pos > $#plArr); # save the requests back saveArr $req, @reqArr; } else { # advance the playlist $pos = loadPos; # advance the playlist and echo the file ++$pos; $pos = 0 if($pos > $#plArr); # save-back the position savePos $pos; } # current song saveCur $pos; # echo the new file print $plArr[$pos]; plh/var/0000755000203200000620000000000010060466152013065 5ustar wavexxstaff00000000000000plh/var/www/0000755000203200000620000000000010060466152013711 5ustar wavexxstaff00000000000000plh/var/www/radio/0000755000203200000620000000000007727616230015021 5ustar wavexxstaff00000000000000plh/var/www/radio/playlist.pl0000755000203200000620000001117507713764274017236 0ustar wavexxstaff00000000000000#!/usr/bin/perl use strict; use warnings; use Fcntl ":flock"; # Some constants my $base = "/home/ices"; my $playlist = $base . "/etc/playlist.txt"; my $playroot = $base . "/"; my $position = $base . "/var/position"; my $requests = $base . "/var/requests"; my $current = $base . "/var/current"; my $reqUri = "request"; my $nfoUri = "info"; my $bps = 15000; # Request a song and song informations sub req($) { my ($id) = @_; return "#$id"; } # Load a position from a file sub loadPos($) { # read the file my ($file) = @_; open FD, "<$file" or return 0; flock FD, LOCK_SH; $_ = ; flock FD, LOCK_UN; close FD; # get the value /(\d+)/; return ($1? $1 + 1: 0); } # Determine the current song in the playlist and current song my $psong = loadPos($position); my $csong = loadPos($current); # Fetch the list of queued songs my %queue; if(-f $requests) { open REQ, "<$requests"; flock REQ, LOCK_SH; while() { $queue{$1 + 1} = $. if(/(\d+)/); } flock REQ, LOCK_UN; close REQ; } # The current song (if different from the playlist song) # must be showed on the queue $queue{$csong} = 0 if($csong && $psong != $csong); # HTTP headers print "Content-Type: text/html\nPragma: no-cache\n\n"; # Basic HTML structure print q { Playlist

To current, playlist, end.

}; sub basicInterp(\$) { my $r = shift; $_ = $$r; $_ = "" if(!$_); s/_/ /g; s/-$//; s/^pool\///; s/\.ogg$//; # html stuff s//>/g; s/&/&/g; s/"/"/g; # Capitalize the first letter s/^(\w)/\U$1\E/; $$r = $_; } # Convert sizes to hh:ss sub hs($) { my $size = shift; my $time = $size / $bps; sprintf("%02d:%02d", $time / 60, $time % 60); } # The playlist my $n = 1; my $total = 0; my $time; my $qtime = 0; if(open PL, "<$playlist") { my $file; my $size; while() { $file = $_; my ($author, $album, $title) = /^([^-]+)-([^-]+-)?(.+)\.[^\s.]+$/; basicInterp($author); basicInterp($album); basicInterp($title); chop($file); $time = hs($size = (stat("$playroot/$file"))[7]); # hilight the current song my $pre; my $aft; if($n == $psong) { $pre = ""; $aft = ""; } elsif($n == $csong) { $pre = ""; $aft = ""; } elsif(exists $queue{$n}) { $pre = ""; $aft = ""; # total request lenght $qtime += $size; } else { $pre = $aft = ""; } # song uris my $uri = req($n); # Show the queue list. if(($n - 1 == $psong) && %queue) { print q{}; } print qq { }; ++$n; $total += $size; } close PL; }; # Statistics at the end $time = int($total / $bps / 3600); my $days = int($time / 24); $qtime = hs($qtime); # footer print qq {
Author Album Title Approx time

On queue: }; foreach my $elem(sort {$queue{$a} <=> $queue{$b}} keys %queue) { print qq{#$elem }; } print q{
$pre$uri$aft $pre$author$aft $pre$album$aft $pre$title$aft $pre$time$aft


Total playing time: $time hours ($days days) + $qtime for requests.
Legend: Current playlist position, Song being played, Queued song

}; plh/var/www/radio/radio.pls0000644000203200000620000000007707656517623016652 0ustar wavexxstaff00000000000000[playlist] NumberOfEntries=1 File1=http://radio:8000/radio.ogg plh/var/www/radio/seek.pl0000755000203200000620000000133407707460755016320 0ustar wavexxstaff00000000000000#!/usr/bin/env perl # seek to a song id use strict; use warnings; use Fcntl ":flock"; # constants my $position = "/home/ices/var/position"; # HTTP headers print "Content-Type: text/html\nPragma: no-cache\n\n"; # header print q { Seek }; # fetch the song id my ($id) = ($ENV{"REQUEST_URI"} =~ /\?(\d+)$/); if($id) { # save the new position open FD, ">$position" or die; flock FD, LOCK_EX; print FD ($id - 1) . "\n"; flock FD, LOCK_UN; close FD; print "Playlist position altered to #$id."; } else { print "No action to perform or bad request."; } # footer print q { Go back to the playlist. }; plh/var/www/radio/request.pl0000755000203200000620000000155607707731752017065 0ustar wavexxstaff00000000000000#!/usr/bin/env perl # request a song id use strict; use warnings; use Fcntl ":flock"; # constants my $req = "/home/ices/var/requests"; # HTTP headers print "Content-Type: text/html\nPragma: no-cache\n\n"; # header print q { Request }; # fetch the song id my ($ids, $idf) = ($ENV{"REQUEST_URI"} =~ /\?(\d+)(?:-(\d+))?$/); if($ids) { # adjust range $idf = $ids if(!$idf || $idf < $ids); # save the request open FD, ">>$req" or die; flock FD, LOCK_EX; foreach my $n($ids ... $idf) { print FD ($n - 1) . "\n"; } flock FD, LOCK_UN; close FD; print ($idf != $ids? "Songs in range $ids-$idf queued.": "Song #$ids queued."); } else { print "No action to perform or bad request."; } # footer print q { Go back to the playlist. }; plh/var/www/radio/info.pl0000755000203200000620000000162707725067574016333 0ustar wavexxstaff00000000000000#!/usr/bin/env perl # seek to a song id use strict; use warnings; use Fcntl ":flock"; # constants my $base = "/home/ices"; my $playlist = $base . "/etc/playlist.txt"; my $playroot = $base . "/"; # HTTP headers print "Content-Type: text/html\nPragma: no-cache\n\n"; # header print q { Informations }; # fetch the song id my ($id) = ($ENV{"REQUEST_URI"} =~ /\?(\d+)$/); if($id) { # fetch the song id my $file = qx{sed -ne '${id}p' '$playlist'}; chop $file; # fetch some informations my $info = qx{/usr/local/bin/ogginfo -v "$playroot/$file" | sed -e '1,2d'}; print qq {

Informations about song #$id

$info

}; } else { print "No action to perform or bad request."; } # footer print q { Go back to the playlist. }; plh/var/www/radio/index.html0000644000203200000620000000127110060466477017017 0ustar wavexxstaff00000000000000 Radio™

plh/README0000644000203200000620000000052210060467043013154 0ustar wavexxstaff00000000000000Copyright(c) 2002 by wave++ (Yuri D'Elia) Use ices/bin/plh as a backend for ices. Create a file in $base/etc called playlist.txt containing the list of ogg files to stream. Touch the $base/base/{current,position,requests} to be writable by your web-server. Ensure all files have comments using ices/bin/search-noc.