Astroboy
view release on metacpan or search on metacpan
lib/Astroboy/AlbumDir.pm view on Meta::CPAN
$self->is_album or carp("Not deemed album: $abs_path") and return;
return $self;
}
sub ls_mp3_percent {
my $self = shift;
my $total_files = $self->ls_count || 0;
my $total_mp3 = $self->ls_mp3_count || 0;
$total_mp3 or return 0;
#debug("$total_files $total_mp3");
int( ($total_mp3 * 100 ) / $total_files );
}
sub is_album { ($_[0]->ls_mp3_percent) > 50 ? 1 : 0 }
sub empty_trash {
$_[0]->ls_trash_count or warn("Nothing in trash.\n") and return;
unlink @{$_[0]->ls_trash};
1;
}
# paths
#
lib/Astroboy/AlbumDir.pm view on Meta::CPAN
Returns count of files.
=head2 ls_mp3()
Like ls(), returns array ref of mp3 files in this dir.
=head2 ls_trash()
Like ls(), returns everything not mp3.
=head2 ls_mp3_percent()
Of the files in this dir, what percentage are mp3s.
=head2 is_album()
If more than 50% of files are mp3, then true, else false.
=head2 empty_trash()
Moves files to a temp directory. Sort of a safe delete.
This is everything that is not an mp3 file.
Call at your own peril.
t/00_albumdir_basic.t view on Meta::CPAN
skipcond();
my $abs = './t/music/dir1';
-d $abs or die("missing $abs");
my $a = Astroboy::AlbumDir->new($abs);
ok( $a, "got album" ) or die;
my $percentage = $a->ls_mp3_percent;
ok($percentage, "percentage mp3s: $percentage");
ok $a->is_album,'is album';
my $trash = $a->ls_trash;
### $trash
my $music = $a->ls_mp3;
### $music
my $all = $a->ls;
t/03_albumdir_advanced.t view on Meta::CPAN
system('cp -R ./t/music/dir1 ./t/music/album_tmp');
my $abs = './t/music/album_tmp';
-d $abs or die("missing $abs");
my $a = Astroboy::AlbumDir->new($abs);
ok( $a, "got album" ) or die;
my $percentage = $a->ls_mp3_percent;
ok($percentage, "percentage mp3s: $percentage");
ok $a->is_album,'is album';
my $abs_music = $a->abs_music;
ok($abs_music, "abs music is $abs_music");
my $artist = $a->artist;
( run in 0.386 second using v1.01-cache-2.11-cpan-05162d3a2b1 )