Created
July 25, 2015 10:01
-
-
Save xavery/a9ead4c01e3b5404df58 to your computer and use it in GitHub Desktop.
Script to generate a histogram showing the dominating years in your music collection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
use Audio::TagLib; | |
use File::Find; | |
use Statistics::Histogram; | |
die "Usage : $0 <dir>" unless $ARGV[0] && -d $ARGV[0]; | |
sub unique | |
{ | |
my %counts; | |
$counts{$_}++ for @{$_[0]}; | |
return scalar(keys(%counts)); | |
} | |
my @years; | |
sub wanted | |
{ | |
return unless -f $_; | |
my $f = Audio::TagLib::FileRef->new($_); | |
if(defined($f->tag())) | |
{ | |
my $year = $f->tag()->year(); | |
push @years, $year if($year != 0); | |
} | |
} | |
find(\&wanted, $ARGV[0]); | |
print get_histogram(\@years, unique(\@years), 1, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment