Created
April 7, 2014 01:11
-
-
Save lwalen/10013433 to your computer and use it in GitHub Desktop.
Returns a list of artists with only one song from a given iTunes library or playlist file
This file contains hidden or 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/env perl | |
use v5.10; | |
use Mac::iTunes::Library; | |
use Mac::iTunes::Library::XML; | |
use Mac::iTunes::Library::Playlist; | |
my $library = Mac::iTunes::Library::XML->parse(@ARGV[0]); | |
my %results; | |
my %items = $library->items(); | |
while (($artist, $artistSongs) = each %items) { | |
if ((keys %$artistSongs) == 1) { | |
while (($songName, $artistSongItems) = each %{$artistSongs}) { | |
foreach my $item (@$artistSongItems) { | |
$results{$artist} = $item->name(); | |
} | |
} | |
} | |
} | |
foreach my $key (sort { lc($a) cmp lc($b) } keys %results) { | |
say "$key\t$results{$key}"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment