jq join for play-release
This commit is contained in:
29
src/main.sh
29
src/main.sh
@@ -71,7 +71,29 @@ if [ "${1:-}" = "--list-artists" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${1:-}" = "--play-release" ]; then
|
if [ "${1:-}" = "--play-release" ]; then
|
||||||
echo "Playing release $2" >>/tmp/foo
|
mbid=${2}
|
||||||
|
deco=${3}
|
||||||
|
base="$(dirname "$deco")"
|
||||||
|
echo "Playing release ($mbid) [$deco]" >>/tmp/foo
|
||||||
|
mb_release "$mbid" |
|
||||||
|
$JQ -r --slurpfile deco "$deco" --arg base "$base" '$deco[].tracks as $filenames |
|
||||||
|
.media[] |
|
||||||
|
.position as $pos |
|
||||||
|
.tracks |
|
||||||
|
map({
|
||||||
|
$pos,
|
||||||
|
number: .number,
|
||||||
|
file: $filenames[.id]
|
||||||
|
}) |
|
||||||
|
map(
|
||||||
|
if(.number | type == "string" and test("^[0-9]+$")) then
|
||||||
|
.number |= tonumber
|
||||||
|
else
|
||||||
|
.
|
||||||
|
end
|
||||||
|
) |
|
||||||
|
sort_by([.pos, .number]) |
|
||||||
|
map($base + "/" + .file)[]' >>/tmp/foo
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -368,7 +390,6 @@ esac
|
|||||||
while true; do
|
while true; do
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
"--artist")
|
"--artist")
|
||||||
mb_artist "$2" >>/tmp/foo
|
|
||||||
name="$(mb_artist "$2" | $JQ -r '.name')"
|
name="$(mb_artist "$2" | $JQ -r '.name')"
|
||||||
secsymb="$(printf "$FORMAT_TYPE_HAS_SECONDARY" "")"
|
secsymb="$(printf "$FORMAT_TYPE_HAS_SECONDARY" "")"
|
||||||
sel=$(
|
sel=$(
|
||||||
@@ -420,7 +441,7 @@ while true; do
|
|||||||
--expect="ctrl-h,ctrl-a" \
|
--expect="ctrl-h,ctrl-a" \
|
||||||
--bind="alt-l:change-query($FORMAT_LOCAL )" \
|
--bind="alt-l:change-query($FORMAT_LOCAL )" \
|
||||||
--bind="load:transform:[ \"\$FZF_TOTAL_COUNT\" -gt 0 ] && echo \"rebind:ctrl-l\" || echo \"unbind:ctrl-l\"" \
|
--bind="load:transform:[ \"\$FZF_TOTAL_COUNT\" -gt 0 ] && echo \"rebind:ctrl-l\" || echo \"unbind:ctrl-l\"" \
|
||||||
--bind="enter:execute-silent:$0 --play-release {3}" \
|
--bind="enter:execute-silent:$0 --play-release {2} {3}" \
|
||||||
--bind="focus:transform:[ {3} ] && echo \"rebind:enter\" || echo \"unbind:enter\"" \
|
--bind="focus:transform:[ {3} ] && echo \"rebind:enter\" || echo \"unbind:enter\"" \
|
||||||
--bind="ctrl-l:accept" \
|
--bind="ctrl-l:accept" \
|
||||||
--bind="alt-b:execute-silent:xdg-open 'https://musicbrainz.org/release/{r2}' &" \
|
--bind="alt-b:execute-silent:xdg-open 'https://musicbrainz.org/release/{r2}' &" \
|
||||||
@@ -589,7 +610,7 @@ while true; do
|
|||||||
--expect="ctrl-/" \
|
--expect="ctrl-/" \
|
||||||
--bind="alt-l:change-query($FORMAT_LOCAL )" \
|
--bind="alt-l:change-query($FORMAT_LOCAL )" \
|
||||||
--bind="load:transform:[ \"\$FZF_TOTAL_COUNT\" -gt 0 ] && echo \"rebind:ctrl-l\" || echo \"unbind:ctrl-l\"" \
|
--bind="load:transform:[ \"\$FZF_TOTAL_COUNT\" -gt 0 ] && echo \"rebind:ctrl-l\" || echo \"unbind:ctrl-l\"" \
|
||||||
--bind="enter:execute-silent:$0 --play-release {3}" \
|
--bind="enter:execute-silent:$0 --play-release {2} {3}" \
|
||||||
--bind="focus:transform:[ {3} ] && echo \"rebind:enter\" || echo \"unbind:enter\"" \
|
--bind="focus:transform:[ {3} ] && echo \"rebind:enter\" || echo \"unbind:enter\"" \
|
||||||
--bind="ctrl-l:accept" \
|
--bind="ctrl-l:accept" \
|
||||||
--bind="alt-b:execute-silent:xdg-open 'https://musicbrainz.org/release/{r2}' &" \
|
--bind="alt-b:execute-silent:xdg-open 'https://musicbrainz.org/release/{r2}' &" \
|
||||||
|
Reference in New Issue
Block a user