X-Git-Url: https://git.draconx.ca/gitweb/fvwmconf.git/blobdiff_plain/28cb996b04a7c47ed40f97033f6e4faa507a987d..76dcebcadfbe9098623b0f6b54eeebcdbf872c96:/scripts/mpdmenu.pl diff --git a/scripts/mpdmenu.pl b/scripts/mpdmenu.pl index 9b60cdf..d2c4c2c 100755 --- a/scripts/mpdmenu.pl +++ b/scripts/mpdmenu.pl @@ -3,7 +3,7 @@ use strict; use Getopt::Long; -use IO::Socket; +use IO::Socket::INET6; use constant { MPD_MJR_MIN => 0, @@ -46,7 +46,7 @@ $artist = decode_utf8($artist) if defined($artist); $title = decode_utf8($title) if defined($title);; # Connect to MPD. -my $sock = new IO::Socket::INET( +my $sock = new IO::Socket::INET6( PeerAddr => $host, PeerPort => $port, Proto => 'tcp' @@ -67,27 +67,27 @@ if (defined $album) { 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) = ( @@ -97,16 +97,16 @@ if (defined $album) { $_->{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) { @@ -122,7 +122,7 @@ if (defined $album) { while (<$sock>) { last if (/^OK/); die($_) if (/^ACK/); - + if (/^(\w+): (.*)$/) { $file = $2 if ($1 eq "file"); $albums{$2} = $file if ($1 eq "Album"); @@ -138,11 +138,11 @@ if (defined $album) { my $key = $_; my $a_album = sanitise($key); - open THUMB, "-|", "$FVWM/scripts/thumbnail.sh", + open THUMB, "-|", "$FVWM/scripts/thumbnail.zsh", "--small", "--music", $albums{$key}; my $thumb = ; close THUMB; - die("Incompetent use of thumbnail.sh") if ($?); + die("Incompetent use of thumbnail.zsh") if ($?); $thumb =~ s/\n//sg; $thumb = "%$thumb%" if (-f $thumb); @@ -186,6 +186,7 @@ if (defined $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. @@ -193,10 +194,10 @@ if (defined $album) { 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-]+(mix|size|version))?$//i; s/\s+without\s+\w+$//i; my $basetitle = $_; @@ -207,13 +208,13 @@ if (defined $album) { 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; } } @@ -230,15 +231,16 @@ if (defined $album) { ); # MPD searches are case-insensitive. - next if (!($t_title =~ m/(\P{Latin}|^)\Q$basetitle\E(\P{Latin}|$)/)); + next if (!($t_title =~ m/(\P{Latin}|^)\Q$basetitle\E(\P{Latin}|$)/ || $t_title =~ m/\Q$basetitle\E/i)); + $t_artist = sanitise($t_artist); $t_title = sanitise($t_title); - open THUMB, "-|", "$FVWM/scripts/thumbnail.sh", + open THUMB, "-|", "$FVWM/scripts/thumbnail.zsh", "--small", "--music", $t_file; my $thumb = ; close(THUMB); - die("Incompetent use of thumbnail.sh") if ($?); + die("Incompetent use of thumbnail.zsh") if ($?); $thumb =~ s/\n//sg; $thumb = "%$thumb%" if (-f $thumb); @@ -281,7 +283,7 @@ if (defined $album) { } die("Failed data query\n") unless (keys(%entry) > 0); - open THUMB, "-|", "$FVWM/scripts/thumbnail.sh", + open THUMB, "-|", "$FVWM/scripts/thumbnail.zsh", "--image", "--music", $entry{file}; my $thumb = ; my $scan = ; @@ -350,7 +352,7 @@ if (defined $album) { ."--menu MenuMPDAlbum " ."--album ".shellify($entry{Album}, 1)." " ."--artist ".shellify($entry{Artist}, 1)."\""); - + cmd("DestroyFunc MakeMenuMPDArtist"); cmd("AddToFunc MakeMenuMPDArtist + I DestroyMenu MenuMPDArtist