my $entry;
$menu = "MenuMPDAlbum" unless defined $menu;
-
+
$album =~ s/"/\\"/g;
print $sock "playlistfind album \"$album\"\n";
while (<$sock>) {
last if (/^OK/);
die($_) if (/^ACK/);
-
+
if (/^(\w+): (.*)$/) {
if ($1 eq "file") {
if (keys(%$entry) > 0) {
addalbumentry(\@playlist, $entry)
}
-
+
$entry = {};
}
-
+
$entry->{$1} = $2;
}
}
addalbumentry(\@playlist, $entry) if (keys(%$entry) > 0);
-
+
die("No tracks found.\n") if (!@playlist);
foreach (sort albumsort @playlist) {
my ($t_file, $t_trackno, $t_artist, $t_title, $t_id) = (
$_->{Title},
$_->{Id},
);
-
+
next if (defined $artist && !$accept{albumdir($t_file)});
-
+
$t_artist = sanitise($t_artist);
$t_title = sanitise($t_title);
-
+
my $cmd = sprintf "AddToMenu $menu \"%d\t%s - %s\""
." Exec mpc playid %d",
$t_trackno, $t_artist, $t_title, $t_id;
-
+
cmd($cmd);
}
} elsif (defined $artist) {
while (<$sock>) {
last if (/^OK/);
die($_) if (/^ACK/);
-
+
if (/^(\w+): (.*)$/) {
$file = $2 if ($1 eq "file");
$albums{$2} = $file if ($1 eq "Album");
s/ -Practice Track-//; # Fair Heaven
s/〜世界で一番アナタが好き〜//; # Pure Heart
s/〜彼方への哀歌//; # 十二幻夢
+ s/ sora no uta ver.//; # 美しい星
s/\s*-remix-$//; # Otherwise "D-THREAD -remix-" doesn't work right.
s/\s*$ob.*(style|mix|edit|edition|ver\.?|version|カラオケ)$cb?$//i;
# Deal with titles like "blah (without XYZ)".
- s/\s*$ob((e\.)?piano|english|japanese|inst|tv|without|w\/o|off|back|short|karaoke|game).*//i;
+ s/\s*$ob\s*((e\.)?piano|english|japanese|inst|tv|without|w\/o|off|back|short|karaoke|game).*//i;
# Deal with titles like "blah instrumental".
- s/\s+(instrumental|off vocal|short)(\s+(size|version|s))?$//i;
+ s/\s+(instrumental|off vocal|short|tv)([\s-]+(size|version|s))?$//i;
s/\s+without\s+\w+$//i;
my $basetitle = $_;
while (<$sock>) {
last if (/^OK/);
die($_) if (/^ACK/);
-
+
if (/^(\w+): (.*)$/) {
if ($1 eq "file") {
push @titles, $entry if (keys(%$entry) > 0);
$entry = {};
}
-
+
$entry->{$1} = $2;
}
}
."--menu MenuMPDAlbum "
."--album ".shellify($entry{Album}, 1)." "
."--artist ".shellify($entry{Artist}, 1)."\"");
-
+
cmd("DestroyFunc MakeMenuMPDArtist");
cmd("AddToFunc MakeMenuMPDArtist
+ I DestroyMenu MenuMPDArtist