summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-07-08 05:12:03 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-07-08 05:12:03 +0000
commitc9f8c7abd211ebdb5a4c7d5797e3513aad14530d (patch)
treee1d50deafbd52f10ec6e5588aadb46567ece647e /bin
parentf04fe3df5ef816a2a3394a09f497dc97889de47a (diff)
downloadampache-c9f8c7abd211ebdb5a4c7d5797e3513aad14530d.tar.gz
ampache-c9f8c7abd211ebdb5a4c7d5797e3513aad14530d.tar.bz2
ampache-c9f8c7abd211ebdb5a4c7d5797e3513aad14530d.zip
see changelog...
Diffstat (limited to 'bin')
-rwxr-xr-xbin/archive/init (renamed from bin/init)0
-rw-r--r--bin/catalog_update.php.inc3
-rwxr-xr-xbin/create_genre32
-rwxr-xr-xbin/filesort.pl29
-rwxr-xr-xbin/fileupdate.pl346
-rwxr-xr-xbin/genres.txt148
6 files changed, 3 insertions, 555 deletions
diff --git a/bin/init b/bin/archive/init
index 6d396cf5..6d396cf5 100755
--- a/bin/init
+++ b/bin/archive/init
diff --git a/bin/catalog_update.php.inc b/bin/catalog_update.php.inc
index 3f8e9a76..9d6160df 100644
--- a/bin/catalog_update.php.inc
+++ b/bin/catalog_update.php.inc
@@ -9,6 +9,9 @@ $db_results = mysql_query($sql, dbh());
while ($r = mysql_fetch_row($db_results)) {
$catalog = new Catalog($r[0]);
+ // Clean out dead files
+ $catalog->clean_catalog();
+
// Verify Existing
$catalog->verify_catalog();
diff --git a/bin/create_genre b/bin/create_genre
deleted file mode 100755
index c9687e7b..00000000
--- a/bin/create_genre
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/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
deleted file mode 100755
index a3347ab6..00000000
--- a/bin/filesort.pl
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/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
deleted file mode 100755
index 4353d057..00000000
--- a/bin/fileupdate.pl
+++ /dev/null
@@ -1,346 +0,0 @@
-#!/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
deleted file mode 100755
index 968f68c1..00000000
--- a/bin/genres.txt
+++ /dev/null
@@ -1,148 +0,0 @@
-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