blob: dee407437041390dba6a71cf0f1d65b1e470d743 (
plain) (
tree)
|
|
function bass
switch "$argv[1]"
case search find
__bass_print (__bass_mpc $argv)
case id
__bass_mbid $argv
case browse
__bass_browse $argv
case love
mpc sendmessage listenbrainz_feedback love
case hate
mpc sendmessage listenbrainz_feedback hate
case ""
__bass_print -p (__bass_mpc playlist)
case "*"
mpc $argv
end
end
function __bass_print
argparse "p/playlist" -- $argv
or return 1
for line in $argv
set -l data (string split \t $line)
set -l artist (__bass_trim $data[1])
set -l album (__bass_trim $data[2])
set -l title (__bass_trim $data[3])
set -l file $data[4]
set -l position $data[5]
if not isatty stdout
echo $file
else if set -q _flag_playlist
set -l current (mpc -f "%position%" current)
if test "$position" = "$current"
echo -n "▶ "
else
echo -n " "
end
__bass_print_track $title $artist $album
else
__bass_print_track $title $artist $album
end
end
end
function __bass_trim
set -l length (string length $argv[1])
if test $length -gt 39
echo (string sub --length 39 $argv[1])…
else
echo $argv[1]
end
end
function __bass_print_track
set_color blue
echo -n $argv[1]
set_color normal
echo " ꞏ $argv[2] ꞏ $argv[3]"
end
function __bass_mpc
set -l format "%artist%\t%album%\t%title%\t%file%\t%position%"
mpc -f $format $argv
end
function __bass_browse
argparse "a/album" "o/open" -- $argv
or return 1
set -l id (__bass_mbid $_flag_album)
or return 1
beet browse $_flag_album $_flag_open $id
end
function __bass_mbid
argparse "a/album" -- $argv
or return 1
set -l ids (string split \t (mpc -f "%musicbrainz_trackid%\t%musicbrainz_albumid%" current))
if test $status -ne 0
return 1
end
if not set -q _flag_album
echo "mb_trackid:$ids[1]"
else
echo "mb_albumid:$ids[2]"
end
end
|