MPFire Version 2 begonnen

git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@872 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
This commit is contained in:
maniacikarus
2007-09-02 13:16:38 +00:00
parent 92cf793cf2
commit 70ccd4a7b5
12 changed files with 422 additions and 303 deletions

218
config/mpfire/mpd.conf Normal file
View File

@@ -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"
#
################################################################

View File

@@ -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 <http://www.gnu.org/licenses/>. #
# #
###############################################################################
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;
my $debug = 0;
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`;
&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 '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");
}
elsif ($ARGV[0] eq 'clearplaylist') {
if ($debug){print "Deleting playlist\n";}
&clearplaylist();
}
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");
}
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");
}
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];
my $song = `mpc \| head -2 | grep -v volume`;
print $song;
}
else { print $song[$i-1];}
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 = <DATEI>;
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);}
}

View File

@@ -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/