From 70ccd4a7b550782fce2fd5ac7084d69a45a7720e Mon Sep 17 00:00:00 2001 From: maniacikarus Date: Sun, 2 Sep 2007 13:16:38 +0000 Subject: [PATCH] MPFire Version 2 begonnen git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@872 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8 --- config/mpfire/mpd.conf | 218 +++++++++++++++++ config/mpfire/mpfire.pl | 181 ++++---------- config/mpfire/webradio | 14 +- config/rootfiles/packages/mpfire | 14 +- doc/language_issues.de | 2 + doc/language_issues.en | 2 + html/cgi-bin/mpfire.cgi | 281 +++++++++++----------- html/html/images/media-playback-pause.png | Bin 464 -> 0 bytes html/html/images/media-skip-backward.png | Bin 0 -> 576 bytes langs/de/cgi-bin/de.pl | 4 +- langs/en/cgi-bin/en.pl | 4 +- lfs/mpfire | 13 +- 12 files changed, 426 insertions(+), 307 deletions(-) create mode 100644 config/mpfire/mpd.conf delete mode 100644 html/html/images/media-playback-pause.png create mode 100644 html/html/images/media-skip-backward.png diff --git a/config/mpfire/mpd.conf b/config/mpfire/mpd.conf new file mode 100644 index 0000000000..c3153a3291 --- /dev/null +++ b/config/mpfire/mpd.conf @@ -0,0 +1,218 @@ +# MPD CONFIG FILE +# For a full description of all config parameters, +# Check the mpd man page, "man mpd". + +##################### REQUIRED ########################### +port "6600" +music_directory "/" +playlist_directory "/var/ipfire/mpfire" +log_file "/var/log/mpd.log" +error_file "/var/log/mpd.error.log" +pid_file "/var/run/mpd.pid" +########################################################## + +########################################################## +# EVERYTHING ELSE IS OPTIONAL +########################################################## + +#################### OPTIONAL FILES ###################### +# +# Location of DB file +# +db_file "/var/ipfire/mpfire/db/mpd.db" +# +# The state file (if set) will be a file +# for storing all current information +# (playlist, playing/paused, etc...) from +# the last MPD session. This will be used +# to recreate your last MPD session after +# restart. +# +state_file "/var/ipfire/mpfire/mpd_state" +# +########################################################## + + +################### VOLUME MIXER ######################### +# +# Examples: +# ALSA Mixer +mixer_type "alsa" +mixer_device "default" +mixer_control "PCM" +# +# OSS Mixer +#mixer_type "oss" +#mixer_device "/dev/mixer" +#mixer_control "PCM" +# +# Software Mixer +#mixer_type "software" +# +########################################################## + + +################## AUDIO OUTPUT ########################## +# +audio_output { + type "alsa" + name "alsa" + device "hw:0,0" # optional + format "44100:16:2" # optional +} +# +# An example of an OSS output: +# +audio_output { + type "oss" + name "My OSS Device" + device "/dev/dsp" # optional + format "44100:16:2" # optional +} +# +# An example of a shout output (for streaming to Icecast): +# +audio_output { + type "shout" + name "My Shout Stream" + host "localhost" + port "8000" + mount "/mpd.ogg" + password "hackme" +# quality "5.0" + bitrate "128" + format "44100:16:1" +# user "source" # optional +# description "My Stream Description" # optional +# genre "jazz" # optional +# public "no" # optional +} +# +# Set this if you have problems +# playing audio files. +# This will resample your music so +# that it comes out at the set rate. +# +#audio_output_format "44100:16:2" +# +# You should not need mess with +# this value unless you know +# what you're doing. +# +#audio_write_size "1024" +# +########################################################## + +################# REPLAYGAIN ############################# +# +# Use Replay Gain (album or title) +# http://www.replaygain.org +# +#replaygain "album" +# +# Sets the pre-amp used for files that have replaygain +# info. Valid values are between -15 to 15 (in dB). +# +#replaygain_preamp "0" +# +########################################################## + + +################ OUTPUT BUFFER SETTINGS ################## +# +# You should not need to mess with this +# unless you know what you're doing. +# +audio_buffer_size "2048" +# +# This means exactly what it says, it will +# buffer your file up to the percentage of +# the buffer before it begins playing. +# +buffer_before_play "25%" +# +########################################################## + + +################### HTTP PROXY ########################### +# +# http_proxy_host "proxy.isp.com" +# http_proxy_port "8080" +# http_proxy_user "user" +# http_proxy_password "password" +# +########################################################## + + +################# SECURITY SETTINGS ###################### +# +# It is encouraged to run MPD as +# non-superuser. If you start mpd as root +# (for example, in an init script), set +# this value, then mpd will drop root priveleges +# and runs as the user specified. +# +user "nobody" +# +# Set this value if you only have one +# address you want to allow connection to. +# +bind_to_address "localhost" +# +# If you want to setup MPD to use +# passwords set them here +# +#password "password1@read,add,control,admin" +#password "password2@read" +# +# Specify permissions used by default when no password is +# given by for a connection/client. +# +#default_permissions "read,add,control,admin" +# +########################################## + + +################ MISCELLANEOUS OPTIONS ################### +# +# This setting exists as precaution against attacks. +# +#max_playlist_length "16384" +# +# Valid options are "default", "secure" or "verbose". +#log_level "default" +# +connection_timeout "60" +# +# This should be fine for 2-3 people using clients +# at the same time. +# +#max_connections "5" +# +# No need to change these unless you know better. +# +#max_command_list_size "2048" +#max_output_buffer_size "2048" +# +# This will make playlists compatible with normal music +# players. +# +#save_absolute_paths_in_playlists "no" +# +########################################################## + +###################### CHARACTER ENCODINGS ##################### +# +# If file or directory names do not display correctly, then you +# may need to change this. In most cases it should be either +# "ISO-8859-1" or "UTF-8". You must recreate your database +# after changing this (use mpd --create-db). +# +filesystem_charset "UTF-8" +# +# The encoding that ID3v1 tags should be converted from. +# +id3v1_encoding "UTF-8" +metadata_to_use "artist,album,title,track,name,comment,date,genre" +# +################################################################ diff --git a/config/mpfire/mpfire.pl b/config/mpfire/mpfire.pl index ec7f292010..fae4cd09e2 100644 --- a/config/mpfire/mpfire.pl +++ b/config/mpfire/mpfire.pl @@ -1,80 +1,44 @@ #!/usr/bin/perl -############################################################################### -# # -# IPFire.org - A linux based firewall # -# Copyright (C) 2007 Michael Tremer & Christian Schmidt # -# # -# 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 3 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, see . # -# # -############################################################################### - -use MP3::Tag; -use MP3::Info; require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; my $filename = ""; -my %songs = ""; -my $debug = 0; -my $temp; - -if ($ARGV[0] eq 'scan') { -my $command = "find "; -chomp $ARGV[1]; -$command .= "\"$ARGV[1]\""; -if ($ARGV[2] eq 'off'){$command .= " -maxdepth 1";} -$command .= " -name *.mp3"; -my @files = `$command`; +my $debug = 0; -&getExistingSongs(); - -foreach (@files){ - $filename = $_; - chomp($filename) - &getSongInfo(); - } -open(DATEI, ">${General::swroot}/mpfire/db/songs.db") || die "Kann Datenbank nicht speichern"; -print DATEI %songs; -close(DATEI); +if ( ! -e /var/run/mpd.pid){ + system("mpd >/dev/null"); } -if ($ARGV[0] eq 'getdb') { - &getExistingSongs(); - print %songs; - } +if ($ARGV[0] eq 'scan') { + if ($debug){print "Creating Database\n";} + system("mpd --create-db >/dev/null"); +} elsif ($ARGV[0] eq 'play') { - &checkplaylist(); &checkmute(); + &clearplaylist(); if ($debug){print "Yes we are called and we will play $ARGV[1]\n";} - system("/usr/bin/mpg123 -b 1024 --aggressive -q \"$ARGV[1]\" 2>/dev/null >/dev/null &"); + system("mpc add \"$ARGV[1]\" >/dev/null && mpc play >/dev/null"); } -elsif ($ARGV[0] eq 'stop') { - my $PID = `ps -ef \| grep "wget -qO" \| head -1 \| grep -v "sh -c" \| awk '{ print \$2 }'`; - if ( $PID ne '' ){ - if ($debug){print "Stopping $PID\n";} - system("kill -KILL $PID"); - my $PID = `ps -ef \| grep "mpg123 -b 1024 --aggressive -Zq -" \| head -1 \| grep -v "sh -c" \| awk '{ print \$2 }'`; - if ($debug){print "Killing Process $PID\n";} - system("kill -KILL $PID"); +elsif ($ARGV[0] eq 'playadd') { + if ($debug){print "Yes we are called and we will add $ARGV[1]\n";} + system("mpc add \"$ARGV[1]\" >/dev/null && mpc play >/dev/null"); + } +elsif ($ARGV[0] eq 'playlist') { + &checkmute(); + &clearplaylist(); + if ($debug){print "Yes we are called and we will play your Playlist\n";} + system("mpc load playlist >/dev/null && mpc play >/dev/null"); } - else{ - my $PID = `ps -ef \| grep mpg123 \| grep playlist \| head -1 \| grep -v "sh -c" \| awk '{ print \$2 }'`; - if ($debug){print "Stopping $PID\n";} - system("kill -KILL $PID"); +elsif ($ARGV[0] eq 'clearplaylist') { + if ($debug){print "Deleting playlist\n";} + &clearplaylist(); } +elsif ($ARGV[0] eq 'stop') { + my $PID = 'cat /var/run/mpd.pid'; + if ($debug){print "Killing Process $PID\n";} + system("mpc stop >/dev/null"); } elsif ($ARGV[0] eq 'volup') { if ($debug){print "Increasing Volume\n";} @@ -87,59 +51,33 @@ elsif ($ARGV[0] eq 'voldown') { system("/usr/bin/amixer set PCM $ARGV[1]%- 2>/dev/null >/dev/null"); } elsif ($ARGV[0] eq 'playall') { - &checkplaylist(); - &checkmute(); if ($debug){print "Playing everything\n";} - system("/usr/bin/mpg123 -b 1024 --aggressive -Zq@ /var/ipfire/mpfire/playlist 2>/dev/null >/dev/null &"); + system("mpc play >/dev/null"); } -elsif ($ARGV[0] eq 'pause') { - my $PID = `ps -ef \| grep mpg123 \| grep playlist \| head -1 \| grep -v "sh -c" \| grep -v "grep" \| awk '{ print \$2 }'`; - if ($debug){print "Pausing Process $PID\n";} - system("kill -STOP $PID"); - } -elsif ($ARGV[0] eq 'resume') { - my $PID = `ps -ef \| grep mpg123 \| grep playlist \| head -1 \| grep -v "sh -c" \| grep -v "grep" \| awk '{ print \$2 }'`; - if ($debug){print "Resuming Process $PID\n";} - system("kill -CONT $PID"); +elsif ($ARGV[0] eq 'toggle') { + system("mpc toggle >/dev/null"); } elsif ($ARGV[0] eq 'next') { if ($debug){print "Next Song\n";} - my $PID = `ps -ef | grep mpg123 | grep playlist | head -1 | awk '{ print \$2 }'`; - system("kill -SIGINT $PID"); + system("mpc next >/dev/null["); + } +elsif ( $ARGV[0] eq 'prev' ) { + if ($debug){print "Previous Song\n";} + system("mpc prev >/dev/null"); } elsif ($ARGV[0] eq 'song') { - &checkmute(); - my $song = `lsof -nX \| grep mpg123 \| grep REG \| grep mem | grep mp3 \| grep -v "sh -c" \| grep -v "grep"`; - my @song = split(/\//,$song); - my $i = @song; - if ( $i == 0 ){ - my $song = `ps -ef \| grep "wget -qO" \| grep -v "sh -c" \| grep -v "grep"`; - my @song = split(/http\:\/\//,$song); - my $temp = $song[1]; - my @song = split(/ /,$temp); - print $song[0]; - } - else { print $song[$i-1];} + my $song = `mpc \| head -2 | grep -v volume`; + print $song; + } +elsif ($ARGV[0] eq 'stats') { + my $song = `mpc stats | grep Songs`; + print $song; } elsif ($ARGV[0] eq 'playweb') { - &General::readhash("${General::swroot}/proxy/settings", \%proxysettings); &checkmute(); - - if ($proxysettings{'UPSTREAM_PROXY'}) { - if ($proxysettings{'UPSTREAM_USER'}) { - &checkm3uproxy(); - if ($debug){print "Playing webstream\n";} - system("wget -qO - `wget -qO - http://$proxysettings{'UPSTREAM_USER'}:$proxysettings{'UPSTREAM_PASSWORD'}@$proxysettings{'UPSTREAM_PROXY'}$ARGV[1]` | mpg123 -b 1024 --aggressive -Zq - 2>/dev/null >/dev/null &"); - } - else { - &checkm3uproxyuser(); - if ($debug){print "Playing webstream\n";} - system("wget -qO - `wget -qO - http://$proxysettings{'UPSTREAM_PROXY'}$ARGV[1]` | mpg123 -b 1024 --aggressive -Zq - 2>/dev/null >/dev/null &");} - } else { - &checkm3u(); - if ($debug){print "Playing webstream\n";} - system("wget -qO - `wget -qO - http://$ARGV[1]` | mpg123 -b 1024 --aggressive -Zq - 2>/dev/null >/dev/null &"); - } + &clearplaylist(); + if ($debug){print "Playing webstream $ARGV[1] \n";} + system("mpc add http://$ARGV[1] >/dev/null && mpc play >/dev/null && sleep 1"); } elsif ($ARGV[0] eq 'volume') { $temp = "Master - "; @@ -149,26 +87,12 @@ elsif ($ARGV[0] eq 'volume') { print $temp; } -sub getSongInfo(){ - my $mp3 = MP3::Tag->new($filename); - my ($title, $track, $artist, $album, $comment, $year, $genre) = $mp3->autoinfo(); - my $info = get_mp3info($filename); - $mp3->close(); - $songs{$filename} = "|".$artist."|".$title."|".$track."|".$album."|".$year."|".$genre."|".$info->{MM}."|".$info->{SS}."|".$info->{BITRATE}."|".$info->{FREQUENCY}."|".$info->{MODE}."\n"; +sub clearplaylist(){ + system("mpc clear >/dev/null"); } -sub getExistingSongs(){ - open(DATEI, "<${General::swroot}/mpfire/db/songs.db") || die "Keine Datenbank vorhanden"; - my @Zeilen = ; - close(DATEI); - foreach (@Zeilen){ - my @Zeile = split(/\|/,$_); - $songs{$Zeile[0]} = "|".$Zeile[1]."|".$Zeile[2]."|".$Zeile[3]."|".$Zeile[4]."|".$Zeile[5]."|".$Zeile[6]."|".$Zeile[7]."|".$Zeile[8]."|".$Zeile[9]."|".$Zeile[10]."|".$Zeile[11]."\n"; - } - } - sub checkplaylist(){ - my $Datei = "/var/ipfire/mpfire/playlist"; + my $Datei = "/var/ipfire/mpfire/playlist.m3u"; my @Info = stat($Datei); if ( $Info[7] eq '' || $Info[7] eq '0' ){print "There is no playlist";exit(1);} } @@ -187,18 +111,3 @@ sub checkmute(){ system("amixer set Master toggle"); } } - -sub checkm3u(){ - my $Datei = system("wget -q --spider http://$ARGV[1]"); - if ( $Datei ne '0' ){print "We are unable to get the stream";exit(1);} -} - -sub checkm3uproxy(){ - my $Datei = system("wget -q --spider http://$ARGV[1]"); - if ( $Datei ne '0' ){print "We are unable to get the stream";exit(1);} -} - -sub checkm3uproxyuser(){ - my $Datei = system("wget -q --spider http://$ARGV[1]"); - if ( $Datei ne '0' ){print "We are unable to get the stream";exit(1);} -} diff --git a/config/mpfire/webradio b/config/mpfire/webradio index ea84da9438..ff91b1ca33 100644 --- a/config/mpfire/webradio +++ b/config/mpfire/webradio @@ -1,5 +1,9 @@ -www.89.0rtl.de/webradio/rtl-high.m3u|89.0 RTL Hitradio -metafiles.gl-systemhaus.de/wdr/channel_einslive.m3u|Einslive -www.deepinside.co.uk/ecoute-deepinside-wmp.m3u|Deepinside Radio European -www.bigfm.de/webradio/bigfm-high.m3u|BigFM -www.brocken.de/webradio/brocken-high.m3u|Hit-Radio Brocken +62.75.176.45/rtl-high|89.0 RTL Hitradio|http://www.89.0rtl.de +gffstream.ic.llnwd.net/stream/gffstream_stream_wdr_einslive_b|Einslive|http://www.einslive.de/ +213.186.41.149:8040|Deepinside Radio European|http://www.deepinside.co.uk +62.75.176.40:80/bigfm-cbr-128|BigFM|http://www.bigfm.de +62.75.176.44/brocken-high|Hit-Radio Brocken|http://www.radiobrocken.de +87.118.100.135:9191|Spaceworld Radio|http://spaceworld-radio.de/ +dsl.blackbeats.fm:13000|BlackBeats FM|http://www.blackbeats.fm +87.118.64.197:3100|Discofox-Radio|http://www.discofox-radio.de +rmnradio.powerstream.de:8022|RMNradio|http://www.rmnradio.de/ diff --git a/config/rootfiles/packages/mpfire b/config/rootfiles/packages/mpfire index 4f85b12a0f..44b12b976f 100644 --- a/config/rootfiles/packages/mpfire +++ b/config/rootfiles/packages/mpfire @@ -5,15 +5,7 @@ var/ipfire/mpfire var/ipfire/mpfire/bin var/ipfire/mpfire/bin/mpfire.pl var/ipfire/mpfire/db -var/ipfire/mpfire/db/songs.db -var/ipfire/mpfire/playlist +var/ipfire/mpfire/db/mpd.db +var/ipfire/mpfire/playlist.m3u var/ipfire/mpfire/settings -usr/lib/perl5/site_perl/5.8.8/MP3/Info.pm -usr/lib/perl5/site_perl/5.8.8/MP3/Tag.pm -usr/lib/perl5/site_perl/5.8.8/MP3/Tag/File.pm -usr/lib/perl5/site_perl/5.8.8/MP3/Tag/ID3v1.pm -usr/lib/perl5/site_perl/5.8.8/MP3/Tag/ID3v2.pm -usr/lib/perl5/site_perl/5.8.8/MP3/Tag/ParseData.pm -usr/lib/perl5/site_perl/5.8.8/MP3/Tag/LastResort.pm -usr/lib/perl5/site_perl/5.8.8/MP3/Tag/Inf.pm -usr/lib/perl5/site_perl/5.8.8/MP3/Tag/CDDB_File.pm +var/ipfire/mpfire/mpd.conf diff --git a/doc/language_issues.de b/doc/language_issues.de index 60bb3fe837..f45de44b1f 100644 --- a/doc/language_issues.de +++ b/doc/language_issues.de @@ -389,3 +389,5 @@ WARNING: translation string unused: week WARNING: translation string unused: weekly firewallhits WARNING: translation string unused: xtaccess bad transfert WARNING: translation string unused: yearly firewallhits +WARNING: untranslated string: pause +WARNING: untranslated string: resume diff --git a/doc/language_issues.en b/doc/language_issues.en index 466602c90e..baeb016792 100644 --- a/doc/language_issues.en +++ b/doc/language_issues.en @@ -423,3 +423,5 @@ WARNING: translation string unused: week WARNING: translation string unused: weekly firewallhits WARNING: translation string unused: xtaccess bad transfert WARNING: translation string unused: yearly firewallhits +WARNING: untranslated string: pause +WARNING: untranslated string: resume diff --git a/html/cgi-bin/mpfire.cgi b/html/cgi-bin/mpfire.cgi index 537f8cadf8..9415dc6488 100644 --- a/html/cgi-bin/mpfire.cgi +++ b/html/cgi-bin/mpfire.cgi @@ -1,28 +1,15 @@ #!/usr/bin/perl -############################################################################### -# # -# IPFire.org - A linux based firewall # -# Copyright (C) 2007 Michael Tremer & Christian Schmidt # -# # -# 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 3 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, see . # -# # -############################################################################### +# +# IPFire CGIs +# +# This code is distributed under the terms of the GPL +# +# (c) The IPFire Team use strict; # enable only the following on debugging purpose -#use warnings; -#use CGI::Carp 'fatalsToBrowser'; +use warnings; +use CGI::Carp 'fatalsToBrowser'; require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; @@ -35,11 +22,6 @@ my %checked = (); my $message = '0'; my $errormessage = ""; -open(DATEI, "<${General::swroot}/mpfire/db/songs.db") || die "No Database found"; -my @songdb = ; -close(DATEI); -@songdb = sort(@songdb); - &General::readhash("${General::swroot}/main/settings", \%mainsettings); &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); @@ -49,6 +31,44 @@ sub refreshpage{&Header::openbox( 'Waiting', 1, "; +close(DATEI); + +my @artist; my @album; my @genre; my @year; my $linecount = 0; my @currentsong = ""; my %songs; +foreach (@songdb){ + + if ( $_ =~ /mtime: / ){ + $songs{$currentsong[1]}="$currentsong[2]|$currentsong[3]|$currentsong[4]|$currentsong[5]|$currentsong[6]|$currentsong[7]|$currentsong[8]|$currentsong[9]"; + push(@artist,$currentsong[4]); + push(@album,$currentsong[6]); + push(@year,$currentsong[8]); + push(@genre,$currentsong[9]); + @currentsong = ""; + } + elsif ( $_ =~ /key: / || $_ =~ /file: / || $_ =~ /Time: / || $_ =~ /Artist: / || $_ =~ /Title: / || $_ =~ /Album: / || $_ =~ /Track: / || $_ =~ /Date: / || $_ =~ /Genre: / ){ + my @temp = split(/: /,$_); + push(@currentsong,$temp[1]); + } + else { + next; + } + } + + my %hash = map{ $_, 1 }@artist; + @artist = sort keys %hash; + my %hash = map{ $_, 1 }@album; + @album = sort keys %hash; + my %hash = map{ $_, 1 }@year; + @year = sort keys %hash; + my %hash = map{ $_, 1 }@genre; + @genre = sort keys %hash; + + my $artistcount = $#artist+1; + my $albumcount = $#album+1; + my $yearcount = $#year+1; + my $genrecount = $#genre+1; + &Header::getcgihash(\%mpfiresettings); &Header::openpage($Lang::tr{'mpfire'}, 1, ""); &Header::openbigbox('100%', 'left', '', $errormessage); @@ -60,110 +80,111 @@ if ( $mpfiresettings{'ACTION'} eq "scan" ) { delete $mpfiresettings{'__CGI__'};delete $mpfiresettings{'x'};delete $mpfiresettings{'y'};delete $mpfiresettings{'PAGE'}; &General::writehash("${General::swroot}/mpfire/settings", \%mpfiresettings); -$message=system("/usr/local/bin/mpfirectrl scan $mpfiresettings{'SCANDIR'} $mpfiresettings{'SCANDIRDEPS'}"); +open(DATEI, "<${General::swroot}/mpfire/mpd.conf") || die "Datei nicht gefunden"; +my @Zeilen = ; +close(DATEI); +open(DATEI, ">${General::swroot}/mpfire/mpd.conf") || die "Datei nicht gefunden"; +foreach (@Zeilen){ +if ( $_ =~ /music_directory/){print DATEI "music_directory \"".$mpfiresettings{'MUSICDIR'}."\"\n";} +else {print DATEI $_;} +} +close(DATEI); + +$message=system("/usr/local/bin/mpfirectrl scan"); refreshpage(); } elsif ( $mpfiresettings{'ACTION'} eq ">" ){$message=system("/usr/local/bin/mpfirectrl","play","\"$mpfiresettings{'FILE'}\"");} elsif ( $mpfiresettings{'ACTION'} eq "x" ){$message=system("/usr/local/bin/mpfirectrl stop");} -elsif ( $mpfiresettings{'ACTION'} eq "||" ){$message=system("/usr/local/bin/mpfirectrl pause");} -elsif ( $mpfiresettings{'ACTION'} eq "|>" ){$message=system("/usr/local/bin/mpfirectrl resume");} +elsif ( $mpfiresettings{'ACTION'} eq "|>" ){$message=system("/usr/local/bin/mpfirectrl toggle");} +elsif ( $mpfiresettings{'ACTION'} eq "<<" ){$message=system("/usr/local/bin/mpfirectrl prev");} elsif ( $mpfiresettings{'ACTION'} eq ">>" ){$message=system("/usr/local/bin/mpfirectrl next");} -elsif ( $mpfiresettings{'ACTION'} eq "playweb" ){$message=system("/usr/local/bin/mpfirectrl","playweb","\"$mpfiresettings{'FILE'}\"");} elsif ( $mpfiresettings{'ACTION'} eq "+" ){$message=system("/usr/local/bin/mpfirectrl volup 5");} elsif ( $mpfiresettings{'ACTION'} eq "-" ){$message=system("/usr/local/bin/mpfirectrl voldown 5");} elsif ( $mpfiresettings{'ACTION'} eq "++" ){$message=system("/usr/local/bin/mpfirectrl volup 10");} elsif ( $mpfiresettings{'ACTION'} eq "--" ){$message=system("/usr/local/bin/mpfirectrl voldown 10");} -elsif ( $mpfiresettings{'ACTION'} eq "playlist" ){$message=system("/usr/local/bin/mpfirectrl playall");} -elsif ( $mpfiresettings{'ACTION'} eq "emptyplaylist" ){$message=system("unlink ${General::swroot}/mpfire/playlist && touch ${General::swroot}/mpfire/playlist");} -elsif ( $mpfiresettings{'ACTION'} eq "addtoplaylist" ){ -open(DATEI, ">>${General::swroot}/mpfire/playlist") || die "Could not add playlist"; -print DATEI $mpfiresettings{'FILE'}."\n"; -close(DATEI); -} +elsif ( $mpfiresettings{'ACTION'} eq "playweb" ){$message=system("/usr/local/bin/mpfirectrl","playweb","\"$mpfiresettings{'FILE'}\"");} +elsif ( $mpfiresettings{'ACTION'} eq "playlist" ){$message=system("/usr/local/bin/mpfirectrl playlist");} +elsif ( $mpfiresettings{'ACTION'} eq "emptyplaylist" ){$message=system("/usr/local/bin/mpfirectrl clearplaylist");} +elsif ( $mpfiresettings{'ACTION'} eq "addtoplaylist" ){$message=system("/usr/local/bin/mpfirectrl","playadd","\"$mpfiresettings{'FILE'}\"");} +elsif ( $mpfiresettings{'ACTION'} eq "playall" ){$message=system("/usr/local/bin/mpfirectrl playall");} elsif ( $mpfiresettings{'ACTION'} eq "playalbum" ) { -my @temp = ""; -my @album = split(/\|/,$mpfiresettings{'album'}); -my %hash = map{ $_, 1 }@album; - -foreach (@songdb){ - my @song = split(/\|/,$_); - chomp($song[0]); - push(@temp,$song[0]."\n") if exists $hash{$song[4]}; +my @temp = ""; my @song = ""; my @select = split(/\|/,$mpfiresettings{'album'}); + +foreach (keys(%songs)){ + @song = split(/\|/,$songs{$_});$song[4] =~ s/\W/ /g; + + foreach (@select){ + $_ =~ s/\W/ /g; + if ( $song[4] =~ /$_/ ){push(@temp,$song[0]);} } -open(DATEI, ">${General::swroot}/mpfire/playlist") || die "Could not add playlist"; +} + +open(DATEI, ">${General::swroot}/mpfire/playlist.m3u") || die "Could not add playlist"; print DATEI @temp; close(DATEI); -$message=system("/usr/local/bin/mpfirectrl playall"); +$message=system("/usr/local/bin/mpfirectrl playlist"); } elsif ( $mpfiresettings{'ACTION'} eq "playartist" ) { -my @temp = ""; -my @artist = split(/\|/,$mpfiresettings{'artist'}); -my %hash = map{ $_, 1 }@artist; - -foreach (@songdb){ - my @song = split(/\|/,$_); - chomp($song[0]); - push(@temp,$song[0]."\n") if exists $hash{$song[1]}; +my @temp = ""; my @song = ""; my @select = split(/\|/,$mpfiresettings{'artist'}); + +foreach (keys(%songs)){ + @song = split(/\|/,$songs{$_});$song[2] =~ s/\W/ /g; + + foreach (@select){ + $_ =~ s/\W/ /g; + if ( $song[2] =~ /$_/ ){push(@temp,$song[0]);} } -open(DATEI, ">${General::swroot}/mpfire/playlist") || die "Could not add playlist"; +} + +open(DATEI, ">${General::swroot}/mpfire/playlist.m3u") || die "Could not add playlist"; print DATEI @temp; close(DATEI); -$message=system("/usr/local/bin/mpfirectrl playall"); +$message=system("/usr/local/bin/mpfirectrl playlist"); } elsif ( $mpfiresettings{'ACTION'} eq "playyear" ) { -my @temp = ""; -my @year = split(/\|/,$mpfiresettings{'year'}); -my %hash = map{ $_, 1 }@year; - -foreach (@songdb){ - my @song = split(/\|/,$_); - chomp($song[0]); - push(@temp,$song[0]."\n") if exists $hash{$song[5]}; +my @temp = ""; my @song = ""; my @select = split(/\|/,$mpfiresettings{'year'}); + +foreach (keys(%songs)){ + @song = split(/\|/,$songs{$_});$song[6] =~ s/\W/ /g; + + foreach (@select){ + $_ =~ s/\W/ /g; + if ( $song[6] =~ /$_/ ){push(@temp,$song[0]);} } -open(DATEI, ">${General::swroot}/mpfire/playlist") || die "Could not add playlist"; -print DATEI @temp; -close(DATEI); -$message=system("/usr/local/bin/mpfirectrl playall"); } -elsif ( $mpfiresettings{'ACTION'} eq "playgenre" ) -{ -my @temp = ""; -my @genre = split(/\|/,$mpfiresettings{'genre'}); -my %hash = map{ $_, 1 }@genre; -foreach (@songdb){ - my @song = split(/\|/,$_); - chomp($song[0]); - push(@temp,$song[0]."\n") if exists $hash{$song[6]}; - } -open(DATEI, ">${General::swroot}/mpfire/playlist") || die "Could not add playlist"; +open(DATEI, ">${General::swroot}/mpfire/playlist.m3u") || die "Could not add playlist"; print DATEI @temp; close(DATEI); -$message=system("/usr/local/bin/mpfirectrl playall"); +$message=system("/usr/local/bin/mpfirectrl playlist"); } -elsif ( $mpfiresettings{'ACTION'} eq "playall" ) +elsif ( $mpfiresettings{'ACTION'} eq "playgenre" ) { -my @temp = ""; -foreach (@songdb){ - my @song = split(/\|/,$_); - chomp($song[0]); - push(@temp,$song[0]."\n"); +my @temp = ""; my @song = ""; my @select = split(/\|/,$mpfiresettings{'genre'}); + +foreach (keys(%songs)){ + @song = split(/\|/,$songs{$_});$song[7] =~ s/\W/ /g; + + foreach (@select){ + $_ =~ s/\W/ /g; + if ( $song[7] =~ /$_/ ){push(@temp,$song[0]);} } -open(DATEI, ">${General::swroot}/mpfire/playlist") || die "Could not add playlist"; +} + +open(DATEI, ">${General::swroot}/mpfire/playlist.m3u") || die "Could not add playlist"; print DATEI @temp; close(DATEI); -$message=system("/usr/local/bin/mpfirectrl playall"); +$message=system("/usr/local/bin/mpfirectrl playlist"); } elsif ( $mpfiresettings{'SHOWLIST'} ){delete $mpfiresettings{'__CGI__'};delete $mpfiresettings{'x'};delete $mpfiresettings{'y'};delete $mpfiresettings{'PAGE'};&General::writehash("${General::swroot}/mpfire/settings", \%mpfiresettings);refreshpage();} ############################################################################################################################ ################################### Aufbau der HTML Seite fr globale Sambaeinstellungen #################################### -$mpfiresettings{'SCANDIR'} = "/"; -$mpfiresettings{'SHOWLIST'} = "off"; +$mpfiresettings{'MUSICDIR'} = "/"; &General::readhash("${General::swroot}/mpfire/settings", \%mpfiresettings); @@ -179,9 +200,7 @@ print < - - +
$Lang::tr{'Scan for Files'}
$Lang::tr{'Scan from Directory'}
$Lang::tr{'deep scan directories'}on / - off
$Lang::tr{'Scan from Directory'}
@@ -195,6 +214,8 @@ if ( $song eq "" ){$song = "None";} my $Volume = `/usr/local/bin/mpfirectrl volume`; $Volume=~s//
/g; +my $stats = `mpc stats | tail -4`; +$stats=~s/\\/
/g &Header::openbox('100%', 'center', $Lang::tr{'mpfire controls'}); print < -= $song =- END ; -if ( $#songdb eq '-1' ) {print "
total 0 songs

";} -else {print "
total $#songdb songs

";} +my $countsongs=`/usr/local/bin/mpfirectrl stats`; +print "
".$countsongs."

"; print <
-
-
+
+
@@ -224,30 +245,14 @@ print <
$Volume +
$stats END ; &Header::closebox(); -if ( $#songdb ne '0' ){ &Header::openbox('100%', 'center', $Lang::tr{'quick playlist'}); -my @artist; my @album; my @genre; my @year; -foreach (@songdb){ - my @song = split(/\|/,$_); - push(@artist,$song[1]); push(@album,$song[4]); push(@year,$song[5]); push(@genre,$song[6]);} - my %hash = map{ $_, 1 }@artist; - @artist = sort keys %hash; - my %hash = map{ $_, 1 }@album; - @album = sort keys %hash; - my %hash = map{ $_, 1 }@year; - @year = sort keys %hash; - my %hash = map{ $_, 1 }@genre; - @genre = sort keys %hash; - my $artistcount = $#artist+1; - my $albumcount = $#album+1; - my $yearcount = $#year+1; - my $genrecount = $#genre+1; print ""; if ( $#songdb eq '-1' ) {print "";} else {print "";} @@ -306,8 +311,6 @@ print < - - + END ; my $lines=0;my $i=0;my $begin;my $end; if ( $mpfiresettings{'PAGE'} eq 'all' ){ $begin=0; - $end=$#songdb; + $end=keys(%songs); } else{ $begin=(($mpfiresettings{'PAGE'}-1) * 100); $end=(($mpfiresettings{'PAGE'} * 100)-1); } -foreach (@songdb){ +foreach (keys(%songs)){ if (!($i >= $begin && $i <= $end)){ - #print $begin."->".$i."<-".$end."\n"; +# print $begin."->".$i."<-".$end."\n"; $i++;next;} - my @song = split(/\|/,$_); + my @song = split(/\|/,$songs{$_}); + my $minutes = sprintf ("%.0f", $song[1] / 60 ); + my $seconds = $song[1] % 60; if ($lines % 2) {print "";} else {print "";} - $song[0]=~s/\/\//\//g; print <
-
- - + + - + + END ; - if ( $song[11] eq "0\n" ) {print ""; } - elsif ( $song[11] eq "1\n" ) {print ""; } - elsif ( $song[11] eq "2\n" ) {print ""; } - elsif ( $song[11] eq "3\n" ) {print ""; } - else {print ""; } $lines++; $i++; } @@ -377,16 +375,7 @@ print "
$Lang::tr{'artist'}$Lang::tr{'album'}
$Lang::tr{'artist'} - ".$artistcount."$Lang::tr{'album'} - ".$albumcount."

$Lang::tr{'Pages'}

END ; -my $pages =(int($#songdb/100)+1); +my $pages =(int(keys(%songs)/100)+1); for(my $i = 1; $i <= $pages; $i++) { print ""; if (!($i % 205)){print"
";} @@ -332,42 +335,37 @@ print <$Lang::tr{'album'}
$Lang::tr{'year'} $Lang::tr{'genre'}$Lang::tr{'length'}
$Lang::tr{'bitrate'} - $Lang::tr{'frequency'}
$Lang::tr{'mode'}
$Lang::tr{'length'}
$song[1]
$song[2]
$song[3]$song[4]$song[2]
$song[3]
$song[5]$song[4] $song[6]$song[7]:$song[8]
$song[9] - $song[10]
$song[7]$minutes:$seconds
Stereo
Joint
Stereo
Dual
Channel
Single
Channel
"; &Header::openbox('100%', 'center', $Lang::tr{'mpfire playlist'}); -open(DATEI, "<${General::swroot}/mpfire/playlist") || die "Could not open playlist"; -my @playlist = ; -close(DATEI); - -my %hash; -foreach (@songdb){ - my @song = split(/\|/,$_); - chomp($song[0]); - $hash{$song[0]}=$song[1]." - ".$song[2]." - ".$song[7].":".$song[8]; -} +my @playlist = `mpc playlist`; print < @@ -394,7 +383,7 @@ print < @@ -429,7 +418,7 @@ END foreach (@webradio){ my @stream = split(/\|/,$_); print <$stream[1] + $stream[1]
END diff --git a/html/html/images/media-playback-pause.png b/html/html/images/media-playback-pause.png deleted file mode 100644 index c8b4fe2251f885e2362b7ef36b85d6c3a178f7c8..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc-jL100001 literal 464 zc-jHb0WbcEP)fkXfR0bNN% zK~y-)&5}!Q6hRDzzbd<#?kMWj*ortnatw&zNJwy`D9RZCg*!wL5UgjGNHA&oVHW+! z028qUFG{7aT)%!l;9p1DyPy6&J1w6g;v*0`zpdA6&YwMbzc2ds_4Qc{Lq320^k$!5 zzj=4I*=`dMd4^_&s>bET6_*!RsOsQmtPgN=Ura3y+#M02?|VLd`GAOE?sQ$Z@Y~Nf zBRBg~z|0U4c6Z+?v_MoabGo)gM7V2qh$y0hKP1q!JDR3JR1gu|*FYL}%{SWi2j!|- zoXv6H10NkUZ9^gMh7Gi5vrqV;>BD-9GXJBeDwkV$vM~cQN1dU zzy8jT>#CjwmhIYXH>X4*rDN*a%Jzqz;k7x5ETI&B|H7dZO>0000AxA%RKEf40C05xmK&%L(TwQ=^~;L zApQQqJzPHe>Eq{W_2!55_i;ZKLUJK*S8psnUx@p$6oQB>B;?!y0L~pk%I^Z^IzQan zY_`5^Vn9r5z0-qI%5_};P*KF-m+v?{3>5$XXaHb;na$u9W9(1-XZ-}~!mxZr5J?yS O0000 'Die Passwörter stimmen nicht überein.', 'passwords must be at least 6 characters in length' => 'Passwörter müssen mind. 6 Zeichen lang sein', 'path to directory' => 'Pfad zur Freigabe', -'pause' => 'Pause', 'pc' => 'PC', 'pc add' => 'PC hinzufügen', 'pdc options' => 'PDC Optionen', @@ -1270,6 +1269,7 @@ 'pre-shared key is too short' => 'Pre-shared Schlüsel ist zu kurz', 'prefered master' => 'Prefered Master', 'present' => 'Vorhanden', +'prev' => 'Vorheriger', 'primary dns' => 'Primärer DNS:', 'primary ntp server' => 'Primärer NTP-Server', 'primary wins server address' => 'Primäre WINS-Server Adresse', @@ -1347,7 +1347,6 @@ 'restore defaults' => 'Voreinstellungen wiederherstellen', 'restore hardware settings' => 'Hardware-Einstellungen wiederherstellen', 'restore settings' => 'Einstellungen wiederherstellen', -'resume' => 'Resume', 'reverse sort' => 'In umgekehrter chronologischer Reihenfolge sortieren', 'root' => 'Root', 'root certificate' => 'Root-Zertifikat', @@ -1540,6 +1539,7 @@ 'to email adr' => 'An Email Adresse', 'to install an update' => 'Um ein Update zu installieren, laden Sie zuerst die folgende .tgz.gpg Datei hoch:', 'to warn email bad' => 'An Email Adresse ist nicht gültig', +'toggle' => 'Pause/Resume', 'toggle enable disable' => 'Aktivieren oder Deaktivieren', 'tone' => 'Ton', 'tone dial' => 'Tonwahl:', diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index fd5d33930a..9a9b75dddf 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -1273,7 +1273,6 @@ 'passwords do not match' => 'Passwords do not match.', 'passwords must be at least 6 characters in length' => 'Passwords must be at least 6 characters in length', 'path to directory' => 'path to share', -'pause' => 'pause', 'pc' => 'Workstatipon', 'pc add' => 'add workstation', 'pdc options' => 'PDC Options', @@ -1298,6 +1297,7 @@ 'pre-shared key is too short' => 'Pre-shared key is too short.', 'prefered master' => 'Prefered Master', 'present' => 'Present', +'prev' => 'previous', 'primary dns' => 'Primary DNS:', 'primary ntp server' => 'Primary NTP Server', 'primary wins server address' => 'Primary WINS Server address', @@ -1376,7 +1376,6 @@ 'restore defaults' => 'Restore defaults', 'restore hardware settings' => 'Restore hardware settings', 'restore settings' => 'Reset Settings', -'resume' => 'resume', 'reverse sort' => 'Sort in reverse chronological order', 'root' => 'Root', 'root certificate' => 'Root Certificate', @@ -1572,6 +1571,7 @@ 'to email adr' => 'To Email address', 'to install an update' => 'To install an update please upload the .tgz.gpg file below:', 'to warn email bad' => 'To email address is not valid', +'toggle' => 'pause/resume', 'toggle enable disable' => 'Enable or Disable', 'tone' => 'Tone', 'tone dial' => 'Tone dial:', diff --git a/lfs/mpfire b/lfs/mpfire index f0371c294f..edd32b350d 100644 --- a/lfs/mpfire +++ b/lfs/mpfire @@ -30,9 +30,9 @@ THISAPP = mpfire-$(VER) DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = mpfire -PAK_VER = 1 +PAK_VER = 2 -DEPS = "mpg123 alsa" +DEPS = "mpd mpc alsa libshout libogg libmad libid3tag" ############################################################################### # Top-level Rules @@ -58,9 +58,12 @@ dist: $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) -mkdir -p /var/ipfire/mpfire/{bin,db} - touch /var/ipfire/mpfire/{settings,playlist} - touch /var/ipfire/mpfire/db/songs.db - chown nobody.nobody /var/ipfire/mpfire/{settings,playlist} + touch /var/ipfire/mpfire/{settings,playlist.m3u} + touch /var/ipfire/mpfire/db/mpd.db + touch /var/log/mpd_error.log + touch /var/log/mpd.log install -v -m 755 $(DIR_SRC)/config/mpfire/mpfire.pl /var/ipfire/mpfire/bin + install -v -m 644 $(DIR_SRC)/config/mpfire/mpd.conf /var/ipfire/mpfire/ install -v -m 644 $(DIR_SRC)/config/mpfire/webradio /var/ipfire/mpfire/ + chown nobody.nobody /var/ipfire/mpfire/{settings,playlist.m3u,webradio,mpd.conf} @$(POSTBUILD) -- 2.39.2