Changeset d1a3d62 for debian/lib/gutenbach
- Timestamp:
- Jun 24, 2010, 1:49:52 AM (14 years ago)
- Branches:
- nodebathena
- Children:
- 5a05bf2
- Parents:
- 56954d4
- git-author:
- Kyle C. Brogle <broglek@…> (06/10/10 15:12:26)
- git-committer:
- Jessica B. Hamrick <jhamrick@…> (06/24/10 01:49:52)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
debian/lib/gutenbach
r0237078 rd1a3d62 94 94 printf(STDERR "Got \%arguments: %s\n", Dumper(\%arguments)); 95 95 96 # Open up a zwrite command to announce the current track. 97 my @zwrite_command = (qw(/usr/bin/zwrite -d -n -c), $zephyr_class, "-i", $queue.'@'.$host, "-s", "Gutenbach Music Spooler"); 98 99 print STDERR "Invoking @zwrite_command\n"; 100 open(ZEPHYR, "|-", @zwrite_command) or die "Couldn't launch zwrite: $!"; 96 101 97 102 98 my $status; 103 99 if (exists($arguments{"options"}{"job-originating-host-name"})) { 104 print(ZEPHYR $arguments{"user"},"\@",$arguments{"options"}{"job-originating-host-name"}," is playing:\n");100 105 101 $status = "User: ".$arguments{"user"}."\@".$arguments{"options"}{"job-originating-host-name"}; 106 102 } else { 107 print(ZEPHYR $arguments{"user"}," is playing:\n");103 108 104 $status = "User: ".$arguments{"user"}; 109 105 } … … 112 108 sub clear_status { 113 109 kill 15, $pid if $pid; 114 my @zwrite_command = (qw(/usr/bin/zwrite -d -n -c), $zephyr_class, "-i", $queue.'@'.$host, "-s", "Gutenbach Music Spooler");115 open(ZEPH, "|-", @zwrite_command);116 print(ZEPH "Playback aborted.\n");117 close(ZEPH);118 110 die; 119 111 } … … 131 123 if ($magic) { 132 124 # $magic means that Image::ExifTool was able to identify the type of file 133 printf(ZEPHYR "%s file %s\n", $magic, $arguments{"job-title"});134 125 $status .= sprintf(" Filetype: %s.", $magic); 135 126 $status .= sprintf(" Filename: %s.", $arguments{"job-title"}); 136 127 137 128 if (exists $fileinfo->{'Title'}) { 138 printf(ZEPHYR "\@b{%s}\n", $fileinfo->{'Title'}) if exists $fileinfo->{'Title'};129 139 130 $status .= sprintf(" Title: %s.", $fileinfo->{'Title'}); 140 131 } 141 132 foreach my $key (qw/Artist Album AlbumArtist/) { 142 133 if (exists $fileinfo->{$key}) { 143 printf(ZEPHYR "%s\n", $fileinfo->{$key}) if exists $fileinfo->{$key};134 144 135 $status .= sprintf(" %s: %s\n", $key, $fileinfo->{$key}); 145 136 } … … 167 158 # Read the title (currently not doing so because youtube-dl doesn't know how to get the title. 168 159 my $title = ""; # <YTDL> 169 # Print the title to zephyr andthe status string.170 print ZEPHYR "YouTube video $filepath\n$title";160 # Print the title to the status string. 161 171 162 $status .= " YouTube video $filepath. $title."; 172 163 # youtube-dl prints the URL of the flash video, which we pass to mplayer as a filename. … … 175 166 } else { # Doesn't appear to be a YouTube URL. 176 167 print STDERR "Resolved external reference to $filepath\n"; 177 printf(ZEPHYR "%s\n", $filepath);168 178 169 $status .= sprintf(" External: %s\n", $filepath); 179 170 } … … 181 172 elsif (-T $filepath) { # If the file appears to be a text file, treat it as a playlist. 182 173 split_playlist($filepath, \%arguments); 183 close(ZEPHYR);174 184 175 # See http://www.cups.org/documentation.php/api-filter.html#MESSAGES 185 176 print CUPS "NOTICE: $status\n"; … … 187 178 } 188 179 189 close(ZEPHYR); 180 190 181 print CUPS "NOTICE: $status\n"; 191 182 play_mplayer_audio($filepath, \%arguments); … … 223 214 elsif ($contenttype eq "audio/x-scpls") { $format="SHOUTCAST" } 224 215 else { 225 print ZEPHYR 226 "Unknown Content-Type $contenttype for URI $uri\n"; 216 227 217 } 228 218 } else { # Unable to match the URL regex 229 print ZEPHYR "Couldn't read URI for external reference\n";219 230 220 # Return the existing path, in the hopes that mplayer knows what to do with it. 231 221 return $filepath; … … 233 223 234 224 if ($format eq "SHOUTCAST") { 235 print ZEPHYR "Shoutcast playlist...\n";225 236 226 return get_shoutcast($uri); 237 227 } elsif ($format eq "MP3") { 238 228 } elsif ($format eq "OGG") { 239 229 } else { 240 print ZEPHYR "Unrecognized stream format: $format\n";230 241 231 } 242 232 return $uri; … … 259 249 } 260 250 } 261 printf(ZEPHYR "Playlist containing %d valid entries, split into separate jobs.\n", $i);251 262 252 } 263 253 … … 282 272 my $server = int(rand scalar(@uris)); 283 273 # print the name of the stream if available 284 print ZEPHYR "$titles[$server]\n";274 285 275 return $uris[$server]; 286 276 } … … 289 279 my ($filepath, $opts) = @_; 290 280 291 # Open up a zwrite command to show the mplayer output292 my @zwrite_command = (qw(/usr/bin/zwrite -d -n -c), $zephyr_class, "-i", $queue.'@'.$host, "-s", "Gutenbach Music Spooler");293 294 print STDERR "Invoking (from play_mplayer_audio): @zwrite_command\n";295 281 296 282 # fork for mplayer 297 283 $pid = open(MP3STATUS, "-|"); 298 284 unless (defined $pid) { 299 open(ZEPHYR, "|-", @zwrite_command) or die "Couldn't launch zwrite: $!";300 print ZEPHYR "Couldn't fork: $!\n";301 close(ZEPHYR);302 285 return; 303 286 } … … 306 289 # Check if there were any errors 307 290 if ($_ = <MP3STATUS>) { 308 open(ZEPHYR, "|-", @zwrite_command) or die "Couldn't launch zwrite: $!"; 309 print ZEPHYR "Playback completed with the following errors:\n"; 291 310 292 while (<MP3STATUS>) { 311 print ZEPHYR $_;293 312 294 } 313 close(ZEPHYR);295 314 296 } else { 315 open(ZEPHYR, "|-", @zwrite_command) or die "Couldn't launch zwrite: $!"; 316 print ZEPHYR "Playback completed successfully.\n"; 317 close(ZEPHYR); 318 } 319 close(MP3STATUS) || print ZEPHYR "mplayer exited $?\n"; 297 298 } 299 close(MP3STATUS); 320 300 } 321 301 else { # child
Note: See TracChangeset
for help on using the changeset viewer.