icecream-1.3/0000755000175000017500000000000011005404501012401 5ustar cgrecocgrecoicecream-1.3/Changelog0000644000175000017500000000173011005404501014214 0ustar cgrecocgreco* Version 1.3 (27 Apr 2008) - Modified by Cristian Greco - Parse .m3u playlist starting with a comment - Fix wrong request to server, including strange 404 errors and 302 redirect - Support direct stream URLs - Save anonymous stream with a pattern filename - Save .ogg streams with right extension - Split into tracks and tee to stdout at the same time - Option '--user-agent' was mentioned as '--useragent' - New description and example in man page * Version 1.2 (17 Jan 2005) - Added support for formatted filenames (e.g, "podcast-%Y-%m-%d"), thanks to Sean Dague for the patch * Version 1.0 (10 Nov 2005) - All bugs resolved (all two of them!) - Optional sync to mp3 headers - Some code cleanup * Version 0.8 (27 Sep 2003) - Added a stop-condition option (elapsed minutes, songs, KB or MB) - Fixed Digitally Imported playlist bug (thanks to Andrej for his patch) * Version 0.7 (29 Mar 2003) - First public version now available for download icecream-1.3/Makefile0000644000175000017500000000022111005404501014034 0ustar cgrecocgreco PREFIX=/usr/local BIN=icecream MAN=icecream.1 all: install: install -m 0755 $(BIN) $(PREFIX)/bin install -m 0644 $(MAN) $(PREFIX)/man/man1 icecream-1.3/icecream0000755000175000017500000006530211005404501014105 0ustar cgrecocgreco#!/usr/bin/perl -w # # icecream 1.3 # Copyright (c) 2003-2008 Gil Megidish # # Formatted filename patch by Sean Dague (13 Dec 2005) # Modified by Cristian Greco 2008 (release 1.3) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; use IO::Socket; use Getopt::Long; my $config = {}; my $def_agent = "icecream/1.3"; my $version = "icecream/1.3"; my $accept_header = "audio/mpeg, audio/x-mpegurl, audio/x-scpls, */*"; my $def_timeout = 500; my $max_sync_count = 3; my $largest_unknown_buffer = 1024**2; my @bitrate_table = ( [0, 0, 0, 0, 0], [32, 32, 32, 32, 8], [64, 48, 40, 48, 16], [96, 56, 48, 56, 24], [128, 64, 56, 64, 32], [160, 80, 64, 80, 40], [192, 96, 80, 96, 48], [224, 112, 96, 112, 56], [256, 128, 112, 128, 64], [288, 160, 128, 144, 80], [320, 192, 160, 160, 96], [352, 224, 192, 176, 112], [384, 256, 224, 192, 128], [416, 320, 256, 224, 144], [448, 384, 320, 256, 160], [-1, -1, -1, -1, -1, -1] ); my @freq_table = ( [44100, 22050, 11025], [48000, 24000, 12000], [32000, 16000, 8000], [1, 1, 1, 1] ); sub check_stop_cond { return if (! defined $config->{'stop-cond'}); $config->{'stop-cond'} =~ /^(\d+)(\w+)$/; my $count = $1; my $units = $2; my $kb = $config->{'bytes-downloaded'} / 1024; if ($units eq 'kb') { $config->{stop} = ($kb >= $count); } elsif ($units eq 'mb') { $config->{stop} = ($kb >= ($count * 1024)); } elsif ($units eq 'min') { my $elapsed = (time() - $config->{'start-time'}) / 60; $config->{stop} = ($elapsed >= $count); } elsif ($units eq 'songs') { $config->{stop} = ($config->{'played-tracks'} >= $count); } else { die "unhandled unit $units\n"; } } sub parse_m3u_playlist { my ($playlist) = shift || return undef; my (@lines) = split('\n', $playlist); my (@queue) = (); my ($id) = 1; foreach my $s (@lines) { # skip lines beginning with a comment if ($s =~ /^#EXT/) { next; } my ($entry) = {}; $entry->{id} = $id++; $entry->{file} = $s; push @queue, $entry; } return @queue; } sub parse_pls_playlist { my ($playlist) = shift || return undef; my (@lines) = split('\n', $playlist); my ($line); my ($entry, $dirty); my ($lastid); my (@queue) = (); # parse_pls_playlist parses a .pls playlist, and # returns a vector of all links in content $line = shift @lines; if (! defined $line || $line !~ /^\[playlist\]/i) { # not a valid playlist print STDERR "invalid playlist file\n"; return undef; } $entry = {}; $dirty = 0; $lastid = 1; $line = shift @lines; while (defined $line) { my ($property, $id, $value); # now expecting FileX, TitleX and LengthX if ($line =~ /^(\w+)(\d+)=(.+)$/) { $property = $1; $id = $2; $value = $3; $value =~ s/\s*$//s; if ($id ne $lastid) { # different entry push @queue, $entry; $entry = {}; $dirty = 0; $lastid = $id; } # add property to hash $property = lc $property; $entry->{$property} = $value; $dirty = 1; } $line = shift @lines; } push @queue, $entry if $dirty; return @queue; } sub slurp_file { my ($filename) = shift || return undef; my ($data); open(SLURPEE, "<$filename") || return undef; # set delimiter to undef, next read will load the # entire file into memory local $/ = undef; # read entire file $data = ; close SLURPEE; return $data; } sub select_socket { my ($handle) = shift || return 0; my ($timeout) = shift || return 0; my ($v) = ''; vec($v, fileno($handle), 1) = 1; return select($v, $v, $v, $timeout / 1000.0); } sub recv_chunk { my ($handle) = shift || return undef; my ($cnt) = shift || return undef; my ($data) = ''; while ($cnt != 0) { my ($chunk, $chunksize); my ($next_chunk); $next_chunk = ($cnt > 0) ? $cnt : 1024; if (select_socket($handle, $def_timeout) <= 0) { # timed out print "Timedout!\n"; last; } $handle->recv($chunk, $next_chunk); $chunksize = length($chunk); if ($chunksize == 0) { # error occured, or end of stream last; } $data .= $chunk; $cnt -= $chunksize; # paranoia, what if a bigger chunk is received $cnt = 0 unless $cnt > 0; } return $data; } sub split_url { my ($url) = shift || return undef; my ($host, $port, $path); $port = undef; if ($url =~ /^([\d\w\._\-]+)(:\d+)??(\/.*)??$/) { $host = $1; if (defined $2) { # port includes the colon $port = substr($2, 1); } $path = $3; } else { # unparsable print "*** UNPARSABLE ***\n"; return undef; } return ($host, $port, $path); } sub slurp_http { my ($location) = shift || return undef; my ($host, $port, $path); my ($sock); my ($data, $request); debug("slurping http resource at $location"); # parse location $location = strip_protocol($location); ($host, $port, $path) = split_url($location); # parsing errors? return undef unless defined $host; $port = 80 unless defined $port; $path = "/" unless defined $path; debug("retreiving from $host $port $path"); $sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, Proto => 'tcp'); # error connecting? return undef unless defined $sock; $sock->autoflush(1); my $agent = $config->{'user-agent'}; $request = "GET $path HTTP/1.0\r\n" . "Host: $host:$port\r\n" . "Accept: ${accept_header}\r\n" . "User-Agent: $agent\r\n" . "\r\n"; debug("sending request to server", $request); print $sock $request; $data = recv_chunk($sock, -1); $sock->shutdown(2); debug("data retreived from server", $data); return $data; } sub get_http_body { my ($message) = shift || return undef; my ($header, $body); ($header, $body) = split("\r\n\r\n", $message, 2); return $body; } sub extract_status_code { my ($message) = shift || return undef; if ($message !~ /^(.+)\s+(\d+)/) { return undef; } return $2; } sub get_302_location { my ($message) = shift || return undef; if ($message =~ /.*Location:\s*(.+)\n/i) { return $1; } # uhm? where did it go? return undef; } sub retreive_http_playlist { my ($location) = shift || return undef; my ($response); my ($status); while (1) { $response = slurp_http($location); return undef unless defined $response; $status = extract_status_code($response); if (! defined $status) { # problems parsing return undef; } if ($status == 200) { # 200 OK return get_http_body($response); } if ($status == 302) { # location moved $location = get_302_location($response); debug("new location $location\n"); next; } # 404, 5XX and anything else return undef; } } sub retreive_playlist { my ($location) = shift || return undef; if ($location =~ /^(\w+):\/\/(.+)$/) { my $protocol = $1; my $url = $2; if ($protocol eq "file") { # local file requested return slurp_file($url); } if ($protocol eq "http") { # remote http file return retreive_http_playlist($url); } # unknown protocol return undef; } # no protocol specified, assuming local file return slurp_file($location); } sub slurp_headers { my ($sock) = shift || return undef; my ($max_length) = shift || -1; my ($data); my ($headers) = ''; return "" if ($max_length == 0); $data = recv_chunk($sock, 1); while (defined $data) { $headers .= $data; last if $headers =~ /\r\n\r\n/; if ($max_length != -1 && length($headers) >= $max_length) { # just enough (we're reading one byte at a time) last; } $data = recv_chunk($sock, 1); } return $headers; } sub trim { my ($str) = shift || return undef; $str =~ s/^[\s\t]//g; $str =~ s/[\s\t]$//g; return $str; } sub parse_stream_headers { my ($headers) = shift || return undef; my (@lines) = split('\n', $headers); my ($server) = {}; foreach my $line (@lines) { my ($key, $value); if ($line =~ /^\s*([\w\-]+)\s*\:\s*(.+)\s*$/) { $key = $1; $value = $2; $key = trim($key); $value = trim($value); $server->{$key} = $value; } } return $server; } sub parse_meta { my ($meta) = shift || return undef; if ($meta =~ /StreamTitle='(.+){1}'/) { my $title = $1; $title =~ s/\';(.*)$//; return $title; } return undef; } sub sync_mp3_frame { my ($data) = shift || return undef; my ($expected_sync_count) = shift; if (! defined $expected_sync_count) { $expected_sync_count = $max_sync_count; } # break recursion debug("entered recursion with expected = $expected_sync_count, len=" . length($data)); return $data if ($expected_sync_count == 0); my $offset = 0; my $max_offset = length($data) - 3; while ($offset < $max_offset) { # look for sync data my $frame = unpack('N', substr($data, $offset, $offset + 4)); if (($frame & 0xfff00000) == 0xfff00000) { # padding bit my $padding = ($frame >> 9) & 1; # 0: mpeg1, 1:mpeg2, 2:mpeg2.5 my $mpg_ver = 0; # ISO/IEC 11172-3 my $ver_idx = ($frame >> 19) & 3; $mpg_ver = 1 if ($ver_idx == 2); # ISO/IEC 13818-3 $mpg_ver = 2 if ($ver_idx == 0); # unofficial goto next_sync if $ver_idx == 1; # reserved # find mpeg layer (0 for Layer I) my $layer = 3 - (($frame >> 17) & 3); goto next_sync if $layer == 3; # reserved my $sample_rate = $freq_table[($frame >> 10) & 3][$mpg_ver]; my $br_idx = 0; if ($mpg_ver == 0) { # easy. MPEG1 $br_idx = $layer; } else { # MPEG2 and MPEG2.5 $br_idx = 3 if ($layer == 0); $br_idx = 4 if ($layer > 0); } my $bitrate = 1000 * $bitrate_table[($frame >> 12) & 0xf][$br_idx]; my $frame_size = int(144 * $bitrate / ($sample_rate)) + $padding; debug("frame_size $frame_size"); # recursively find more sync bits if (($offset + $frame_size) > $max_offset) { # impossible for another frame to be found return undef; } my $subdata = substr($data, $offset + $frame_size); my $rec = sync_mp3_frame($subdata, $expected_sync_count - 1); if (defined $rec) { # recursion ended! return $subdata; } } next_sync: if ($expected_sync_count < $max_sync_count) { # we are not allowed to continue loop inside recursion last; } $offset++; } return undef; } sub recv_metablock { my ($sock) = shift || return undef; my ($block_size); my ($data); $block_size = recv_chunk($sock, 1); $block_size = ord($block_size) * 16; return "" if ($block_size == 0); $data = recv_chunk($sock, $block_size); return $data; } sub fix_filename { my ($fn) = shift || return undef; # remove all characters that cause problems # on unices and on windows $fn =~ s/[\\\/\?\*\:\t\n\r]//g; return $fn; } sub open_output { my ($context) = shift || return 0; my ($fn) = shift || return 0; $fn = fix_filename($fn); open(OUTPUT, ">$fn") || die "FIXME: "; OUTPUT->autoflush(1); binmode OUTPUT; $context->{output_open} = 1; return 1; } sub write_block { my ($chunk) = shift || return; my ($context) = shift || return; if ($config->{stdout} == 1) { print $chunk; } # allow set name support if (defined($config->{name})) { $context->{title} = $config->{name}; $context->{id} = 0; # it doesn't mean anything in this context anyway } if ($context->{output_open} == 0 && $context->{title} ne '') { my $trackid = ''; if ($context->{id} != 0) { $trackid = sprintf "%02d - ", $context->{id}; } my $fn = $trackid . $context->{title}; $fn .= defined $context->{'is-ogg'} ? ".ogg" : ".mp3"; return unless open_output($context, $fn); } if ($context->{output_open} == 1) { print OUTPUT $chunk; } } sub print_title { my ($context) = shift; if ($config->{quiet} == 1) { # quiet! return; } if (defined $context) { if ($context->{length} > 0) { my $trackid = ''; if ($context->{id} != 0) { $trackid = sprintf "%02d - ", $context->{id}; } my ($kb) = int(($context->{length} + 1023) / 1024); print "\r${trackid}$context->{title} [$kb K]"; } } else { print "\n"; } } sub close_output_stream { my $context = shift || return; # close old output stream $context->{output_open} = 0; close OUTPUT; } sub set_title { my ($context) = shift || return 0; my ($newtitle) = shift || return 0; if ($newtitle eq $context->{title}) { # still playing the same track return 0; } if ($context->{title} ne '') { # new track print_title(); $config->{'played-tracks'}++; } $context->{title} = $newtitle; # track has changed if ($config->{tracks} == 0) { # there is no need to switch output stream return 1; } # reset track information $context->{length} = 0; $context->{id} = $context->{id} + 1; close_output_stream($context); return 1; } sub loop_named_stream { my ($sock) = shift || return 0; my ($stream) = shift || return 0; my ($context) = {}; debug("loop_named_stream()"); my $synced = 0; my $huge = ""; $context->{id} = find_latest_index("."); $context->{title} = ''; $context->{length} = 0; $context->{output_open} = 0; $context->{'is-ogg'} = $stream->{'is-ogg'}; if ($config->{tracks} == 0) { # single audio track of whatever is received $context->{title} = $stream->{'name'}; } # load all data up to the first metaint if -t is set elsif ($config->{traks}) { my $metablock; my $title; while ($config->{stop} == 0) { my $chunk = recv_chunk($sock, $stream->{'metaint'}); if (length($chunk) < $stream->{'metaint'}) { print "got a problem here..\n"; return 0; } $huge .= $chunk; $metablock = recv_metablock($sock); $title = parse_meta($metablock); last if defined $title; if (length($huge) > $largest_unknown_buffer) { debug("too many bytes before title received"); if ($config->{quiet} == 0) { print "no title was received. giving up"; } return 0; } } set_title($context, $title); $context->{length} += length($huge); if ($config->{sync} != 0) { $huge = sync_mp3_frame($huge); if (defined $huge) { write_block($huge, $context); $synced = 1; } } else { write_block($huge, $context); } print_title($context); } $huge = ""; while (1) { check_stop_cond(); last if ((defined $config->{stop}) && ($config->{stop} != 0)); my $chunk = recv_chunk($sock, $stream->{'metaint'}); if (length($chunk) < $stream->{'metaint'}) { print "got a problem here..\n"; return 0; } # update statistics $config->{'bytes-downloaded'} += length($chunk); $context->{length} += length($chunk); if ($synced) { write_block($chunk, $context); } else { $huge .= $chunk; my $sync_frame = sync_mp3_frame($huge); if (defined $sync_frame) { write_block($sync_frame, $context); $huge = ""; $synced = 1; } } print_title($context); my $metablock = recv_metablock($sock); # update current track if title found my $title = parse_meta($metablock); set_title($context, $title) if defined $title; } debug("loop_named_stream ended"); return 1; } sub loop_anonymous_stream { my ($sock) = shift || return 0; my ($stream) = shift || return 0; my ($context) = {}; debug("loop_anonymous_stream()"); $context->{id} = 0; $context->{title} = defined $stream->{name} ? $stream->{name} : 'stream-' .time; $context->{length} = 0; $context->{output_open} = 0; $context->{'is-ogg'} = $stream->{'is-ogg'}; while (1) { check_stop_cond(); last if ((defined $config->{stop}) && ($config->{stop} != 0)); my $chunk = recv_chunk($sock, 1024); last unless length($chunk) > 0; # update statistics $config->{'bytes-downloaded'} += length($chunk); $context->{length} += length($chunk); write_block($chunk, $context); print_title($context); } debug("loop_anonymous_stream ended"); return 1; } sub strip_protocol { my ($url) = shift || return undef; if ($url =~ /^\w+:\/\/(.+)$/) { return $1; } return $url; } sub split_protocol { my ($url) = shift || return undef; if ($url =~ /^(\w+):\/\//) { return $1; } return undef; } sub prepare_stream_data { my ($raw) = shift || return undef; my ($out) = (); # ICY protocol if (defined $raw->{'icy-name'}) { $out->{name} = $raw->{'icy-name'}; } if (defined $raw->{'icy-metaint'}) { $out->{metaint} = $raw->{'icy-metaint'}; } if (defined $raw->{'icy-genre'}) { $out->{genre} = $raw->{'icy-genre'}; } # Shoutcast protocol if (defined $raw->{'x-audiocast-genre'}) { $out->{genre} = $raw->{'x-audiocast-genre'}; } if (defined $raw->{'x-audiocast-name'}) { $out->{name} = $raw->{'x-audiocast-name'}; } return $out; } sub start_stream { my ($location) = shift || return 0; my ($host, $port, $path); my ($sock, $headers); my ($status); my ($stream_data); do { if (split_protocol($location) ne "http") { print STDERR "error: not an http location $location\n"; return 0; } $location = strip_protocol($location); # XXX: note: can clean this (too much code) # parse location ($host, $port, $path) = split_url($location); # parsing errors? if (! defined $host) { print STDERR "error parsing url $location\n"; return 0; } $port = 80 unless defined $port; $path = "/" unless defined $path; $sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, Proto => 'tcp'); if (! defined $sock) { print STDERR "error connecting to $host:$port\n"; return 0; } my $agent = $config->{'user-agent'}; my $request = "GET $path HTTP/1.0\r\n" . "Host: $host:$port\r\n" . "Accept: ${accept_header}\r\n" . "Icy-MetaData:1\r\n" . "User-Agent:$agent\r\n" . "\r\n"; debug("sending request to server", $request); print $sock $request; $headers = slurp_headers($sock); if (! defined $headers) { print STDERR "error retreiving response from server\n"; return 0; } debug("data retreived from server", $headers); $status = extract_status_code($headers); if (! defined $status) { print STDERR "error parsing server response (use --debug)\n"; return 0; } elsif ($status == 302) { # relocated $location = get_302_location($headers); } elsif ($status == 400) { # server full print STDERR "error: server is full (use --debug for complete response)\n"; return 0; } elsif ($status != 200) { # nothing works fine these days print STDERR "error: server error $status (use --debug for complete response)\n"; return 0; } } while ($status != 200); # manage icy and x-audiocast headers even if they are embedded in http # but skip header manipulation in other cases! if (($headers =~ /.*icy.*/) or ($headers =~ /.*audiocast.*/)) { my $raw_stream_data = parse_stream_headers($headers); if (! defined $raw_stream_data) { print STDERR "error: problems parsing stream headers (please use --debug)\n"; return 0; } $stream_data = prepare_stream_data($raw_stream_data); if (! defined $stream_data->{'name'}) { print STDERR "error: not an icecast/shoutcast stream\n"; return 0; } if ($config->{debug}) { my $info = "name: $stream_data->{name}\n"; $info .= "genre: $stream_data->{genre}\n" if defined $stream_data->{genre}; $info .= "metaint: $stream_data->{metaint}\n" if defined $stream_data->{metaint}; debug("parsed stream headers", $info); } if ($headers =~ /.*Content-Type: application\/ogg/i) { # streaming url is .ogg file, # remember this when saving output file $stream_data->{'is-ogg'} = 1; } } if (defined $stream_data->{'metaint'}) { # server periodically sends stream title loop_named_stream($sock, $stream_data); } else { # no titles for tracks loop_anonymous_stream($sock, $stream_data); } return 1; } sub banner() { print "$version\n"; } sub help() { banner(); print "usage: icecream [options] URL [URL...]\n"; print "\n"; print "options:\n"; print " -h, --help print this message\n"; print " -q, --quiet no printouts\n"; print " -v, --verbose be verbose\n"; print " -t, --tracks split into tracks when saving\n"; print " --name=NAME save stream to file NAME. Format codes\n"; print " are replaced as in the date command.\n"; print " --stop=N[units] stop download after N (kb, mb, min, songs)\n"; print " --user-agent=AGENT identify as AGENT stead of ${def_agent}\n"; print " --stdout output stream to stdout (implies quiet)\n"; print " --sync sync mpeg audio\n"; print " --debug turn on debugging\n"; exit 0; } sub parse_options { my (%options) = (); my ($config) = {}; GetOptions(\%options, "--help", "--quiet", "--verbose", "--stdout", "--tracks", "--debug", "--user-agent=s", "--name=s", "--stop=s", "--sync"); $config->{help} = (defined $options{help}) ? 1 : 0; $config->{quiet} = (defined $options{quiet}) ? 1 : 0; $config->{verbose} = (defined $options{verbose}) ? 1 : 0; $config->{debug} = (defined $options{debug}) ? 1 : 0; $config->{stdout} = (defined $options{stdout}) ? 1 : 0; $config->{tracks} = (defined $options{tracks}) ? 1 : 0; $config->{sync} = (defined $options{sync}) ? 1 : 0; $config->{name} = (defined $options{name}) ? $options{name} : undef; $config->{'user-agent'} = (defined $options{'user-agent'}) ? $options{'user-agent'} : ${def_agent}; $config->{'stop-cond'} = (defined $options{stop}) ? lc $options{stop} : undef; # stdout implies quiet if ($config->{stdout} == 1) { # stdout implies quiet $config->{quiet} = 1; $config->{debug} = 0; } # Do Date replacement on name field if (($config->{name}) && ($config->{name} =~ /%/)) { require POSIX; POSIX->import(); $config->{name} = strftime($config->{name},localtime(time)); } # validate stop condition if (defined $config->{'stop-cond'}) { my $cond_valid = 0; if ($config->{'stop-cond'} =~ /^(\d+)(\w+)$/) { my $cond = $2; if ($cond eq 'min' || $cond eq 'songs' || $cond eq 'kb' || $cond eq 'mb') { $cond_valid = 1; } } if ($cond_valid == 0) { print STDERR "error parsing stop condition $config->{'stop-cond'}\n"; return undef; } } $config->{urls} = join("\n", @ARGV); return $config; } sub verbose { my $s = shift || return; if ($config->{verbose} == 1) { print STDERR "$s"; } } sub debug { my $title = shift || return; my $additional = shift; if ($config->{debug}) { print "[ $title ]\n"; if (defined $additional) { my @ar = split("\n", $additional); foreach my $s (@ar) { print "\t$s\n"; } } } } sub process { my ($url) = shift || return undef; my ($config) = shift || return undef; # play direct stream url (not .pls nor .m3u) if (($url =~ /^http/) and (not (($url =~ /\.m3u$/) or ($url =~ /\.pls$/)))) { start_stream($url); return 1; } my $raw = retreive_playlist($url); if (! defined $raw) { print STDERR "error: failed to retreive playlist from $url\n"; return undef; } my @pls = (); if ($url =~ /\.m3u$/) { @pls = parse_m3u_playlist($raw); } elsif ($url =~ /\.pls$/) { @pls = parse_pls_playlist($raw); } debug("play list parsed"); $config->{'stop'} = 0; $config->{'played-tracks'} = 0; $config->{'bytes-downloaded'} = 0; $config->{'start-time'} = time(); my $entry = (); foreach $entry (@pls) { next unless defined $entry; if ($config->{verbose}) { print "[ playing $entry->{'file'} ]\n"; } start_stream($entry->{file}); last if ($config->{stop} != 0); } return 1; } sub main { my (@queue, $url); my ($played) = 0; $config = parse_options(); if (! defined $config) { # there was an error parsing parameters help(); } help() if ($config->{help} == 1); @queue = split("\n", $config->{urls}); help() unless @queue > 0; foreach $url (@queue) { process($url, $config); $played++; } print "\n"; if ($played == 0) { print STDERR "nothing was played"; } } sub find_latest_index { my ($location) = shift || return 0; my ($id) = 0; my ($fn); opendir(DIR, $location) || return $id; while ($fn = readdir(DIR)) { if ($fn =~ /^(\d+)\s+.*\.mp3$/) { $id = $1 if ($id < $1); } } closedir(DIR); return $id; } # great C habit binmode STDOUT; $| = 1; main(); __END__ =head1 NAME icecream - download icecast and shoutcast streams, redirecting all fetched content to stdout and/or to disk at the same time =head1 SYNOPSIS icecream [OPTIONS] URL [URL..] =head1 DESCRIPTION icecream is a lightweight, non-interactive, stream download utility. It connects to icecast and shoutcast servers or direct stream URLs, and redirects all fetched content to stdout and/or to media files on your disk. Listen to the stream piping the output to a stdin-capable media player. Save the stream to a named file or split it into different tracks. It is possible to redirect the stream and save it to disk at the same time. icecream is able to parse pls and m3u playlists, and to download mp3 and ogg direct stream URLs. If the stream is anonymous it will be saved as 'stream-time.mp3', where time is actual timestamp. =head1 OPTIONS =over 8 =item B<-h>, B<--help> Print a help message describing all options =item B<-q>, B<--quiet> Turn off output =item B<-v>, B<--verbose> Be verbose =item B<-t>, B<--tracks> Split stream into tracks (if possible) =item B<--name=NAME> Save the stream to file specified by NAME. Format codes starting with "%" will be replaced. See the date command for valid format codes. =item B<--stop=N[units]> Stop downloading the stream after N kb/mb/min/songs =item B<--user-agent=AGENT> Set user-agent header to AGENT =item B<--stdout> Output stream to stdout (implies -q) =item B<--sync> Turn syncing on, required for some mpeg players that read from stdin =item B<--debug> Turn on debugging outputs =back =head1 EXAMPLES =over 8 =item Streaming to mpg123 icecream --stdout http://radio.com/playlist.pls | mpg123 - =item Split stream into different tracks icecream -t http://metal.org/radio.pls =item Split stream into tracks and play with vlc at the same time icecream -t --stdout http://streaming.com/playlist.pls | vlc file:/dev/stdin =item Prepare a 74 minute CD icecream -t --stop 74min http://trace.net/playlist.m3u =item Use a filename with today's date as output icecream -q --name 'radio_%Y_%m_%d' --stop 60min http://radio.com/playlist.pls =back =head1 BUGS You are welcome to send bug reports about icecream to our mailing list. Feel free to visit http://icecream.sourceforge.net =head1 AUTHOR Written by Gil Megidish =cut icecream-1.3/icecream.10000644000175000017500000001507211005404502014241 0ustar cgrecocgreco.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 .\" .\" Standard preamble: .\" ======================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ICECREAM 1" .TH ICECREAM 1 "2008-04-28" "1.3" "icecream" .SH "NAME" icecream \- download icecast and shoutcast streams, redirecting all fetched content to stdout and/or to disk at the same time .SH "SYNOPSIS" .IX Header "SYNOPSIS" icecream [\s-1OPTIONS\s0] \s-1URL\s0 [\s-1URL\s0..] .SH "DESCRIPTION" .IX Header "DESCRIPTION" icecream is a lightweight, non\-interactive, stream download utility. It connects to icecast and shoutcast servers or direct stream URLs, and redirects all fetched content to stdout and/or to media files on your disk. .PP Listen to the stream piping the output to a stdin-capable media player. Save the stream to a named file or split it into different tracks. It is possible to redirect the stream and save it to disk at the same time. .PP icecream is able to parse pls and m3u playlists, and to download mp3 and ogg direct stream URLs. If the stream is anonymous it will be saved as \&'stream\-time.mp3', where time is actual timestamp. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-h\fR, \fB\-\-help\fR" 8 .IX Item "-h, --help" Print a help message describing all options .IP "\fB\-q\fR, \fB\-\-quiet\fR" 8 .IX Item "-q, --quiet" Turn off output .IP "\fB\-v\fR, \fB\-\-verbose\fR" 8 .IX Item "-v, --verbose" Be verbose .IP "\fB\-t\fR, \fB\-\-tracks\fR" 8 .IX Item "-t, --tracks" Split stream into tracks (if possible) .IP "\fB\-\-name=NAME\fR" 8 .IX Item "--name=NAME" Save the stream to file specified by \s-1NAME\s0. Format codes starting with \*(L"%\*(R" will be replaced. See the date command for valid format codes. .IP "\fB\-\-stop=N[units]\fR" 8 .IX Item "--stop=N[units]" Stop downloading the stream after N kb/mb/min/songs .IP "\fB\-\-user\-agent=AGENT\fR" 8 .IX Item "--user-agent=AGENT" Set user-agent header to \s-1AGENT\s0 .IP "\fB\-\-stdout\fR" 8 .IX Item "--stdout" Output stream to stdout (implies \-q) .IP "\fB\-\-sync\fR" 8 .IX Item "--sync" Turn syncing on, required for some mpeg players that read from stdin .IP "\fB\-\-debug\fR" 8 .IX Item "--debug" Turn on debugging outputs .SH "EXAMPLES" .IX Header "EXAMPLES" .IP "Streaming to mpg123" 8 .IX Item "Streaming to mpg123" icecream \-\-stdout http://radio.com/playlist.pls | mpg123 \- .IP "Split stream into different tracks" 8 .IX Item "Split stream into different tracks" icecream \-t http://metal.org/radio.pls .IP "Split stream into tracks and play with vlc at the same time" 8 .IX Item "Split stream into tracks and play with vlc at the same time" icecream \-t \-\-stdout http://streaming.com/playlist.pls | vlc file:/dev/stdin .IP "Prepare a 74 minute \s-1CD\s0" 8 .IX Item "Prepare a 74 minute CD" icecream \-t \-\-stop 74min http://trace.net/playlist.m3u .IP "Use a filename with today's date as output" 8 .IX Item "Use a filename with today's date as output" icecream \-q \-\-name 'radio_%Y_%m_%d' \-\-stop 60min http://radio.com/playlist.pls .SH "BUGS" .IX Header "BUGS" You are welcome to send bug reports about icecream to our mailing list. Feel free to visit http://icecream.sourceforge.net .SH "AUTHOR" .IX Header "AUTHOR" Written by Gil Megidish icecream-1.3/COPYING0000600000175000017500000004310311005404501013425 0ustar cgrecocgreco GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License.