iTunesの曲一覧


 Win32::OLEを使うためWindowsが対象です。
use strict;
use warnings;
use Win32::OLE;

my $itunes = Win32::OLE->new("iTunes.Application")
    or die "iTunesオブジェクトを作成できません。";

my $list = $itunes->LibraryPlaylist;
#my $list = $itunes->LibrarySource->Playlists->ItemByName('ミュージック');
#my $list = $itunes->LibrarySource->Playlists->ItemByName('Podcast');

my $tracks = $list->Tracks;
my $track_num = $tracks->Count;

print "合計", $track_num, "曲\n";

foreach my $i (1 .. $track_num) {
    my $track = $tracks->item($i);
    printf "%5s %s", $track->Time, $track->Name;
    print "\n";
}

関連項目

iTunesで今聴いている曲の取得