summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/.htaccess1
-rwxr-xr-xbin/archive/export_playlist.pl80
-rwxr-xr-xbin/archive/import_playlist.pl118
-rwxr-xr-xbin/archive/migrate_user.pl56
-rw-r--r--bin/catalog_update.php.inc18
-rw-r--r--bin/compare_config.php.inc55
-rwxr-xr-xbin/create_genre32
-rwxr-xr-xbin/filesort.pl29
-rwxr-xr-xbin/fileupdate.pl346
-rwxr-xr-xbin/genres.txt148
-rwxr-xr-xbin/init11
-rwxr-xr-xbin/moosic6
-rwxr-xr-xbin/moosicd6
-rw-r--r--bin/parse_m3u.php.inc47
-rwxr-xr-xbin/print_amazon.php.inc42
-rw-r--r--bin/print_tags.php.inc34
16 files changed, 1029 insertions, 0 deletions
diff --git a/bin/.htaccess b/bin/.htaccess
new file mode 100644
index 00000000..3a428827
--- /dev/null
+++ b/bin/.htaccess
@@ -0,0 +1 @@
+Deny from all
diff --git a/bin/archive/export_playlist.pl b/bin/archive/export_playlist.pl
new file mode 100755
index 00000000..c6e0ccaf
--- /dev/null
+++ b/bin/archive/export_playlist.pl
@@ -0,0 +1,80 @@
+#!/usr/bin/perl -w
+#
+# Exports playlists from ampache
+#
+# Fill in the site specific database connection parameters below before running
+#
+
+use DBI;
+
+# Configure database connection parameters
+my $db = "ampache"; # database
+my $user = ""; # database user
+my $pw = ""; # database user password
+
+
+if ($#ARGV < 0) {
+ print "Usage: $0 <filename>\n";
+ print " Exports Ampache playlists to <filename>.\n";
+ exit;
+}
+
+
+open(OUT, "> $ARGV[0]") or die("Could not open '$ARGV[0]' for write - $!");
+
+# Build DSNs
+my $dsn = "dbi:mysql:database=$db;";
+
+# Connect to database
+my $dbh= DBI->connect($dsn, $user, $pw,
+ { RaiseError => 1, AutoCommit => 0 });
+
+
+# Prepare statements
+my $sth = $dbh->prepare("SELECT id, name, owner, type FROM playlist");
+my $sth2 = $dbh->prepare("SELECT username FROM user
+ WHERE id = ?");
+my $sth3 = $dbh->prepare("SELECT song.file
+ FROM playlist_data, song
+ WHERE playlist_data.playlist = ?
+ AND playlist_data.song = song.id");
+
+# Execute select and loop through results
+$sth->execute();
+my $count = 0;
+my ($id,$name,$owner,$type,$date,$file,$track);
+while(($id,$name,$owner,$type) = $sth->fetchrow_array) {
+ if ($count > 0) {
+ # Use a blank line as a separator between playlists
+ print OUT "\n";
+ }
+
+ $count++;
+
+ if ($owner =~ /^\d+$/) {
+ # Fetch username instead of id for owner
+ $sth2->execute($owner);
+ $owner = "unknown" unless (($owner) = $sth2->fetchrow_array);
+ $sth2->finish;
+ }
+
+ # Date is not present in old ampache's
+ $date = 0 if (! defined($date));
+
+ print OUT "Name: $name\n";
+ print OUT "Owner: $owner\n";
+ print OUT "Type: $type\n";
+
+ # Grab songs for this playlist
+ $sth3->execute($id);
+ while(($file) = $sth3->fetchrow_array) {
+ print OUT "File: $file\n";
+ }
+}
+
+print "Exported $count playlists.\n";
+
+# Clean up
+$dbh->disconnect;
+close(OUT);
+
diff --git a/bin/archive/import_playlist.pl b/bin/archive/import_playlist.pl
new file mode 100755
index 00000000..4ce0e7b5
--- /dev/null
+++ b/bin/archive/import_playlist.pl
@@ -0,0 +1,118 @@
+#!/usr/bin/perl -w
+#
+# Imports playlists into ampache (from export_playlist.pl output)
+#
+# Fill in the site specific database connection parameters below before running
+#
+
+use DBI;
+use Data::Dumper;
+
+# Configure database connection parameters
+my $db = "ampache3_1"; # database
+my $user = ""; # database user
+my $pw = ""; # database user password
+
+
+if ($#ARGV < 0) {
+ print "Usage: $0 <filename>\n";
+ print " Imports Ampache playlists from <filename>.\n";
+ print " The format of <filename> should match the output of export_playlist.pl.\n";
+ exit;
+}
+
+
+open(IN, "$ARGV[0]") or die("Could not open '$ARGV[0]' for read - $!");
+
+# Build DSNs
+my $dsn = "dbi:mysql:database=$db;";
+
+# Connect to database
+my $dbh = DBI->connect($dsn, $user, $pw,
+ { RaiseError => 1, AutoCommit => 0 });
+
+
+# Structure to contain playlists
+my @playlists;
+
+# Parse file
+my $i = 0;
+while($line = <IN>) {
+ chomp $line;
+
+ if ($line eq "") {
+ # Blank line means new playlist
+ $i++;
+ next;
+ }
+
+ if ($line =~ /^ID: (.*)$/) {
+ $playlists[$i]->{id} = $1;
+ }
+
+ if ($line =~ /^Name: (.*)$/) {
+ $playlists[$i]->{name} = $1;
+ }
+
+ if ($line =~ /^Owner: (.*)$/) {
+ $playlists[$i]->{owner} = $1;
+ }
+
+ if ($line =~ /^Type: (.*)$/) {
+ $playlists[$i]->{type} = $1;
+ }
+
+ if ($line =~ /^File: (.*)$/) {
+ push @{$playlists[$i]->{files}}, $1;
+ }
+}
+close(IN);
+
+# Prepare statements
+my $sth = $dbh->prepare("SELECT id FROM user
+ WHERE username = ?");
+my $sth2 = $dbh->prepare("INSERT INTO playlist
+ (name, owner, type)
+ values (?, ?, ?)");
+my $sth3 = $dbh->prepare("SELECT id FROM song
+ WHERE file = ?");
+my $sth4 = $dbh->prepare("INSERT INTO playlist_data
+ (playlist, song, track)
+ values (?, ?, ?)");
+
+# Insert records into Ampache
+my ($id,$name,$owner,$type,$file,$songid);
+my $count = 0;
+for ($i = 0; $i < $#playlists + 1; $i++) {
+ $count++;
+
+ $name = $playlists[$i]->{name};
+
+ $sth->execute($playlists[$i]->{owner});
+ $owner = 0 unless (($owner) = $sth->fetchrow_array);
+ $sth->finish;
+
+ $type = $playlists[$i]->{type};
+
+ print "Importing playlist '$name'...\n";
+
+ # Create base playlist entry
+ $sth2->execute($name, $owner, $type);
+ $id = $dbh->{mysql_insertid};
+
+ # And add files to it
+ while($file = pop(@{$playlists[$i]->{files}})) {
+ $sth3->execute($file);
+ next unless (($songid) = $sth3->fetchrow_array);
+ $sth3->finish;
+
+ $sth4->execute($id,$songid,0);
+ }
+}
+
+print "Imported $count playlists.\n";
+
+# Clean up
+$dbh->disconnect;
+close(IN);
+
diff --git a/bin/archive/migrate_user.pl b/bin/archive/migrate_user.pl
new file mode 100755
index 00000000..cf36c868
--- /dev/null
+++ b/bin/archive/migrate_user.pl
@@ -0,0 +1,56 @@
+#!/usr/bin/perl -w
+#
+# Migrates users from Ampache v3.0 to Ampache v3.1.
+#
+# Fill in the site specific database connection parameters below before running
+#
+
+use DBI;
+
+# Configure database connection parameters
+my $db_old = "ampache"; # old database
+my $db_new = "ampache3_1"; # new database
+my $user_old = ""; # old database user
+my $user_new = ""; # new database user
+my $pw_old = "!"; # old database user password
+my $pw_new = "!"; # new database user password
+
+
+# Build DSNs
+my $dsn_new = "dbi:mysql:database=$db_new;";
+my $dsn_old = "dbi:mysql:database=$db_old;";
+
+
+# Connect to old and new databases
+my $dbh_new = DBI->connect($dsn_new, $user_new, $pw_new,
+ { RaiseError => 1, AutoCommit => 0 });
+
+my $dbh_old = DBI->connect($dsn_old, $user_old, $pw_old,
+ { RaiseError => 1, AutoCommit => 0 });
+
+
+# Prepare select and insert statements
+my $sth = $dbh_old->prepare("SELECT username, fullname, email, password, access
+ FROM user");
+
+my $sth_update = $dbh_new->prepare("INSERT INTO user
+ (username, fullname, email, password, access, offset_limit)
+ VALUES (?, ?, ?, ?, ?, 50)");
+
+
+# Execute select and loop through results
+$sth->execute();
+my ($f1,$f2,$f3,$f4,$f5);
+my $count = 0;
+while(($f1,$f2,$f3,$f4,$f5) = $sth->fetchrow_array) {
+ $sth_update->execute($f1,$f2,$f3,$f4,$f5);
+ $count++;
+}
+
+print "Migrated $count users.\n";
+
+
+# Clean up
+$dbh_old->disconnect;
+$dbh_new->disconnect;
+
diff --git a/bin/catalog_update.php.inc b/bin/catalog_update.php.inc
new file mode 100644
index 00000000..3f8e9a76
--- /dev/null
+++ b/bin/catalog_update.php.inc
@@ -0,0 +1,18 @@
+<?php
+
+$no_session='1';
+require ("../modules/init.php");
+
+$sql = "SELECT id FROM catalog WHERE catalog_type='local'";
+$db_results = mysql_query($sql, dbh());
+
+while ($r = mysql_fetch_row($db_results)) {
+ $catalog = new Catalog($r[0]);
+
+ // Verify Existing
+ $catalog->verify_catalog();
+
+ // Look for new files
+ $catalog->add_to_catalog();
+}
+?>
diff --git a/bin/compare_config.php.inc b/bin/compare_config.php.inc
new file mode 100644
index 00000000..af29b381
--- /dev/null
+++ b/bin/compare_config.php.inc
@@ -0,0 +1,55 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2005 Ampache.org
+ All rights reserved
+
+ 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+$no_session = '1';
+require ("../modules/init.php");
+require ("../lib/debug.php");
+
+$results = debug_read_config(conf('prefix') . "/config/ampache.cfg.php");
+
+$dist_results = debug_read_config(conf('prefix') . "/config/ampache.cfg.php.dist");
+
+echo "\nCHECKING CONF VARS... \n\n";
+
+foreach ($dist_results['conf'] as $key=>$value) {
+
+ if (!isset($results['conf'][$key])) {
+ echo "MISSING:";
+ echo " $key = $value\n";
+ }
+
+} // foreach dist
+
+echo "\nCHECKING LIBGLUE VARS...\n\n";
+
+foreach ($dist_results['libglue'] as $key=>$value) {
+
+ if (!isset($results['libglue'][$key])) {
+ echo "MISSING:";
+ echo " $key = $value\n";
+ }
+
+
+} // foreach libglue
+
+?>
+
diff --git a/bin/create_genre b/bin/create_genre
new file mode 100755
index 00000000..c9687e7b
--- /dev/null
+++ b/bin/create_genre
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+
+# Copyright (c) 2000 Kveton.com
+# All rights reserved.
+
+# $Id: create_genre,v 1.2 2003/11/24 05:53:12 vollmerk Exp $
+# $Source: /data/cvsroot/ampache/bin/create_genre,v $
+
+# Create the genres in the database for ease of use
+
+use DBI;
+
+# User, pass and database names
+my $user = '_user_';
+my $pass = '_password_';
+my $db_name = 'ampache';
+my $db_host = 'localhost';
+
+$dbh = DBI->connect("dbi:mysql:database=$db_name;host=$db_host;port=3306", $user, $pass);
+my $sql = qq{INSERT INTO genre (id,name) VALUES (?,?)};
+my $sth = $dbh->prepare($sql);
+
+open(GENRE, "< genres.txt");
+
+while ( $line = <GENRE> ) {
+ chomp $line;
+ my ($id, $name) = split(/\./, $line);
+ print "$id : $name\n";
+ $sth->execute($id,$name);
+}
+
+1;
diff --git a/bin/filesort.pl b/bin/filesort.pl
new file mode 100755
index 00000000..a3347ab6
--- /dev/null
+++ b/bin/filesort.pl
@@ -0,0 +1,29 @@
+#!/usr/bin/perl -w
+#
+# Sorts your MP3s into directories based on the sort pattern specified
+# in ampache
+
+use FindBind qw($Bin);
+require "$Bin/init";
+
+use Data::Dumper;
+use Getopt::Long;
+
+Getopt::Long::Configure('bundling','no_ignore_case');
+GetOptions
+ ("h|help" => \$usage,
+ "t|test" => \$pretend,
+ "a|all" => \$all,
+ "s|sort" => \$sort,
+ "c|clean" => \$clean,
+ "v|verbose" => \$verbose);
+
+if ($help) {
+ usage();
+}
+
+
+#
+# Pull in Data from Ampache
+#
+
diff --git a/bin/fileupdate.pl b/bin/fileupdate.pl
new file mode 100755
index 00000000..4353d057
--- /dev/null
+++ b/bin/fileupdate.pl
@@ -0,0 +1,346 @@
+#!/usr/bin/perl -w
+
+# Find and file away MP3's. Run multiple times and will
+# ignore addition of duplicates in db (based on MD5 hash
+# of full file path.
+
+use FindBin qw($Bin);
+require "$Bin/init";
+
+use Data::Dumper;
+use Getopt::Long;
+
+use vars qw($help $pretend $id3 $rename $sort $all $verbose);
+
+Getopt::Long::Configure('bundling','no_ignore_case');
+GetOptions
+ ("h|help" => \&usage,
+ "p|pretend" => \$pretend,
+ "i|id3" => \$id3,
+ "r|rename" => \$rename,
+ "s|sort" => \$sort,
+ "a|all" => \$all,
+ "rename_all" => \$rename_all,
+ "sort_all" => \$sort_all,
+ "v|verbose" => \$verbose);
+
+if ( !$help && !$all && !$id3 && !$rename && !$sort && !$rename_all && !$sort_all ) {
+ usage();
+}
+
+if ($help) {
+ usage();
+}
+
+if($id3 or $all)
+{
+ my @flagged = $ampache->get_table_where("flagged","WHERE type = 'setid3'");
+
+ foreach my $update(@flagged)
+ {
+ my @info = $ampache->get_song_info($update->{'song'});
+ my $cmd = update_id3_tag($ampache,@info);
+ if($rename or $all)
+ {
+ if($verbose){ print "Marking for rename after id3\n"; }
+ if(!$pretend){ $ampache->change_flags(@info,'setid3','ren'); }
+ }
+ else
+ {
+ if($sort or $all)
+ {
+ if($verbose){ print "Marking for sort after id3\n"; }
+ if(!$pretend){ $ampache->change_flags(@info,'setid3','sort'); }
+ }
+ else
+ {
+ if($verbose){ print "Stopping after id3 update\n"; }
+ if(!$pretend){ $ampache->change_flags(@info,'setid3','notify'); }
+ }
+ }
+ }
+}
+
+if($rename or $all)
+{
+ my $filename = '';
+ my @flagged = $ampache->get_table_where("flagged","WHERE type = 'ren'");
+ foreach my $update (@flagged)
+ {
+ my @info = $ampache->get_song_info($update->{'song'});
+ my $cmd = rename_file($ampache,\$filename,@info);
+ if(!$pretend){ $ampache->update_song($cmd,@info); }
+ if($sort or $all)
+ {
+ if($verbose){ print "Marking for sort after rename\n"; }
+ if(!$pretend){ $ampache->change_flags(@info,'ren','sort'); }
+ }
+ else
+ {
+ if($verbose){ print "Updating filename in DB after rename\n"; }
+ if(!$pretend){ $ampache->change_flags(@info,'ren','notify'); }
+ }
+ }
+}
+
+if ($rename_all) {
+ my $filename = '';
+ my @flagged = $ampache->get_table_where("catalog,song","WHERE catalog.catalog_type='local' AND catalog.id=song.catalog","song.id AS song");
+ foreach my $update (@flagged) {
+ my @info = $ampache->get_song_info($update->{'song'});
+ my $cmd = rename_file($ampache,\$filename,@info);
+ if(!$pretend){ $ampache->update_song($cmd,@info); }
+ } # End Foreach
+} # End Rename All
+
+if ($sort_all) {
+ my $filename = '';
+ my @flagged = $ampache->get_table_where("catalog,song","WHERE catalog.catalog_type='local' AND catalog.id=song.catalog","song.id AS song");
+ foreach my $update(@flagged)
+ {
+ my @info = $ampache->get_song_info($update->{'song'});
+ my $cmd = sort_file($ampache,\$filename,@info);
+ if(!$pretend){ $ampache->update_song($cmd,@info); }
+ if($verbose){ print "Updating filename in DB after sort\n"; }
+ if(!$pretend){ $ampache->change_flags(@info,'sort','notify'); }
+ }
+} # End Sort ALL
+
+
+if($sort or $all)
+{
+ my $filename = '';
+ my @flagged = $ampache->get_table_where("flagged","WHERE type = 'sort'");
+ foreach my $update(@flagged)
+ {
+ my @info = $ampache->get_song_info($update->{'song'});
+ my $cmd = sort_file($ampache,\$filename,@info);
+ if(!$pretend){ $ampache->update_song($cmd,@info); }
+ if($verbose){ print "Updating filename in DB after sort\n"; }
+ if(!$pretend){ $ampache->change_flags(@info,'sort','notify'); }
+ }
+}
+
+# # # # #
+# subs
+# # # # # # #
+
+# %A = album name
+# %a = artist name
+# %C = catalog path (for the specified song)
+# %c = comment
+# %g = genre
+# %y = year
+# %T = track number
+# %t = song title
+#
+# %filename I use for filename
+
+sub get_catalog_setting
+{
+ my ($self,$catalog,$setting) = @_;
+ #bless $self;
+ my $cmd = $self->get_catalog_option($catalog,$setting);
+ return $cmd;
+}
+
+sub update_id3_tag
+{
+ my ($self,$song) = @_;
+ my $id3set = get_catalog_setting($self,$song->{'catalog'},'id3_set_command');
+ $id3set =~ s/\Q%A\E/$song->{'album'}/g;
+ $id3set =~ s/\Q%a\E/$song->{'artist'}/g;
+ $id3set =~ s/\Q%C\E/$song->{'catalog'}/g;
+ $id3set =~ s/\Q%c\E/$song->{'comment'}/g;
+ if(($song->{'genre'} * 1) < 255){$id3set =~ s/\Q%g\E/$song->{'genre'}/g;}
+ else{$id3set =~ s/ -g %g//g;}
+ $id3set =~ s/\Q%T\E/$song->{'track'}/g;
+ $id3set =~ s/\Q%t\E/$song->{'title'}/g;
+ $id3set =~ s/\Q%y\E/$song->{'year'}/g;
+ $id3set =~ s/\Q%filename\E//g;
+ # $id3set =~ s/([\'\"])/\\$1/g;
+ my $filename = $song->{'file'};
+ my $id3tag_command = "$id3set \"$filename\"";
+ return do_call($id3tag_command);
+}
+
+sub rename_file
+{
+ my ($self,$filename,$song) = @_;
+ my $ren_pattern = get_catalog_setting($self,$song->{'catalog'},'rename_pattern');
+ #my $sort_pattern = get_catalog_setting($self,$song->{'catalog'},'sort_pattern');
+ my $basedir;
+ if( $song->{'file'} =~ m/^(.*)\/.*?$/ )
+ {
+ $basedir = $1;
+ }
+ else{ die "Could not determine base directory for $song->{'file'}\n"; }
+
+ # We want to pad track numbers with leading zeros:
+ if($song->{'track'} < 10)
+ {
+ $song->{'track'} = "0".$song->{'track'};
+ }
+
+ # we need to clean title,album,artist,comment,genre,track, and year
+ $song->{'title'} =~ s/[\/]/-/g;
+ $song->{'album'} =~ s/[\/]/-/g;
+ $song->{'artist'} =~ s/[\/]/-/g;
+ $song->{'comment'} =~ s/[\/]/-/g;
+ $song->{'genre'} =~ s/[\/]/-/g;
+ $song->{'track'} =~ s/[\/]/-/g;
+ $song->{'year'} =~ s/[\/]/-/g;
+
+ $ren_pattern =~ s/\Q%A\E/$song->{'album'}/g;
+ $ren_pattern =~ s/\Q%a\E/$song->{'artist'}/g;
+ $ren_pattern =~ s/\Q%C\E/$song->{'catalog'}/g;
+ $ren_pattern =~ s/\Q%c\E/$song->{'comment'}/g;
+ $ren_pattern =~ s/\Q%g\E/$song->{'genre'}/g;
+ $ren_pattern =~ s/\Q%T\E/$song->{'track'}/g;
+ $ren_pattern =~ s/\Q%t\E/$song->{'title'}/g;
+ $ren_pattern =~ s/\Q%y\E/$song->{'year'}/g;
+ $ren_pattern =~ s/\Q%filename\E/$song->{'file'}/g;
+ my $oldfilename = $song->{'file'};
+ my $newfilename = $basedir . "/" . $ren_pattern;
+ # result is backslashes in filename
+ # $newfilename =~ s/([\'\"])/\\$1/g;
+
+ print "\tNew: $newfilename -- OLD: $oldfilename\n";
+
+ if(! -e "$newfilename")
+ {
+ my $ren_command = "mv \"$oldfilename\" \"$newfilename\"";
+ $filename = $newfilename;
+ do_call($ren_command);
+ return $filename;
+ }
+ else
+ {
+ print STDERR "File exists: $newfilename\n";
+ $filename = $oldfilename;
+ return $filename;
+ }
+}
+
+sub sort_file
+{
+ my ($self, $filename, $song) = @_;
+ my $basename;
+ my $basedir;
+ if( $song->{'file'} =~ m/^(.*)\/(.*?)$/ )
+ {
+ $basename = $2;
+ $basedir = $1
+ }
+ else{ die "Could not determine base name for $song->{'file'}\n"; }
+
+ # we need to clean title,album,artist,comment,genre,track, and year
+ $song->{'title'} =~ s/[\/]/-/g;
+ $song->{'album'} =~ s/[\/]/-/g;
+ $song->{'artist'} =~ s/[\/]/-/g;
+ $song->{'comment'} =~ s/[\/]/-/g;
+ $song->{'genre'} =~ s/[\/]/-/g;
+ $song->{'track'} =~ s/[\/]/-/g;
+ $song->{'year'} =~ s/[\/]/-/g;
+
+ my $location = get_catalog_setting($self,$song->{'catalog'},'sort_pattern');
+ $location =~ s/\Q%A\E/$song->{'album'}/g;
+ $location =~ s/\Q%a\E/$song->{'artist'}/g;
+ $location =~ s/\Q%C\E/$song->{'catalog'}/g;
+ $location =~ s/\Q%c\E/$song->{'comment'}/g;
+ $location =~ s/\Q%g\E/$song->{'genre'}/g;
+ $location =~ s/\Q%T\E/$song->{'track'}/g;
+ $location =~ s/\Q%t\E/$song->{'title'}/g;
+ $location =~ s/\Q%y\E/$song->{'year'}/g;
+ # result is wrong paths
+ # $location =~ s/([\'\"])/\\$1/g;
+
+ create($location);
+
+ # The basename is calculated so we can see if the file already exists
+ if(! -e "$location/$basename")
+ {
+ my $cmd = "/bin/mv \"".$song->{'file'}."\" \"$location\"";
+ my $ret = do_call($cmd);
+ if(empty_dir($basedir))
+ {
+ print "Removing empty directory $basedir\n";
+ $cmd = "/bin/rmdir \"$basedir\"";
+ do_call($cmd);
+ }
+ $filename = $location."/".$basename;
+ return $filename;
+ }
+ else
+ {
+ print STDERR "File exists: $location/$basename\n";
+ $filename = $song->{'file'};
+ return $filename;
+ }
+}
+
+sub usage
+{
+ my $usage = qq{
+ fileupdate [--id3|--rename|--rename_all|--sort|--sort_all|--all] [--help] [--pretend] [--verbose]
+ --pretend Display command taken, without actually doing anything.
+
+ --id3 Update id3 tags for all files flagged with 'id3'
+
+ --rename Rename files flagged with 'rename'
+
+ --rename_all Renames all files based on id3 info
+
+ --sort Sort files flagged with 'sort'
+
+ --sort_all Sort all files based on id3 info
+
+ --all Performs id3 update, rename, and sort
+ for all files flagged with 'id3'
+ --verbose Shows detailed information about what's happening.
+
+ --help This message
+ };
+ die $usage;
+}
+
+sub do_call
+{
+ my @cmd = @_;
+ my $return = 0;
+
+ if($verbose && !$pretend){ print "@cmd\n";}
+ if($pretend){ print "@cmd\n"; }
+ else
+ {
+ $return = system @cmd;
+ }
+ return $return;
+}
+
+sub create
+{
+ my ($path) = @_;
+ if(! -e $path)
+ {
+ return do_call("mkdir","-p",$path);
+ }
+ return 1;
+}
+
+# empty_dir borrowed from Tom Phoenix (rootbeer@teleport.com)
+# posted in comp.lang.perl.misc on 3/21/97
+
+sub empty_dir ($)
+{
+ local(*DIR, $_);
+ return unless opendir DIR, $_[0];
+ while (defined($_ = readdir DIR)) {
+ next if /^\.\.?$/;
+ closedir DIR;
+ return 0;
+ }
+ closedir DIR;
+ 1;
+}
+1;
diff --git a/bin/genres.txt b/bin/genres.txt
new file mode 100755
index 00000000..968f68c1
--- /dev/null
+++ b/bin/genres.txt
@@ -0,0 +1,148 @@
+1.Classic Rock
+2.Country
+3.Dance
+4.Disco
+5.Funk
+6.Grunge
+7.Hip-Hop
+8.Jazz
+9.Metal
+10.New Age
+11.Oldies
+12.Other
+13.Pop
+14.R&B
+15.Rap
+16.Reggae
+17.Rock
+18.Techno
+19.Industrial
+20.Alternative
+21.Ska
+22.Death Metal
+23.Pranks
+24.Soundtrack
+25.Euro-Techno
+26.Ambient
+27.Trip-Hop
+28.Vocal
+29.Jazz+Funk
+30.Fusion
+31.Trance
+32.Classical
+33.Instrumental
+34.Acid
+35.House
+36.Game
+37.Sound Clip
+38.Gospel
+39.Noise
+40.AlternRock
+41.Bass
+42.Soul
+43.Punk
+44.Space
+45.Meditative
+46.Instrumental Pop
+47.Instrumental Rock
+48.Ethnic
+49.Gothic
+50.Darkwave
+51.Techno-Industrial
+52.Electronic
+53.Pop-Folk
+54.Eurodance
+55.Dream
+56.Southern Rock
+57.Comedy
+58.Cult
+59.Gangsta
+60.Top 40
+61.Christian Rap
+62.Pop/Funk
+63.Jungle
+64.Native American
+65.Cabaret
+66.New Wave
+67.Psychadelic
+68.Rave
+69.Showtunes
+70.Trailer
+71.Lo-Fi
+72.Tribal
+73.Acid Punk
+74.Acid Jazz
+75.Polka
+76.Retro
+77.Musical
+78.Rock & Roll
+79.Hard Rock
+80.Folk
+81.Folk-Rock
+82.National Folk
+83.Swing
+84.Fast Fusion
+85.Bebob
+86.Latin
+87.Revival
+88.Celtic
+89.Bluegrass
+90.Avantgarde
+91.Gothic Rock
+92.Progressive Rock
+93.Psychedelic Rock
+94.Symphonic Rock
+95.Slow Rock
+96.Big Band
+97.Chorus
+98.Easy Listening
+99.Acoustic
+100.Humour
+101.Speech
+102.Chanson
+103.Opera
+104.Chamber Music
+105.Sonata
+106.Symphony
+107.Booty Bass
+108.Primus
+109.Porn Groove
+110.Satire
+111.Slow Jam
+112.Club
+113.Tango
+114.Samba
+115.Folklore
+116.Ballad
+117.Power Ballad
+118.Rhythmic Soul
+119.Freestyle
+120.Duet
+121.Punk Rock
+122.Drum Solo
+123.A capella
+124.Euro-House
+125.Dance Hall
+126.Goa
+127.Drum & Bass
+128.Club-House
+129.Hardcore
+130.Terror
+131.Indie
+132.BritPop
+133.Negerpunk
+134.Polsk Punk
+135.Beat
+136.Christian Gansta Rap
+137.Heavy Metal
+138.Black Metal
+139.Crossover
+140.Contemporary Christian
+141.Christian Rock
+142.Merengue
+143.Salsa
+144.Thrash Metal
+145.Anime
+146.JPop
+147.Synthpop
+255.Unknown
diff --git a/bin/init b/bin/init
new file mode 100755
index 00000000..6d396cf5
--- /dev/null
+++ b/bin/init
@@ -0,0 +1,11 @@
+#! /usr/bin/perl
+# Copyleft Ampache.org
+
+# This script loads up the path to the perl module
+#
+
+use FindBin qw($Bin);
+use lib "$Bin/../lib/perl/Local/Ampache/blib/lib";
+use Local::Ampache;
+$ampache = new Local::Ampache("$Bin/..");
+
diff --git a/bin/moosic b/bin/moosic
new file mode 100755
index 00000000..1f9460ac
--- /dev/null
+++ b/bin/moosic
@@ -0,0 +1,6 @@
+#!/usr/bin/python
+
+import sys
+from moosic.client.cli.main import main
+
+main(sys.argv)
diff --git a/bin/moosicd b/bin/moosicd
new file mode 100755
index 00000000..70313995
--- /dev/null
+++ b/bin/moosicd
@@ -0,0 +1,6 @@
+#!/usr/bin/python
+
+import sys
+from moosic.server.main import main
+
+main(sys.argv)
diff --git a/bin/parse_m3u.php.inc b/bin/parse_m3u.php.inc
new file mode 100644
index 00000000..9b720bb3
--- /dev/null
+++ b/bin/parse_m3u.php.inc
@@ -0,0 +1,47 @@
+<?php
+/*
+
+ 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+
+/* Name of the filename who's tags you want to read */
+$filename = "/data/music/Live/L/Life'll Kill Ya/Warren Zevon.m3u";
+
+
+$no_session = '1';
+require ("../modules/init.php");
+
+$handle = fopen($filename,'r');
+
+$data = fread($handle,filesize($filename));
+
+$results = explode("\n",$data);
+
+foreach ($results as $value) {
+ $value = trim($value);
+ if (preg_match("/\.[A-Za-z0-9]{3}$/",$value)) {
+ echo "$value \n";
+ $sql = "SELECT id FROM song WHERE file LIKE '%" . sql_escape($value) . "'";
+ $db_results = mysql_query($sql, dbh());
+ $foo = mysql_result($db_results,'id');
+ echo "\t Results: " . $foo . "\n";
+ print_r($foo);
+ }
+
+} // end foreach
+
+?>
diff --git a/bin/print_amazon.php.inc b/bin/print_amazon.php.inc
new file mode 100755
index 00000000..09118ae7
--- /dev/null
+++ b/bin/print_amazon.php.inc
@@ -0,0 +1,42 @@
+<?php
+/*
+
+ 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+
+/* Name of the filename who's tags you want to read */
+$search['album_name'] = "Ariels";
+$search['artist_name'] = "Bent";
+
+
+
+$no_session = '1';
+require ("../modules/init.php");
+echo "<pre>\n";
+$amazon = new AmazonSearch(conf('amazon_developer_key'));
+// Prevent the script from timing out
+set_time_limit(0);
+$search_term = $search['artist_name'] . " " . $search['album_name'];
+$amazon->search(array('artist' => $search['artist_name'], 'album' => $search['album_name'], 'keywords' => $serch_term));
+$amazon->lookup($amazon->results);
+
+echo "Search Term: $search_term\n";
+echo "Artist: " . $search['artist_name'] . " AND Album: " . $search['album_name'] . "\n";
+print_r($amazon->results);
+echo "\n</pre>";
+?>
+
diff --git a/bin/print_tags.php.inc b/bin/print_tags.php.inc
new file mode 100644
index 00000000..b199eeea
--- /dev/null
+++ b/bin/print_tags.php.inc
@@ -0,0 +1,34 @@
+<?php
+/*
+
+ 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+
+/* Name of the filename who's tags you want to read */
+$filename = "/data/music/Upload/woo.spx";
+
+
+$no_session = '1';
+require ("../modules/init.php");
+echo "<pre>";
+$info = new Audioinfo();
+$results = $info->info($filename);
+
+
+print_r($results);
+?>
+