Compare commits
8 Commits
42e4aa02b6
...
d39cf11ed3
Author | SHA1 | Date | |
---|---|---|---|
d39cf11ed3 | |||
8112586f87 | |||
6dc107c7c4 | |||
9c969d073f | |||
e76cb6a8e3 | |||
58b1258fe2 | |||
173c717be5 | |||
98145031d3 |
@@ -7,22 +7,22 @@ FORMAT_LOCAL="|>"
|
|||||||
# Pointer to the track currently playing (playlist)
|
# Pointer to the track currently playing (playlist)
|
||||||
FORMAT_CURRENT="->"
|
FORMAT_CURRENT="->"
|
||||||
|
|
||||||
# Input prompts
|
# Input prompt
|
||||||
# =============
|
# =============
|
||||||
# General search prompt
|
# Search prompt
|
||||||
SEARCH_PROMPT="search> "
|
SEARCH_PROMPT="search> "
|
||||||
# Prompt that takes an artist name as argument
|
|
||||||
ARTIST_PROMPT="%s > "
|
|
||||||
# Prompt that takes an artist name and a release name as arguments (in that
|
|
||||||
# order)
|
|
||||||
FULL_PROMPT="%s > %s > "
|
|
||||||
|
|
||||||
# Visual representation of current mode
|
# Headers
|
||||||
# =====================================
|
# =======
|
||||||
# Sign to indicate `normal` mode
|
# Header that displays artist's name
|
||||||
PROMPT_NORMAL="n "
|
HEADER_ARTIST="%s > "
|
||||||
# Sign to indicate `insert` mode
|
# Header that displays the release-group name after artist's
|
||||||
PROMPT_INSERT="i "
|
HEADER_ARTIST_RELEASEGROUP="%s > %s > "
|
||||||
|
# Header that in addition to `HEADER_ARTIST_RELEASEGROUP` also shows some
|
||||||
|
# release information
|
||||||
|
HEADER_RELEASE="%s > %s > %s"
|
||||||
|
# The release information is formatted as follows (placeholders implicit):
|
||||||
|
HEADER_RELEASE_FORMAT="<<tracks>> tx <<media>> | <<label>> <<country>> <<year>>"
|
||||||
|
|
||||||
# Artist view
|
# Artist view
|
||||||
# ===========
|
# ===========
|
||||||
|
@@ -18,22 +18,22 @@ FORMAT_LOCAL="${BLUE}|>$OFF"
|
|||||||
# Pointer to the track currently playing (playlist)
|
# Pointer to the track currently playing (playlist)
|
||||||
FORMAT_CURRENT="${WHITE}-->$OFF"
|
FORMAT_CURRENT="${WHITE}-->$OFF"
|
||||||
|
|
||||||
# Input prompts
|
# Input prompt
|
||||||
# =============
|
# =============
|
||||||
# General search prompt
|
# Search prompt
|
||||||
SEARCH_PROMPT="search: "
|
SEARCH_PROMPT="search: "
|
||||||
# Prompt that takes an artist name as argument
|
|
||||||
ARTIST_PROMPT="artist: %s: "
|
|
||||||
# Prompt that takes an artist name and a release name as arguments (in that
|
|
||||||
# order)
|
|
||||||
FULL_PROMPT="artist: %s / %s: "
|
|
||||||
|
|
||||||
# Visual representation of current mode
|
# Headers
|
||||||
# =====================================
|
# =======
|
||||||
# Sign to indicate `normal` mode
|
# Header that displays artist's name
|
||||||
PROMPT_NORMAL="n)"
|
HEADER_ARTIST="artist: %s"
|
||||||
# Sign to indicate `insert` mode
|
# Header that displays the release-group name after artist's
|
||||||
PROMPT_INSERT="i)"
|
HEADER_ARTIST_RELEASEGROUP="artist: %s / album: %s"
|
||||||
|
# Header that in addition to `HEADER_ARTIST_RELEASEGROUP` also shows some
|
||||||
|
# release information
|
||||||
|
HEADER_RELEASE="artist: %s / album: %s (%s)"
|
||||||
|
# The release information is formatted as follows (placeholders implicit):
|
||||||
|
HEADER_RELEASE_FORMAT="<<label>> <<year>>"
|
||||||
|
|
||||||
# Artist view
|
# Artist view
|
||||||
# ===========
|
# ===========
|
||||||
|
@@ -94,17 +94,17 @@ BEGIN {
|
|||||||
else
|
else
|
||||||
line = line "\t"
|
line = line "\t"
|
||||||
|
|
||||||
sub("<<status>>", line_status, line)
|
gsub("<<status>>", line_status, line)
|
||||||
sub("<<year>>", year, line)
|
gsub("<<year>>", year, line)
|
||||||
sub("<<tracks>>", trackcnt, line)
|
gsub("<<tracks>>", trackcnt, line)
|
||||||
sub("<<media>>", media, line)
|
gsub("<<media>>", media, line)
|
||||||
gsub("&", "\\\\&", label)
|
gsub("&", "\\\\&", label)
|
||||||
sub("<<label>>", label, line)
|
gsub("<<label>>", label, line)
|
||||||
gsub("&", "\\\\&", titel)
|
gsub("&", "\\\\&", title)
|
||||||
sub("<<title>>", title, line)
|
gsub("<<title>>", title, line)
|
||||||
gsub("&", "\\\\&", artist)
|
gsub("&", "\\\\&", artist)
|
||||||
sub("<<artist>>", artist, line)
|
gsub("<<artist>>", artist, line)
|
||||||
sub("<<country>>", country, line)
|
gsub("<<country>>", country, line)
|
||||||
sortk = year ? year : 0
|
sortk = year ? year : 0
|
||||||
l = local_releases[id] ? format_local : ""
|
l = local_releases[id] ? format_local : ""
|
||||||
print sortk, l, line, rgid ? rgid : "0", id ":" local_releases[id]
|
print sortk, l, line, rgid ? rgid : "0", id ":" local_releases[id]
|
||||||
|
87
src/main.sh
87
src/main.sh
@@ -80,6 +80,9 @@ MODE_INSERT="show"
|
|||||||
# FZF handlers
|
# FZF handlers
|
||||||
. "sh/fzf.sh"
|
. "sh/fzf.sh"
|
||||||
|
|
||||||
|
# Load keys
|
||||||
|
. "sh/keys.sh"
|
||||||
|
|
||||||
# Command-line options that may only be used internally.
|
# Command-line options that may only be used internally.
|
||||||
# --lines
|
# --lines
|
||||||
# --playback
|
# --playback
|
||||||
@@ -89,7 +92,8 @@ MODE_INSERT="show"
|
|||||||
# --action-gotoartist
|
# --action-gotoartist
|
||||||
# --action-draw
|
# --action-draw
|
||||||
# --mbsearch
|
# --mbsearch
|
||||||
# --preview-artist
|
# --preview
|
||||||
|
# --show-keybindings
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
"--lines")
|
"--lines")
|
||||||
# Print lines that are fed into fzf.
|
# Print lines that are fed into fzf.
|
||||||
@@ -270,7 +274,7 @@ case "${1:-}" in
|
|||||||
[ "$q" ] && q="$q "
|
[ "$q" ] && q="$q "
|
||||||
printf "show-input+change-query(%s)" "$q"
|
printf "show-input+change-query(%s)" "$q"
|
||||||
# Store current state
|
# Store current state
|
||||||
printf "+change-border-label(%s)+change-list-label(%s)" "$view" "$mbid"
|
printf "+change-list-label(%s)" "$view"
|
||||||
# Set header
|
# Set header
|
||||||
fzf_command_set_header "$view" "$mbid"
|
fzf_command_set_header "$view" "$mbid"
|
||||||
# Set preview window
|
# Set preview window
|
||||||
@@ -301,14 +305,26 @@ case "${1:-}" in
|
|||||||
mb_search_async "$2"
|
mb_search_async "$2"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"--preview-artist")
|
"--preview")
|
||||||
# Generate content for artist preview
|
# Generate content for preview window
|
||||||
#
|
#
|
||||||
# @argument $2: MusicBrainz Artist ID
|
# @argument $2: view
|
||||||
|
# @argument $3: MusicBrainz ID of selected item
|
||||||
#
|
#
|
||||||
# This prints the text to be displayed in the preview window for the
|
# This prints the text to be displayed in the preview window.
|
||||||
# specified artist.
|
view=$2
|
||||||
preview_artist "$2"
|
mbid="${3:-}"
|
||||||
|
case "$view" in
|
||||||
|
"$VIEW_LIST_ARTISTS" | "$VIEW_SEARCH_ARTIST" | "$VIEW_SELECT_ARTIST") preview_artist "$mbid" ;;
|
||||||
|
*) preview_nothing ;;
|
||||||
|
esac
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
"--show-keybindings")
|
||||||
|
# Print keybindings for current view
|
||||||
|
#
|
||||||
|
# @argument $2: view
|
||||||
|
print_keybindings "$2"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -344,6 +360,21 @@ case "${1:-}" in
|
|||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
"--decorate-as")
|
||||||
|
# Decorate the specified directory as given MusicBrainz release
|
||||||
|
#
|
||||||
|
# @argument $2: path
|
||||||
|
# @argument $3: MusicBrainz release ID
|
||||||
|
[ ! "${2:-}" ] && err "You did not specify a directory." && exit 1
|
||||||
|
[ ! -d "$2" ] && err "Path $2 does not point to a directory." && exit 1
|
||||||
|
[ ! "${3:-}" ] && err "You did not specify a MusicBrainz release ID." && exit 1
|
||||||
|
[ ! "$(mb_release "$3" | $JQ '.title // ""')" ] && err "Did you specify a correct MusicBrainz release ID?" && exit 1
|
||||||
|
if ! decorate_as "$2" "$3"; then
|
||||||
|
err "Something went wrong."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
"--reload-database")
|
"--reload-database")
|
||||||
# Reload database of local music
|
# Reload database of local music
|
||||||
#
|
#
|
||||||
@@ -376,6 +407,7 @@ GENERAL OPTIONS:
|
|||||||
|
|
||||||
MANAGE LOCAL MUSIC:
|
MANAGE LOCAL MUSIC:
|
||||||
--decorate <path> Decorate directory containing a tagged release
|
--decorate <path> Decorate directory containing a tagged release
|
||||||
|
--decorate-as <path> <mbid> Decorate directory as the relase <mbid>
|
||||||
--reload-database <path> Populate database with decorated local music from <path>
|
--reload-database <path> Populate database with decorated local music from <path>
|
||||||
EOF
|
EOF
|
||||||
exit 0
|
exit 0
|
||||||
@@ -432,7 +464,6 @@ esac
|
|||||||
|
|
||||||
# Start application:
|
# Start application:
|
||||||
# - load and export preset filters
|
# - load and export preset filters
|
||||||
# - load and export keys
|
|
||||||
# - set title
|
# - set title
|
||||||
# - check for missing data from MusicBrainz
|
# - check for missing data from MusicBrainz
|
||||||
# - precompute main views
|
# - precompute main views
|
||||||
@@ -443,9 +474,6 @@ esac
|
|||||||
# Load filters
|
# Load filters
|
||||||
. "sh/filter.sh"
|
. "sh/filter.sh"
|
||||||
|
|
||||||
# Load keys
|
|
||||||
. "sh/keys.sh"
|
|
||||||
|
|
||||||
# Set window title
|
# Set window title
|
||||||
printf '\033]0;%s\007' "$WINDOW_TITLE"
|
printf '\033]0;%s\007' "$WINDOW_TITLE"
|
||||||
|
|
||||||
@@ -474,17 +502,17 @@ mpv_start
|
|||||||
# mode, we call `hide-input`. To switch to insert mode, we call `show-input`.
|
# mode, we call `hide-input`. To switch to insert mode, we call `show-input`.
|
||||||
#
|
#
|
||||||
# view: [$VIEW_*]
|
# view: [$VIEW_*]
|
||||||
# The view is stored in $FZF_BORDER_LABEL. To set the view, call
|
# The view is stored in $FZF_LIST_LABEL. To set the view, call
|
||||||
# `change-border-label($VIEW)`.
|
# `change-list-label($VIEW)`.
|
||||||
#
|
#
|
||||||
# argument: string
|
# argument: string
|
||||||
# The argument is stored in $FZF_LIST_LABEL. To set the argument, call
|
# The argument is stored in $FZF_LIST_LABEL. To set the argument, call
|
||||||
# `change-list-label($arg)`.
|
# `change-list-label($arg)`.
|
||||||
IN_NORMAL_MODE="[ \$FZF_INPUT_STATE = hidden ]"
|
IN_NORMAL_MODE="[ \$FZF_INPUT_STATE = hidden ]"
|
||||||
IN_VIEW_PATTERN="[ \$FZF_BORDER_LABEL = %s ]"
|
IN_VIEW_PATTERN="[ \$FZF_LIST_LABEL = %s ]"
|
||||||
IN_LIST_ARTISTS_VIEW="$(printf "$IN_VIEW_PATTERN" "$VIEW_LIST_ARTISTS")"
|
IN_LIST_ARTISTS_VIEW="$(printf "$IN_VIEW_PATTERN" "$VIEW_LIST_ARTISTS")"
|
||||||
FZF_CURRENT_MODE="\$FZF_INPUT_STATE"
|
FZF_CURRENT_MODE="\$FZF_INPUT_STATE"
|
||||||
FZF_CURRENT_VIEW="\$FZF_BORDER_LABEL"
|
FZF_CURRENT_VIEW="\$FZF_LIST_LABEL"
|
||||||
FZF_RELOAD_PLAYLIST="reload-sync($0 --lines $VIEW_PLAYLIST)"
|
FZF_RELOAD_PLAYLIST="reload-sync($0 --lines $VIEW_PLAYLIST)"
|
||||||
FZF_POS_PLAYLIST="transform:$0 --action-playlistcursor"
|
FZF_POS_PLAYLIST="transform:$0 --action-playlistcursor"
|
||||||
PUT_FZF_KEY_LOGIC="case \$FZF_KEY in space) echo \"put( )\";; left) echo backward-char;; right) echo forward-char;; backspace|bspace|bs) echo backward-delete-char;; delete|del) echo delete-char;; *) echo \"put(\$FZF_KEY)\";; esac"
|
PUT_FZF_KEY_LOGIC="case \$FZF_KEY in space) echo \"put( )\";; left) echo backward-char;; right) echo forward-char;; backspace|bspace|bs) echo backward-delete-char;; delete|del) echo delete-char;; *) echo \"put(\$FZF_KEY)\";; esac"
|
||||||
@@ -505,13 +533,20 @@ while true; do
|
|||||||
--bind="$KEYS_SEARCH_ALBUM:print($VIEW_SEARCH_ALBUM)+accept" \
|
--bind="$KEYS_SEARCH_ALBUM:print($VIEW_SEARCH_ALBUM)+accept" \
|
||||||
--bind="$KEYS_BROWSE:execute-silent:open \"https://musicbrainz.org/artist/{r3}\"" \
|
--bind="$KEYS_BROWSE:execute-silent:open \"https://musicbrainz.org/artist/{r3}\"" \
|
||||||
--bind="$KEYS_SHOW_PLAYLIST:print($VIEW_PLAYLIST)+print()+accept" \
|
--bind="$KEYS_SHOW_PLAYLIST:print($VIEW_PLAYLIST)+print()+accept" \
|
||||||
|
--bind="$KEYS_KEYBINDINGS:preview:$0 --show-keybindings $VIEW_SELECT_ARTIST" \
|
||||||
|
--bind="$KEYS_SCROLL_PREVIEW_DOWN:preview-down" \
|
||||||
|
--bind="$KEYS_SCROLL_PREVIEW_UP:preview-up" \
|
||||||
|
--bind="$KEYS_PREVIEW_OPEN:show-preview" \
|
||||||
|
--bind="$KEYS_PREVIEW_CLOSE:hide-preview" \
|
||||||
|
--bind="$KEYS_FILTER_LOCAL:change-query($QUERY_LOCAL )" \
|
||||||
-0 -1 \
|
-0 -1 \
|
||||||
--border="bold" \
|
--border="bold" \
|
||||||
--border-label="Select artist" \
|
--border-label="Select artist" \
|
||||||
|
--preview-window="right,25%,border-left,wrap,<30(hidden)" \
|
||||||
|
--preview="$0 --preview $VIEW_SELECT_ARTIST {3}" \
|
||||||
--delimiter="\t" \
|
--delimiter="\t" \
|
||||||
--prompt="$SEARCH_PROMPT" \
|
--prompt="$SEARCH_PROMPT" \
|
||||||
--margin="5%,20%" \
|
--margin="5%,20%" \
|
||||||
--bind="$KEYS_FILTER_LOCAL:change-query('$QUERY_LOCAL' )" \
|
|
||||||
--accept-nth="{3}" \
|
--accept-nth="{3}" \
|
||||||
--with-nth="{1}" || true
|
--with-nth="{1}" || true
|
||||||
)
|
)
|
||||||
@@ -549,6 +584,12 @@ while true; do
|
|||||||
--bind="$KEYS_SEARCH_ALBUM:print($VIEW_SEARCH_ALBUM)+accept" \
|
--bind="$KEYS_SEARCH_ALBUM:print($VIEW_SEARCH_ALBUM)+accept" \
|
||||||
--bind="$KEYS_BROWSE:execute-silent:open \"https://musicbrainz.org/\track/{r3}\"" \
|
--bind="$KEYS_BROWSE:execute-silent:open \"https://musicbrainz.org/\track/{r3}\"" \
|
||||||
--bind="$KEYS_OPEN:execute-silent:open \"\$(dirname {4})\"" \
|
--bind="$KEYS_OPEN:execute-silent:open \"\$(dirname {4})\"" \
|
||||||
|
--bind="$KEYS_N_YANK:execute-silent:printf {3} | $CLIP)" \
|
||||||
|
--bind="$KEYS_YANK_CURRENT:execute-silent:printf {2} | $CLIP" \
|
||||||
|
--bind="$KEYS_KEYBINDINGS:preview:$0 --show-keybindings $VIEW_PLAYLIST" \
|
||||||
|
--bind="$KEYS_SCROLL_PREVIEW_DOWN:preview-down" \
|
||||||
|
--bind="$KEYS_SCROLL_PREVIEW_UP:preview-up" \
|
||||||
|
--bind="$KEYS_PREVIEW_CLOSE:hide-preview" \
|
||||||
--bind="$KEYS_PLAYBACK,$KEYS_N_PLAYBACK:transform($0 --playback $VIEW_PLAYLIST {2} {3} {4})+$FZF_RELOAD_PLAYLIST+$FZF_POS_PLAYLIST" \
|
--bind="$KEYS_PLAYBACK,$KEYS_N_PLAYBACK:transform($0 --playback $VIEW_PLAYLIST {2} {3} {4})+$FZF_RELOAD_PLAYLIST+$FZF_POS_PLAYLIST" \
|
||||||
--bind="$KEYS_PLAYLIST_RELOAD:$FZF_RELOAD_PLAYLIST+$FZF_POS_PLAYLIST" \
|
--bind="$KEYS_PLAYLIST_RELOAD:$FZF_RELOAD_PLAYLIST+$FZF_POS_PLAYLIST" \
|
||||||
--bind="$KEYS_PLAYLIST_REMOVE:execute-silent($0 --playlist $PLAYLIST_CMD_REMOVE)+$FZF_RELOAD_PLAYLIST" \
|
--bind="$KEYS_PLAYLIST_REMOVE:execute-silent($0 --playlist $PLAYLIST_CMD_REMOVE)+$FZF_RELOAD_PLAYLIST" \
|
||||||
@@ -586,7 +627,7 @@ while true; do
|
|||||||
# `$PUT_FZF_KEY_LOGIC` for details.
|
# `$PUT_FZF_KEY_LOGIC` for details.
|
||||||
#
|
#
|
||||||
# Here is a list of all keys grouped by type (see `src/sh/keys.sh`).
|
# Here is a list of all keys grouped by type (see `src/sh/keys.sh`).
|
||||||
#--bind="start:change-border-label($VIEW)+change-list-label($MBID)+$MODE-input+transform:$0 --display" \
|
#--bind="start:change-list-label($VIEW)+change-list-label($MBID)+$MODE-input+transform:$0 --display" \
|
||||||
sel=$(
|
sel=$(
|
||||||
printf "" | $FZF \
|
printf "" | $FZF \
|
||||||
--reverse \
|
--reverse \
|
||||||
@@ -628,7 +669,7 @@ esac" \
|
|||||||
--bind="$KEYS_FILTER:transform:$0 --action-filter $FZF_CURRENT_MODE $FZF_CURRENT_VIEW" \
|
--bind="$KEYS_FILTER:transform:$0 --action-filter $FZF_CURRENT_MODE $FZF_CURRENT_VIEW" \
|
||||||
--bind="$KEYS_BROWSE:execute-silent:
|
--bind="$KEYS_BROWSE:execute-silent:
|
||||||
[ {3} ] || exit 0
|
[ {3} ] || exit 0
|
||||||
case \$FZF_BORDER_LABEL in
|
case $FZF_CURRENT_VIEW in
|
||||||
$VIEW_LIST_ARTISTS | $VIEW_SEARCH_ARTIST) t=artist ;;
|
$VIEW_LIST_ARTISTS | $VIEW_SEARCH_ARTIST) t=artist ;;
|
||||||
$VIEW_ARTIST | $VIEW_SEARCH_ALBUM | $VIEW_LIST_ALBUMS) t=release-group ;;
|
$VIEW_ARTIST | $VIEW_SEARCH_ALBUM | $VIEW_LIST_ALBUMS) t=release-group ;;
|
||||||
$VIEW_RELEASEGROUP) t=release ;;
|
$VIEW_RELEASEGROUP) t=release ;;
|
||||||
@@ -641,13 +682,19 @@ open \"\$(dirname {4})\"" \
|
|||||||
--bind="$KEYS_N_YANK:transform:$IN_NORMAL_MODE && echo \"execute-silent(printf {3} | $CLIP)\" || $PUT_FZF_KEY_LOGIC" \
|
--bind="$KEYS_N_YANK:transform:$IN_NORMAL_MODE && echo \"execute-silent(printf {3} | $CLIP)\" || $PUT_FZF_KEY_LOGIC" \
|
||||||
--bind="$KEYS_YANK_CURRENT:execute-silent:printf {2} | $CLIP" \
|
--bind="$KEYS_YANK_CURRENT:execute-silent:printf {2} | $CLIP" \
|
||||||
--bind="$KEYS_SHOW_PLAYLIST:transform:echo \"print($VIEW_PLAYLIST)+print()+print($FZF_CURRENT_VIEW)+print({2})+accept\"" \
|
--bind="$KEYS_SHOW_PLAYLIST:transform:echo \"print($VIEW_PLAYLIST)+print()+print($FZF_CURRENT_VIEW)+print({2})+accept\"" \
|
||||||
|
--bind="$KEYS_KEYBINDINGS:preview:$0 --show-keybindings $FZF_CURRENT_VIEW" \
|
||||||
--bind="$KEYS_QUIT:print($VIEW_QUIT)+accept" \
|
--bind="$KEYS_QUIT:print($VIEW_QUIT)+accept" \
|
||||||
--bind="$KEYS_N_QUIT:transform:$IN_NORMAL_MODE && ($IN_LIST_ARTISTS_VIEW && echo \"print($VIEW_QUIT)+accept\" || $0 --action-draw $MODE_NORMAL $VIEW_LIST_ARTISTS) || $PUT_FZF_KEY_LOGIC" \
|
--bind="$KEYS_N_QUIT:transform:$IN_NORMAL_MODE && ($IN_LIST_ARTISTS_VIEW && echo \"print($VIEW_QUIT)+accept\" || $0 --action-draw $MODE_NORMAL $VIEW_LIST_ARTISTS) || $PUT_FZF_KEY_LOGIC" \
|
||||||
|
--bind="$KEYS_SCROLL_PREVIEW_DOWN:preview-down" \
|
||||||
|
--bind="$KEYS_SCROLL_PREVIEW_UP:preview-up" \
|
||||||
|
--bind="$KEYS_PREVIEW_OPEN:show-preview" \
|
||||||
|
--bind="$KEYS_PREVIEW_CLOSE:hide-preview" \
|
||||||
--bind="$KEYS_PLAYBACK:transform:$0 --playback $FZF_CURRENT_VIEW {2} {3} {4}" \
|
--bind="$KEYS_PLAYBACK:transform:$0 --playback $FZF_CURRENT_VIEW {2} {3} {4}" \
|
||||||
--bind="$KEYS_N_PLAYBACK:transform:$IN_NORMAL_MODE && $0 --playback $FZF_CURRENT_VIEW {2} {3} {4} || $PUT_FZF_KEY_LOGIC" \
|
--bind="$KEYS_N_PLAYBACK:transform:$IN_NORMAL_MODE && $0 --playback $FZF_CURRENT_VIEW {2} {3} {4} || $PUT_FZF_KEY_LOGIC" \
|
||||||
|
--bind="W:execute-silent:echo 1 >> /tmp/foo; echo $FZF_CURRENT_VIEW >> /tmp/foo; echo 2 >> /tmp/foo" \
|
||||||
--bind="change:execute-silent($0 --mbsearch $FZF_CURRENT_VIEW &)+reload:$0 --lines $FZF_CURRENT_VIEW" \
|
--bind="change:execute-silent($0 --mbsearch $FZF_CURRENT_VIEW &)+reload:$0 --lines $FZF_CURRENT_VIEW" \
|
||||||
--preview-window="right,25%,border-left,wrap,<30(hidden)" \
|
--preview-window="right,25%,border-left,wrap,<30(hidden)" \
|
||||||
--preview="$0 --preview-artist {3}" \
|
--preview="$0 --preview $FZF_CURRENT_VIEW {3}" \
|
||||||
--delimiter="\t" \
|
--delimiter="\t" \
|
||||||
--with-nth="{1}" || true
|
--with-nth="{1}" || true
|
||||||
)
|
)
|
||||||
|
@@ -103,6 +103,8 @@ __api_mb() {
|
|||||||
errormsg=$($JQ -e '.error // ""' "$tmpout")
|
errormsg=$($JQ -e '.error // ""' "$tmpout")
|
||||||
if [ "$errormsg" ]; then
|
if [ "$errormsg" ]; then
|
||||||
err "Failed to fetch MusicBrainz data for $1 $2: $errormsg"
|
err "Failed to fetch MusicBrainz data for $1 $2: $errormsg"
|
||||||
|
echo "$errormsg" | grep -q -i "not found" && break
|
||||||
|
echo "$errormsg" | grep -q -i "invalid" && break
|
||||||
sleep "$SLEEP_ON_ERROR"
|
sleep "$SLEEP_ON_ERROR"
|
||||||
else
|
else
|
||||||
cat "$tmpout"
|
cat "$tmpout"
|
||||||
|
@@ -12,21 +12,38 @@ fzf_command_set_header() {
|
|||||||
"$VIEW_LIST_ALBUMS") header="Search locally available album" ;;
|
"$VIEW_LIST_ALBUMS") header="Search locally available album" ;;
|
||||||
"$VIEW_ARTIST")
|
"$VIEW_ARTIST")
|
||||||
name="$(mb_artist "$mbid" | $JQ '.name')"
|
name="$(mb_artist "$mbid" | $JQ '.name')"
|
||||||
header=$(printf "$ARTIST_PROMPT" "$name")
|
header=$(printf "$HEADER_ARTIST" "$name")
|
||||||
;;
|
;;
|
||||||
"$VIEW_RELEASEGROUP")
|
"$VIEW_RELEASEGROUP")
|
||||||
title="$(mb_releasegroup "$mbid" |
|
title="$(mb_releasegroup "$mbid" |
|
||||||
$JQ '.title')"
|
$JQ '.title')"
|
||||||
artist="$(mb_releasegroup "$mbid" |
|
artist="$(mb_releasegroup "$mbid" |
|
||||||
$JQ '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
|
$JQ '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
|
||||||
header=$(printf "$FULL_PROMPT" "$artist" "$title")
|
header=$(printf "$HEADER_ARTIST_RELEASEGROUP" "$artist" "$title")
|
||||||
;;
|
;;
|
||||||
"$VIEW_RELEASE")
|
"$VIEW_RELEASE")
|
||||||
title="$(mb_release "$mbid" |
|
title="$(mb_release "$mbid" |
|
||||||
$JQ '.title')"
|
$JQ '.title')"
|
||||||
artist="$(mb_release "$mbid" |
|
artist="$(mb_release "$mbid" |
|
||||||
$JQ '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
|
$JQ '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
|
||||||
header=$(printf "$FULL_PROMPT" "$artist" "$title")
|
releaseinfo="$(mb_release "$mbid" |
|
||||||
|
$JQ '[
|
||||||
|
.date[:4],
|
||||||
|
(."label-info" | map(.label.name) | unique | join(", ")),
|
||||||
|
(.media | map(."track-count") | add),
|
||||||
|
(.media | map(.format) | unique | join(", ")),
|
||||||
|
.country
|
||||||
|
] | join("\t")' |
|
||||||
|
awk -F "\t" -v format="$HEADER_RELEASE_FORMAT" '{
|
||||||
|
gsub("&", "\\\\&")
|
||||||
|
sub("<<year>>", $1, format)
|
||||||
|
sub("<<label>>", $2, format)
|
||||||
|
sub("<<tracks>>", $3, format)
|
||||||
|
sub("<<media>>", $4, format)
|
||||||
|
sub("<<country>>", $5, format)
|
||||||
|
print format
|
||||||
|
}')"
|
||||||
|
header=$(printf "$HEADER_RELEASE" "$artist" "$title" "$releaseinfo")
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
printf "+change-header(%s)" "${header:-"???"}"
|
printf "+change-header(%s)" "${header:-"???"}"
|
||||||
|
396
src/sh/keys.sh
396
src/sh/keys.sh
@@ -51,9 +51,14 @@
|
|||||||
# - KEYS_N_YANK: Copy MusicBrainz ID of selected item to clipboard
|
# - KEYS_N_YANK: Copy MusicBrainz ID of selected item to clipboard
|
||||||
# - KEYS_YANK_CURRENT: Copy MusicBrainz ID of current item to clipboard
|
# - KEYS_YANK_CURRENT: Copy MusicBrainz ID of current item to clipboard
|
||||||
# - KEYS_SHOW_PLAYLIST: Switch to playlist view
|
# - KEYS_SHOW_PLAYLIST: Switch to playlist view
|
||||||
|
# - KEYS_KEYBINDINGS: Show keybindings
|
||||||
# - KEYS_QUIT: Quit application
|
# - KEYS_QUIT: Quit application
|
||||||
# - KEYS_N_QUIT: Quit application if we are in VIEW_LIST_ARTISTS, else go to
|
# - KEYS_N_QUIT: Quit application if we are in VIEW_LIST_ARTISTS, else go to
|
||||||
# view VIEW_LIST_ARTISTS (normal mode)
|
# view VIEW_LIST_ARTISTS (normal mode)
|
||||||
|
# - KEYS_SCROLL_PREVIEW_DOWN: Scroll preview down
|
||||||
|
# - KEYS_SCROLL_PREVIEW_UP: Scroll preview up
|
||||||
|
# - KEYS_PREVIEW_OPEN: Open preview window
|
||||||
|
# - KEYS_PREVIEW_CLOSE: Close preview window
|
||||||
#
|
#
|
||||||
# Playback:
|
# Playback:
|
||||||
# - KEYS_PLAY: Play selected release or selected track
|
# - KEYS_PLAY: Play selected release or selected track
|
||||||
@@ -80,108 +85,293 @@
|
|||||||
# - KEYS_PLAYLIST_STORE: Store current playlist as file
|
# - KEYS_PLAYLIST_STORE: Store current playlist as file
|
||||||
# - KEYS_PLAYLIST_LOAD: Load playlist from file
|
# - KEYS_PLAYLIST_LOAD: Load playlist from file
|
||||||
# - KEYS_PLAYLIST_QUIT: Quit playlist view
|
# - KEYS_PLAYLIST_QUIT: Quit playlist view
|
||||||
|
|
||||||
|
if [ ! "${KEYS_LOADED:-}" ]; then
|
||||||
|
# Mode selection:
|
||||||
|
KEYS_I_NORMAL="${KEYS_I_NORMAL:-"esc"}"
|
||||||
|
KEYS_N_INSERT="${KEYS_N_INSERT:-"a,i,/,?"}"
|
||||||
|
export KEYS_I_NORMAL KEYS_N_INSERT
|
||||||
|
|
||||||
|
# Vertical navigation:
|
||||||
|
KEYS_DOWN="${KEYS_DOWN:-"ctrl-j,down"}"
|
||||||
|
KEYS_UP="${KEYS_UP:-"ctrl-k,up"}"
|
||||||
|
KEYS_HALFPAGE_DOWN="${KEYS_HALFPAGE_DOWN:-"ctrl-d"}"
|
||||||
|
KEYS_HALFPAGE_UP="${KEYS_HALFPAGE_UP:-"ctrl-u"}"
|
||||||
|
KEYS_N_DOWN="${KEYS_N_DOWN:-"j"}"
|
||||||
|
KEYS_N_UP="${KEYS_N_UP:-"k"}"
|
||||||
|
KEYS_N_BOT="${KEYS_N_BOT:-"G"}"
|
||||||
|
KEYS_N_TOP="${KEYS_N_TOP:-"1"}"
|
||||||
|
export KEYS_DOWN KEYS_UP KEYS_HALFPAGE_DOWN KEYS_HALFPAGE_UP KEYS_N_DOWN \
|
||||||
|
KEYS_N_UP KEYS_N_BOT KEYS_N_TOP
|
||||||
|
|
||||||
|
# Horizontal navigation:
|
||||||
|
KEYS_IN="${KEYS_IN:-"ctrl-l"}"
|
||||||
|
KEYS_OUT="${KEYS_OUT:-"ctrl-h"}"
|
||||||
|
KEYS_N_IN="${KEYS_N_IN:-"l"}"
|
||||||
|
KEYS_N_OUT="${KEYS_N_OUT:-"h"}"
|
||||||
|
KEYS_SELECT_ARTIST="${KEYS_SELECT_ARTIST:-"ctrl-a"}"
|
||||||
|
KEYS_LIST_ARTISTS="${KEYS_LIST_ARTISTS:-"alt-a"}"
|
||||||
|
KEYS_LIST_ALBUMS="${KEYS_LIST_ALBUMS:-"alt-s"}"
|
||||||
|
KEYS_SEARCH_ARTIST="${KEYS_SEARCH_ARTIST:-"alt-z"}"
|
||||||
|
KEYS_SEARCH_ALBUM="${KEYS_SEARCH_ALBUM:-"alt-x"}"
|
||||||
|
KEYS_SWITCH_ARTIST_ALBUM="${KEYS_SWITCH_ARTIST_ALBUM:-"tab"}"
|
||||||
|
KEYS_SWITCH_LOCAL_REMOTE="${KEYS_SWITCH_LOCAL_REMOTE:-"ctrl-/"}"
|
||||||
|
export KEYS_IN KEYS_OUT KEYS_N_IN KEYS_N_OUT KEYS_SELECT_ARTIST \
|
||||||
|
KEYS_LIST_ARTISTS KEYS_LIST_ALBUMS KEYS_SEARCH_ARTIST KEYS_SEARCH_ALBUM \
|
||||||
|
KEYS_SWITCH_ARTIST_ALBUM KEYS_SWITCH_LOCAL_REMOTE
|
||||||
|
|
||||||
|
# Filtering:
|
||||||
|
KEYS_FILTER_LOCAL="${KEYS_FILTER_LOCAL:-"alt-l"}"
|
||||||
|
KEYS_FILTER_1="${KEYS_FILTER_1:-"alt-1"}"
|
||||||
|
KEYS_FILTER_2="${KEYS_FILTER_2:-"alt-2"}"
|
||||||
|
KEYS_FILTER_3="${KEYS_FILTER_3:-"alt-3"}"
|
||||||
|
KEYS_FILTER_4="${KEYS_FILTER_4:-"alt-4"}"
|
||||||
|
KEYS_FILTER_5="${KEYS_FILTER_5:-"alt-5"}"
|
||||||
|
KEYS_FILTER_6="${KEYS_FILTER_6:-"alt-6"}"
|
||||||
|
KEYS_FILTER_7="${KEYS_FILTER_7:-"alt-7"}"
|
||||||
|
KEYS_FILTER_8="${KEYS_FILTER_8:-"alt-8"}"
|
||||||
|
KEYS_FILTER_9="${KEYS_FILTER_9:-"alt-9"}"
|
||||||
|
KEYS_FILTER_0="${KEYS_FILTER_0:-"alt-0"}"
|
||||||
|
KEYS_FILTER="$KEYS_FILTER_LOCAL,$KEYS_FILTER_1,$KEYS_FILTER_2,$KEYS_FILTER_3,$KEYS_FILTER_4,$KEYS_FILTER_5,$KEYS_FILTER_6,$KEYS_FILTER_7,$KEYS_FILTER_8,$KEYS_FILTER_9,$KEYS_FILTER_0"
|
||||||
|
export KEYS_FILTER_LOCAL KEYS_FILTER_1 KEYS_FILTER_2 KEYS_FILTER_3 \
|
||||||
|
KEYS_FILTER_4 KEYS_FILTER_5 KEYS_FILTER_6 KEYS_FILTER_7 KEYS_FILTER_8 \
|
||||||
|
KEYS_FILTER_9 KEYS_FILTER_0 KEYS_FILTER
|
||||||
|
|
||||||
|
# Specials:
|
||||||
|
KEYS_BROWSE="${KEYS_BROWSE:-"alt-b"}"
|
||||||
|
KEYS_OPEN="${KEYS_OPEN:-"alt-o"}"
|
||||||
|
KEYS_N_YANK="${KEYS_N_YANK:-"y"}"
|
||||||
|
KEYS_YANK_CURRENT="${KEYS_YANK_CURRENT:-"ctrl-y"}"
|
||||||
|
KEYS_SHOW_PLAYLIST="${KEYS_SHOW_PLAYLIST:-"ctrl-p"}"
|
||||||
|
KEYS_KEYBINDINGS="${KEYS_KEYBINDINGS:-"alt-?"}"
|
||||||
|
KEYS_QUIT="${KEYS_QUIT:-"ctrl-c"}"
|
||||||
|
KEYS_N_QUIT="${KEYS_N_QUIT:-"q"}"
|
||||||
|
KEYS_SCROLL_PREVIEW_DOWN="${KEYS_SCROLL_PREVIEW_DOWN:-"page-down"}"
|
||||||
|
KEYS_SCROLL_PREVIEW_UP="${KEYS_SCROLL_PREVIEW_UP:-"page-up"}"
|
||||||
|
KEYS_PREVIEW_OPEN="${KEYS_PREVIEW_OPEN:-"alt-up"}"
|
||||||
|
KEYS_PREVIEW_CLOSE="${KEYS_PREVIEW_CLOSE:-"alt-down"}"
|
||||||
|
export KEYS_BROWSE KEYS_OPEN KEYS_N_YANK KEYS_YANK_CURRENT KEYS_SHOW_PLAYLIST \
|
||||||
|
KEYS_KEYBINDINGS KEYS_QUIT KEYS_N_QUIT KEYS_SCROLL_PREVIEW_DOWN \
|
||||||
|
KEYS_SCROLL_PREVIEW_UP KEYS_PREVIEW_CLOSE KEYS_PREVIEW_OPEN
|
||||||
|
|
||||||
|
# Playback:
|
||||||
|
KEYS_PLAY="${KEYS_PLAY:-"enter"}"
|
||||||
|
KEYS_QUEUE="${KEYS_QUEUE:-"ctrl-alt-m"}" # That's actually alt-enter
|
||||||
|
KEYS_QUEUE_NEXT="${KEYS_QUEUE_NEXT:-"ctrl-alt-n"}"
|
||||||
|
KEYS_TOGGLE_PLAYBACK="${KEYS_TOGGLE_PLAYBACK:-"ctrl-space"}"
|
||||||
|
KEYS_PLAY_NEXT="${KEYS_PLAY_NEXT:-"alt-n"}"
|
||||||
|
KEYS_PLAY_PREV="${KEYS_PLAY_PREV:-"alt-p"}"
|
||||||
|
KEYS_SEEK_FORWARD="${KEYS_SEEK_FORWARD:-"alt-N"}"
|
||||||
|
KEYS_SEEK_BACKWARD="${KEYS_SEEK_BACKWARD:-"alt-P"}"
|
||||||
|
KEYS_PLAYBACK="$KEYS_PLAY,$KEYS_QUEUE,$KEYS_QUEUE_NEXT,$KEYS_TOGGLE_PLAYBACK,$KEYS_PLAY_NEXT,$KEYS_PLAY_PREV,$KEYS_SEEK_FORWARD,$KEYS_SEEK_BACKWARD"
|
||||||
|
KEYS_N_PLAY="${KEYS_N_PLAY:-"."}"
|
||||||
|
KEYS_N_QUEUE="${KEYS_N_QUEUE:-";"}"
|
||||||
|
KEYS_N_QUEUE_NEXT="${KEYS_N_QUEUE_NEXT:-":"}"
|
||||||
|
KEYS_N_TOGGLE_PLAYBACK="${KEYS_N_TOGGLE_PLAYBACK:-"space"}"
|
||||||
|
KEYS_N_PLAY_NEXT="${KEYS_N_PLAY_NEXT:-"right,n"}"
|
||||||
|
KEYS_N_PLAY_PREV="${KEYS_N_PLAY_PREV:-"left,p"}"
|
||||||
|
KEYS_N_SEEK_FORWARD="${KEYS_N_SEEK_FORWARD:-"N,f"}"
|
||||||
|
KEYS_N_SEEK_BACKWARD="${KEYS_N_SEEK_BACKWARD:-"P,b"}"
|
||||||
|
KEYS_N_PLAYBACK="$KEYS_N_PLAY,$KEYS_N_QUEUE,$KEYS_N_QUEUE_NEXT,$KEYS_N_TOGGLE_PLAYBACK,$KEYS_N_PLAY_NEXT,$KEYS_N_PLAY_PREV,$KEYS_N_SEEK_FORWARD,$KEYS_N_SEEK_BACKWARD"
|
||||||
|
export KEYS_PLAY KEYS_QUEUE KEYS_QUEUE_NEXT KEYS_TOGGLE_PLAYBACK \
|
||||||
|
KEYS_PLAY_NEXT KEYS_PLAY_PREV KEYS_SEEK_FORWARD KEYS_SEEK_BACKWARD \
|
||||||
|
KEYS_PLAYBACK KEYS_N_PLAY KEYS_N_QUEUE KEYS_N_QUEUE_NEXT \
|
||||||
|
KEYS_N_TOGGLE_PLAYBACK KEYS_N_PLAY_NEXT KEYS_N_PLAY_PREV \
|
||||||
|
KEYS_N_SEEK_FORWARD KEYS_N_SEEK_BACKWARD KEYS_N_PLAYBACK
|
||||||
|
|
||||||
|
# Playlist (in the playlist, there is no `insert` mode):
|
||||||
|
KEYS_PLAYLIST_RELOAD="${KEYS_PLAYLIST_RELOAD:-"r,ctrl-r"}"
|
||||||
|
KEYS_PLAYLIST_REMOVE="${KEYS_PLAYLIST_REMOVE:-"x,delete"}"
|
||||||
|
KEYS_PLAYLIST_UP="${KEYS_PLAYLIST_UP:-"u"}"
|
||||||
|
KEYS_PLAYLIST_DOWN="${KEYS_PLAYLIST_DOWN:-"d"}"
|
||||||
|
KEYS_PLAYLIST_CLEAR="${KEYS_PLAYLIST_CLEAR:-"C"}"
|
||||||
|
KEYS_PLAYLIST_CLEAR_ABOVE="${KEYS_PLAYLIST_CLEAR_ABOVE:-"U"}"
|
||||||
|
KEYS_PLAYLIST_CLEAR_BELOW="${KEYS_PLAYLIST_CLEAR_BELOW:-"D"}"
|
||||||
|
KEYS_PLAYLIST_SHUFFLE="${KEYS_PLAYLIST_SHUFFLE:-"s"}"
|
||||||
|
KEYS_PLAYLIST_UNSHUFFLE="${KEYS_PLAYLIST_UNSHUFFLE:-"S"}"
|
||||||
|
KEYS_PLAYLIST_GOTO_RELEASE="${KEYS_PLAYLIST_GOTO_RELEASE:-"ctrl-g"}"
|
||||||
|
KEYS_PLAYLIST_STORE="${KEYS_PLAYLIST_STORE:-"ctrl-s"}"
|
||||||
|
KEYS_PLAYLIST_LOAD="${KEYS_PLAYLIST_LOAD:-"ctrl-o"}"
|
||||||
|
export KEYS_PLAYLIST_RELOAD KEYS_PLAYLIST_REMOVE KEYS_PLAYLIST_UP \
|
||||||
|
KEYS_PLAYLIST_DOWN KEYS_PLAYLIST_CLEAR KEYS_PLAYLIST_CLEAR_ABOVE \
|
||||||
|
KEYS_PLAYLIST_CLEAR_BELOW KEYS_PLAYLIST_SHUFFLE KEYS_PLAYLIST_UNSHUFFLE \
|
||||||
|
KEYS_PLAYLIST_GOTO_RELEASE KEYS_PLAYLIST_STORE KEYS_PLAYLIST_LOAD
|
||||||
|
|
||||||
|
export KEYS_LOADED=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Local method to print keybindin groups
|
||||||
#
|
#
|
||||||
|
# @argument $1: Group name
|
||||||
|
# @argument $2: Keys for first item
|
||||||
|
# @argument $3: Description of first item
|
||||||
|
# @argument $4: Keys for second item (optional)
|
||||||
|
# @argument $5: Description of second item (optional)
|
||||||
|
# @argument ...
|
||||||
|
#
|
||||||
|
# This is a helper method for printing key-binding groups.
|
||||||
|
__keybindinggroup_from_args() {
|
||||||
|
printf "$KBF_GROUP\n" "$1"
|
||||||
|
shift
|
||||||
|
{
|
||||||
|
while [ "$*" ]; do
|
||||||
|
printf "$KBF_KEY:\t$KBF_DESC\n" "$1" "${2:-"no description"}"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
} | column -t -s "$(printf '\t')"
|
||||||
|
#} | column -t -s "$(printf '\t')" -c "$FZF_PREVIEW_COLUMNS" -W 2
|
||||||
|
printf "\n\n"
|
||||||
|
}
|
||||||
|
|
||||||
# Mode selection:
|
# Print view-dependent keybindings
|
||||||
KEYS_I_NORMAL="${KEYS_I_NORMAL:-"esc"}"
|
#
|
||||||
KEYS_N_INSERT="${KEYS_N_INSERT:-"a,i,/,?"}"
|
# @argument $1: view
|
||||||
export KEYS_I_NORMAL KEYS_N_INSERT
|
#
|
||||||
|
# This method pretty-prints the keybindings active at the given view.
|
||||||
# Vertical navigation:
|
print_keybindings() {
|
||||||
KEYS_DOWN="${KEYS_DOWN:-"ctrl-j,down"}"
|
view=$1
|
||||||
KEYS_UP="${KEYS_UP:-"ctrl-k,up"}"
|
case "$view" in
|
||||||
KEYS_HALFPAGE_DOWN="${KEYS_HALFPAGE_DOWN:-"ctrl-d"}"
|
"$VIEW_SELECT_ARTIST")
|
||||||
KEYS_HALFPAGE_UP="${KEYS_HALFPAGE_UP:-"ctrl-u"}"
|
__keybindinggroup_from_args "Previews" \
|
||||||
KEYS_N_DOWN="${KEYS_N_DOWN:-"j"}"
|
"$KEYS_SCROLL_PREVIEW_DOWN" "Scroll preview down" \
|
||||||
KEYS_N_UP="${KEYS_N_UP:-"k"}"
|
"$KEYS_SCROLL_PREVIEW_UP" "Scroll preview up" \
|
||||||
KEYS_N_BOT="${KEYS_N_BOT:-"G"}"
|
"$KEYS_KEYBINDINGS" "Show these keybindings" \
|
||||||
KEYS_N_TOP="${KEYS_N_TOP:-"1"}"
|
"$KEYS_PREVIEW_OPEN" "Open preview window" \
|
||||||
export KEYS_DOWN KEYS_UP KEYS_HALFPAGE_DOWN KEYS_HALFPAGE_UP KEYS_N_DOWN \
|
"$KEYS_PREVIEW_CLOSE" "Close preview window"
|
||||||
KEYS_N_UP KEYS_N_BOT KEYS_N_TOP
|
__keybindinggroup_from_args "Navigation" \
|
||||||
|
"$KEYS_DOWN" "Down" \
|
||||||
# Horizontal navigation:
|
"$KEYS_UP" "Up" \
|
||||||
KEYS_IN="${KEYS_IN:-"ctrl-l"}"
|
"$KEYS_HALFPAGE_DOWN" "Down half a page" \
|
||||||
KEYS_OUT="${KEYS_OUT:-"ctrl-h"}"
|
"$KEYS_HALFPAGE_UP" "Up half a page" \
|
||||||
KEYS_N_IN="${KEYS_N_IN:-"l"}"
|
"enter,$KEYS_IN" "Go to selected artist" \
|
||||||
KEYS_N_OUT="${KEYS_N_OUT:-"h"}"
|
"$KEYS_OUT,$KEYS_QUIT" "Return to previews view"
|
||||||
KEYS_SELECT_ARTIST="${KEYS_SELECT_ARTIST:-"ctrl-a"}"
|
__keybindinggroup_from_args "Views" \
|
||||||
KEYS_LIST_ARTISTS="${KEYS_LIST_ARTISTS:-"alt-a"}"
|
"$KEYS_LIST_ARTISTS" "Display artists in local database" \
|
||||||
KEYS_LIST_ALBUMS="${KEYS_LIST_ALBUMS:-"alt-s"}"
|
"$KEYS_LIST_ALBUMS" "Display albums in local database" \
|
||||||
KEYS_SEARCH_ARTIST="${KEYS_SEARCH_ARTIST:-"alt-z"}"
|
"$KEYS_SEARCH_ARTIST" "Show artist on MusicBrainz" \
|
||||||
KEYS_SEARCH_ALBUM="${KEYS_SEARCH_ALBUM:-"alt-x"}"
|
"$KEYS_SEARCH_ALBUM" "Show album on MusicBrainz"
|
||||||
KEYS_SWITCH_ARTIST_ALBUM="${KEYS_SWITCH_ARTIST_ALBUM:-"tab"}"
|
__keybindinggroup_from_args "Special operations" \
|
||||||
KEYS_SWITCH_LOCAL_REMOTE="${KEYS_SWITCH_LOCAL_REMOTE:-"ctrl-/"}"
|
"$KEYS_SHOW_PLAYLIST" "Show playlist" \
|
||||||
export KEYS_IN KEYS_OUT KEYS_N_IN KEYS_N_OUT KEYS_SELECT_ARTIST \
|
"$KEYS_BROWSE" "Open artist in browser"
|
||||||
KEYS_LIST_ARTISTS KEYS_SELECT_ARTIST KEYS_SEARCH_ALBUM \
|
__keybindinggroup_from_args "Filtering" \
|
||||||
KEYS_SWITCH_ARTIST_ALBUM KEYS_SWITCH_LOCAL_REMOTE
|
"$KEYS_FILTER_LOCAL" "Show only entries in local database"
|
||||||
|
;;
|
||||||
# Filtering:
|
"$VIEW_PLAYLIST")
|
||||||
KEYS_FILTER_LOCAL="${KEYS_FILTER_LOCAL:-"alt-l"}"
|
__keybindinggroup_from_args "Previews" \
|
||||||
KEYS_FILTER_1="${KEYS_FILTER_1:-"alt-1"}"
|
"$KEYS_SCROLL_PREVIEW_DOWN" "Scroll preview down" \
|
||||||
KEYS_FILTER_2="${KEYS_FILTER_2:-"alt-2"}"
|
"$KEYS_SCROLL_PREVIEW_UP" "Scroll preview up" \
|
||||||
KEYS_FILTER_3="${KEYS_FILTER_3:-"alt-3"}"
|
"$KEYS_KEYBINDINGS" "Show these keybindings" \
|
||||||
KEYS_FILTER_4="${KEYS_FILTER_4:-"alt-4"}"
|
"$KEYS_PREVIEW_CLOSE" "Close preview window"
|
||||||
KEYS_FILTER_5="${KEYS_FILTER_5:-"alt-5"}"
|
__keybindinggroup_from_args "Navigation" \
|
||||||
KEYS_FILTER_6="${KEYS_FILTER_6:-"alt-6"}"
|
"$KEYS_DOWN,$KEYS_N_DOWN" "Down" \
|
||||||
KEYS_FILTER_7="${KEYS_FILTER_7:-"alt-7"}"
|
"$KEYS_UP,$KEYS_N_UP" "Up" \
|
||||||
KEYS_FILTER_8="${KEYS_FILTER_8:-"alt-8"}"
|
"$KEYS_HALFPAGE_DOWN" "Down half a page" \
|
||||||
KEYS_FILTER_9="${KEYS_FILTER_9:-"alt-9"}"
|
"$KEYS_HALFPAGE_UP" "Up half a page" \
|
||||||
KEYS_FILTER_0="${KEYS_FILTER_0:-"alt-0"}"
|
"$KEYS_N_TOP" "Go to first entry" \
|
||||||
KEYS_FILTER="$KEYS_FILTER_LOCAL,$KEYS_FILTER_1,$KEYS_FILTER_2,$KEYS_FILTER_3,$KEYS_FILTER_4,$KEYS_FILTER_5,$KEYS_FILTER_6,$KEYS_FILTER_7,$KEYS_FILTER_8,$KEYS_FILTER_9,$KEYS_FILTER_0"
|
"$KEYS_N_BOT" "Go to last entry" \
|
||||||
export KEYS_FILTER_LOCAL KEYS_FILTER_1 KEYS_FILTER_2 KEYS_FILTER_3 \
|
"$KEYS_OUT,$KEYS_N_OUT,$KEYS_QUIT,$KEYS_N_QUIT" "Leave playlist view" \
|
||||||
KEYS_FILTER_4 KEYS_FILTER_5 KEYS_FILTER_6 KEYS_FILTER_7 KEYS_FILTER_8 \
|
"$KEYS_SELECT_ARTIST" "Go to artist of selected item"
|
||||||
KEYS_FILTER_9 KEYS_FILTER_0 KEYS_FILTER
|
__keybindinggroup_from_args "Views" \
|
||||||
|
"$KEYS_LIST_ARTISTS" "Display artists in local database" \
|
||||||
# Specials:
|
"$KEYS_LIST_ALBUMS" "Display albums in local database" \
|
||||||
KEYS_BROWSE="${KEYS_BROWSE:-"alt-b"}"
|
"$KEYS_SEARCH_ARTIST" "Show artist on MusicBrainz" \
|
||||||
KEYS_OPEN="${KEYS_OPEN:-"alt-o"}"
|
"$KEYS_SEARCH_ALBUM" "Show album on MusicBrainz"
|
||||||
KEYS_N_YANK="${KEYS_N_YANK:-"y"}"
|
__keybindinggroup_from_args "Playlist" \
|
||||||
KEYS_YANK_CURRENT="${KEYS_YANK_CURRENT:-"ctrl-y"}"
|
"$KEYS_PLAYLIST_RELOAD" "Reload playlist" \
|
||||||
KEYS_SHOW_PLAYLIST="${KEYS_SHOW_PLAYLIST:-"ctrl-p"}"
|
"$KEYS_PLAYLIST_REMOVE" "Remove selected track" \
|
||||||
KEYS_QUIT="${KEYS_QUIT:-"ctrl-c"}"
|
"$KEYS_PLAYLIST_UP" "Move track up" \
|
||||||
KEYS_N_QUIT="${KEYS_N_QUIT:-"q"}"
|
"$KEYS_PLAYLIST_DOWN" "Move track down" \
|
||||||
export KEYS_BROWSE KEYS_OPEN KEYS_N_YANK KEYS_YANK_CURRENT KEYS_SHOW_PLAYLIST \
|
"$KEYS_PLAYLIST_CLEAR" "Clear playlist" \
|
||||||
KEYS_QUIT KEYS_N_QUIT
|
"$KEYS_PLAYLIST_CLEAR_ABOVE" "Remove all tracks above" \
|
||||||
|
"$KEYS_PLAYLIST_CLEAR_BELOW" "Remove all tracks below" \
|
||||||
# Playback:
|
"$KEYS_PLAYLIST_SHUFFLE" "Shuffle" \
|
||||||
KEYS_PLAY="${KEYS_PLAY:-"enter"}"
|
"$KEYS_PLAYLIST_UNSHUFFLE" "Undo shuffle" \
|
||||||
KEYS_QUEUE="${KEYS_QUEUE:-"ctrl-alt-m"}" # That's actually alt-enter
|
"$KEYS_PLAYLIST_GOTO_RELEASE" "Show release of selected track"
|
||||||
KEYS_QUEUE_NEXT="${KEYS_QUEUE_NEXT:-"ctrl-alt-n"}"
|
__keybindinggroup_from_args "Playback" \
|
||||||
KEYS_TOGGLE_PLAYBACK="${KEYS_TOGGLE_PLAYBACK:-"ctrl-space"}"
|
"$KEYS_PLAY,$KEYS_N_PLAY" "Play selected item" \
|
||||||
KEYS_PLAY_NEXT="${KEYS_PLAY_NEXT:-"alt-n"}"
|
"$KEYS_QUEUE,$KEYS_N_QUEUE" "Queue selected item" \
|
||||||
KEYS_PLAY_PREV="${KEYS_PLAY_PREV:-"alt-p"}"
|
"$KEYS_QUEUE_NEXT,$KEYS_N_QUEUE_NEXT" "Play selected item next" \
|
||||||
KEYS_SEEK_FORWARD="${KEYS_SEEK_FORWARD:-"alt-N"}"
|
"$KEYS_TOGGLE_PLAYBACK,$KEYS_N_TOGGLE_PLAYBACK" "Toggle playback" \
|
||||||
KEYS_SEEK_BACKWARD="${KEYS_SEEK_BACKWARD:-"alt-P"}"
|
"$KEYS_PLAY_NEXT,$KEYS_N_PLAY_NEXT" "Play next track" \
|
||||||
KEYS_PLAYBACK="$KEYS_PLAY,$KEYS_QUEUE,$KEYS_QUEUE_NEXT,$KEYS_TOGGLE_PLAYBACK,$KEYS_PLAY_NEXT,$KEYS_PLAY_PREV,$KEYS_SEEK_FORWARD,$KEYS_SEEK_BACKWARD"
|
"$KEYS_PLAY_PREV,$KEYS_N_PLAY_PREV" "Play previous track" \
|
||||||
KEYS_N_PLAY="${KEYS_N_PLAY:-"."}"
|
"$KEYS_SEEK_FORWARD,$KEYS_N_SEEK_FORWARD" "Seek forward" \
|
||||||
KEYS_N_QUEUE="${KEYS_N_QUEUE:-";"}"
|
"$KEYS_SEEK_BACKWARD,$KEYS_N_SEEK_BACKWARD" "Seek backward"
|
||||||
KEYS_N_QUEUE_NEXT="${KEYS_N_QUEUE_NEXT:-":"}"
|
__keybindinggroup_from_args "Special operations" \
|
||||||
KEYS_N_TOGGLE_PLAYBACK="${KEYS_N_TOGGLE_PLAYBACK:-"space"}"
|
"$KEYS_BROWSE" "Open selected item in browser" \
|
||||||
KEYS_N_PLAY_NEXT="${KEYS_N_PLAY_NEXT:-"right,n"}"
|
"$KEYS_OPEN" "Open selected item in file manager" \
|
||||||
KEYS_N_PLAY_PREV="${KEYS_N_PLAY_PREV:-"left,p"}"
|
"$KEYS_N_YANK" "Copy MusicBrainz track ID" \
|
||||||
KEYS_N_SEEK_FORWARD="${KEYS_N_SEEK_FORWARD:-"N,f"}"
|
"$KEYS_YANK_CURRENT" "Copy MusicBrainz release ID"
|
||||||
KEYS_N_SEEK_BACKWARD="${KEYS_N_SEEK_BACKWARD:-"P,b"}"
|
;;
|
||||||
KEYS_N_PLAYBACK="$KEYS_N_PLAY,$KEYS_N_QUEUE,$KEYS_N_QUEUE_NEXT,$KEYS_N_TOGGLE_PLAYBACK,$KEYS_N_PLAY_NEXT,$KEYS_N_PLAY_PREV,$KEYS_N_SEEK_FORWARD,$KEYS_N_SEEK_BACKWARD"
|
*)
|
||||||
export KEYS_PLAY KEYS_QUEUE KEYS_QUEUE_NEXT KEYS_TOGGLE_PLAYBACK \
|
__keybindinggroup_from_args "Switch between modes" \
|
||||||
KEYS_PLAY_NEXT KEYS_PLAY_PREV KEYS_SEEK_FORWARD KEYS_SEEK_BACKWARD \
|
"$KEYS_I_NORMAL" "Swtich to normal mode (insert)" \
|
||||||
KEYS_PLAYBACK KEYS_N_PLAY KEYS_N_QUEUE KEYS_N_QUEUE_NEXT \
|
"$KEYS_N_INSERT" "Swtich to insert mode (normal)"
|
||||||
KEYS_N_TOGGLE_PLAYBACK KEYS_N_PLAY_NEXT KEYS_N_PLAY_PREV \
|
__keybindinggroup_from_args "Previews" \
|
||||||
KEYS_N_SEEK_FORWARD KEYS_N_SEEK_BACKWARD KEYS_N_PLAYBACK
|
"$KEYS_SCROLL_PREVIEW_DOWN" "Scroll preview down" \
|
||||||
|
"$KEYS_SCROLL_PREVIEW_UP" "Scroll preview up" \
|
||||||
# Playlist (in the playlist, there is no `insert` mode):
|
"$KEYS_KEYBINDINGS" "Show these keybindings" \
|
||||||
KEYS_PLAYLIST_RELOAD="${KEYS_PLAYLIST_RELOAD:-"r,ctrl-r"}"
|
"$KEYS_PREVIEW_OPEN" "Open preview window" \
|
||||||
KEYS_PLAYLIST_REMOVE="${KEYS_PLAYLIST_REMOVE:-"x,delete"}"
|
"$KEYS_PREVIEW_CLOSE" "Close preview window"
|
||||||
KEYS_PLAYLIST_UP="${KEYS_PLAYLIST_UP:-"u"}"
|
__keybindinggroup_from_args "Navigation" \
|
||||||
KEYS_PLAYLIST_DOWN="${KEYS_PLAYLIST_DOWN:-"d"}"
|
"$KEYS_DOWN" "Down" \
|
||||||
KEYS_PLAYLIST_CLEAR="${KEYS_PLAYLIST_CLEAR:-"C"}"
|
"$KEYS_UP" "Up" \
|
||||||
KEYS_PLAYLIST_CLEAR_ABOVE="${KEYS_PLAYLIST_CLEAR_ABOVE:-"U"}"
|
"$KEYS_N_DOWN" "Down (normal)" \
|
||||||
KEYS_PLAYLIST_CLEAR_BELOW="${KEYS_PLAYLIST_CLEAR_BELOW:-"D"}"
|
"$KEYS_N_UP" "Up (normal)" \
|
||||||
KEYS_PLAYLIST_SHUFFLE="${KEYS_PLAYLIST_SHUFFLE:-"s"}"
|
"$KEYS_HALFPAGE_DOWN" "Down half a page" \
|
||||||
KEYS_PLAYLIST_UNSHUFFLE="${KEYS_PLAYLIST_UNSHUFFLE:-"S"}"
|
"$KEYS_HALFPAGE_UP" "Up half a page" \
|
||||||
KEYS_PLAYLIST_GOTO_RELEASE="${KEYS_PLAYLIST_GOTO_RELEASE:-"ctrl-g"}"
|
"$KEYS_N_TOP" "Go to first entry (normal)" \
|
||||||
KEYS_PLAYLIST_STORE="${KEYS_PLAYLIST_STORE:-"ctrl-s"}"
|
"$KEYS_N_BOT" "Go to last entry (normal)" \
|
||||||
KEYS_PLAYLIST_LOAD="${KEYS_PLAYLIST_LOAD:-"ctrl-o"}"
|
"$KEYS_IN" "Open selected item" \
|
||||||
export KEYS_PLAYLIST_RELOAD KEYS_PLAYLIST_REMOVE KEYS_PLAYLIST_UP \
|
"$KEYS_N_IN" "Open selected item (normal)" \
|
||||||
KEYS_PLAYLIST_DOWN KEYS_PLAYLIST_CLEAR KEYS_PLAYLIST_CLEAR_ABOVE \
|
"$KEYS_OUT" "Leave current item" \
|
||||||
KEYS_PLAYLIST_CLEAR_BELOW KEYS_PLAYLIST_SHUFFLE KEYS_PLAYLIST_UNSHUFFLE \
|
"$KEYS_N_OUT" "Leave current item (normal)" \
|
||||||
KEYS_PLAYLIST_GOTO_RELEASE KEYS_PLAYLIST_STORE KEYS_PLAYLIST_LOAD
|
"$KEYS_SELECT_ARTIST" "Go to artist of selected item"
|
||||||
|
__keybindinggroup_from_args "Views" \
|
||||||
|
"$KEYS_LIST_ARTISTS" "Display artists in local database" \
|
||||||
|
"$KEYS_LIST_ALBUMS" "Display albums in local database" \
|
||||||
|
"$KEYS_SEARCH_ARTIST" "Show artist on MusicBrainz" \
|
||||||
|
"$KEYS_SEARCH_ALBUM" "Show album on MusicBrainz" \
|
||||||
|
"$KEYS_SWITCH_ARTIST_ALBUM" "Swtich artist / album" \
|
||||||
|
"$KEYS_SWITCH_LOCAL_REMOTE" "Swtich local database / MusicBrainz"
|
||||||
|
__keybindinggroup_from_args "Filtering" \
|
||||||
|
"$KEYS_FILTER_LOCAL" "Show only entries in local database" \
|
||||||
|
"$KEYS_FILTER_0" "Clear filter" \
|
||||||
|
"$KEYS_FILTER_1" "Reset filter to default for current view" \
|
||||||
|
"$KEYS_FILTER_2" "Custom filter" \
|
||||||
|
"$KEYS_FILTER_3" "Custom filter" \
|
||||||
|
"$KEYS_FILTER_4" "Custom filter" \
|
||||||
|
"$KEYS_FILTER_5" "Custom filter" \
|
||||||
|
"$KEYS_FILTER_6" "Custom filter" \
|
||||||
|
"$KEYS_FILTER_7" "Custom filter" \
|
||||||
|
"$KEYS_FILTER_8" "Custom filter" \
|
||||||
|
"$KEYS_FILTER_9" "Custom filter"
|
||||||
|
__keybindinggroup_from_args "Playback" \
|
||||||
|
"$KEYS_PLAY" "Play selected item" \
|
||||||
|
"$KEYS_QUEUE" "Queue selected item" \
|
||||||
|
"$KEYS_QUEUE_NEXT" "Play selected item next" \
|
||||||
|
"$KEYS_TOGGLE_PLAYBACK" "Toggle playback" \
|
||||||
|
"$KEYS_PLAY_NEXT" "Play next track" \
|
||||||
|
"$KEYS_PLAY_PREV" "Play previous track" \
|
||||||
|
"$KEYS_SEEK_FORWARD" "Seek forward" \
|
||||||
|
"$KEYS_SEEK_BACKWARD" "Seek backward"
|
||||||
|
__keybindinggroup_from_args "Playback (normal)" \
|
||||||
|
"$KEYS_N_PLAY" "Play selected item" \
|
||||||
|
"$KEYS_N_QUEUE" "Queue selected item" \
|
||||||
|
"$KEYS_N_QUEUE_NEXT" "Play selected item next" \
|
||||||
|
"$KEYS_N_TOGGLE_PLAYBACK" "Toggle playback" \
|
||||||
|
"$KEYS_N_PLAY_NEXT" "Play next track" \
|
||||||
|
"$KEYS_N_PLAY_PREV" "Play previous track" \
|
||||||
|
"$KEYS_N_SEEK_FORWARD" "Seek forward" \
|
||||||
|
"$KEYS_N_SEEK_BACKWARD" "Seek backward"
|
||||||
|
__keybindinggroup_from_args "Special operations" \
|
||||||
|
"$KEYS_SHOW_PLAYLIST" "Show playlist" \
|
||||||
|
"$KEYS_BROWSE" "Open selected item in browser" \
|
||||||
|
"$KEYS_OPEN" "Open selected item in file manager" \
|
||||||
|
"$KEYS_N_YANK" "Copy selected MusicBrainz ID (normal)" \
|
||||||
|
"$KEYS_YANK_CURRENT" "Copy current MusicBrainz ID" \
|
||||||
|
"$KEYS_QUIT" "Quit applicaion" \
|
||||||
|
"$KEYS_N_QUIT" "First view or quit (normal)"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
@@ -53,7 +53,7 @@ decorate() {
|
|||||||
fi
|
fi
|
||||||
decoration=$($JQ -n '.tracks = {}')
|
decoration=$($JQ -n '.tracks = {}')
|
||||||
tmpf=$(mktemp)
|
tmpf=$(mktemp)
|
||||||
(cd "$1" && find . -type f -iname '*.mp3' -o -iname '*.mp4' -o -iname '*.flac' -o -iname '*.m4a') >"$tmpf"
|
(cd "$1" && find . -type f -iname '*.mp3' -o -iname '*.mp4' -o -iname '*.flac' -o -iname '*.m4a' -o -iname '*.ogg') >"$tmpf"
|
||||||
while IFS= read -r f; do
|
while IFS= read -r f; do
|
||||||
mbid=$(__gettags "$1/$f")
|
mbid=$(__gettags "$1/$f")
|
||||||
rid=$(echo "$mbid" | $JQ '.releaseid')
|
rid=$(echo "$mbid" | $JQ '.releaseid')
|
||||||
@@ -83,6 +83,97 @@ decorate() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Decorate locally available music with specified MusicBrainz release
|
||||||
|
#
|
||||||
|
# @input $1: Path to directory with album
|
||||||
|
# @input $2: MusicBrainz release ID
|
||||||
|
#
|
||||||
|
# Similar as `decorate`, but the MusicBrainz IDs are not inferred from the
|
||||||
|
# tags, but passed as argument.
|
||||||
|
decorate_as() {
|
||||||
|
if [ -f "$1/$DECORATION_FILENAME" ]; then
|
||||||
|
rid="$($JQ '.releaseid' "$1/$DECORATION_FILENAME")"
|
||||||
|
title="$(mb_release "$rid" | $JQ '.title // ""')"
|
||||||
|
artist="$(mb_release "$rid" | $JQ '."artist-credit" | map([.name, .joinphrase] | join("")) | join("")')"
|
||||||
|
[ "$rid" = "$2" ] &&
|
||||||
|
info "Directory $1 has already been decorated as the release '$title' - '$artist' with the identical MusicBrainz release ID." ||
|
||||||
|
info "Directory $1 has already been decorated as the release '$title' - '$artist' with the MusicBrainz release ID $rid."
|
||||||
|
while true; do
|
||||||
|
infonn "Do you want to redecorate $1? (yes/no)"
|
||||||
|
read -r yn
|
||||||
|
case $yn in
|
||||||
|
"yes") break ;;
|
||||||
|
"no") return 0 ;;
|
||||||
|
*) info "Please answer \"yes\" or \"no\"." ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
# Print info
|
||||||
|
title="$(mb_release "$2" | $JQ '.title // ""')"
|
||||||
|
artist="$(mb_release "$2" | $JQ '."artist-credit" | map([.name, .joinphrase] | join("")) | join("")')"
|
||||||
|
info "Decorating $1 as the release $title by $artist"
|
||||||
|
# Start decoration
|
||||||
|
decoration=$($JQ -n '.tracks = {}')
|
||||||
|
tmpf=$(mktemp)
|
||||||
|
(cd "$1" && find . -type f -iname '*.mp3' -o -iname '*.mp4' -o -iname '*.flac' -o -iname '*.m4a' -o -iname '*.ogg' | sort) >"$tmpf"
|
||||||
|
# Compare number of tracks with release
|
||||||
|
rcnt="$(mb_release "$2" | $JQ '.media | map(."track-count") | add')"
|
||||||
|
dcnt="$(wc -l "$tmpf" | cut -d ' ' -f 1)"
|
||||||
|
if [ ! "$rcnt" -eq "$dcnt" ]; then
|
||||||
|
err "Number of tracks in directory ($dcnt) does not match number of tracks in release ($rcnt)."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
#
|
||||||
|
tmpj=$(mktemp)
|
||||||
|
mb_release "$2" |
|
||||||
|
$JQ '.media[] |
|
||||||
|
.position as $pos |
|
||||||
|
.tracks |
|
||||||
|
map({
|
||||||
|
$pos,
|
||||||
|
"id": .id,
|
||||||
|
"n": .number,
|
||||||
|
"t": .title
|
||||||
|
}) |
|
||||||
|
map(if(.n | type == "string" and test("^[0-9]+$")) then .n |= tonumber else . end) |
|
||||||
|
sort_by([.pos, .n])[] |
|
||||||
|
[.t, .id] |
|
||||||
|
join("\t")' >"$tmpj"
|
||||||
|
assocfile=$(mktemp)
|
||||||
|
awk -F '\t' '
|
||||||
|
BEGIN { OFS = "\t" }
|
||||||
|
FNR == NR { title[FNR] = $1; id[FNR] = $2 }
|
||||||
|
FNR != NR { fname[FNR] = $1 }
|
||||||
|
END { for (i in id) print title[i], id[i], fname[i] }
|
||||||
|
' "$tmpj" "$tmpf" >"$assocfile"
|
||||||
|
rm -f "$tmpj" "$tmpf"
|
||||||
|
# Ask user if this is ok
|
||||||
|
info "We discovered the following associatoin:"
|
||||||
|
while IFS= read -r line; do
|
||||||
|
t="$(echo "$line" | cut -d "$(printf '\t')" -f 1)"
|
||||||
|
f="$(echo "$line" | cut -d "$(printf '\t')" -f 3)"
|
||||||
|
printf "Track '%s'\tFile '%s'\n" "$t" "$f"
|
||||||
|
done <"$assocfile" | column -t -s "$(printf '\t')"
|
||||||
|
while true; do
|
||||||
|
infonn "Are the track correctly associated to the audio files? (yes/no)"
|
||||||
|
read -r yn
|
||||||
|
case $yn in
|
||||||
|
"yes") break ;;
|
||||||
|
"no") return 0 ;;
|
||||||
|
*) info "Please answer \"yes\" or \"no\"." ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
# Construct decoration
|
||||||
|
decoration=$($JQ -n '.tracks = {}')
|
||||||
|
while IFS= read -r line; do
|
||||||
|
i="$(echo "$line" | cut -d "$(printf '\t')" -f 2)"
|
||||||
|
f="$(echo "$line" | cut -d "$(printf '\t')" -f 3)"
|
||||||
|
decoration=$(echo "$decoration" | $JQ ".tracks += {\"$i\": \"$f\"}")
|
||||||
|
done <"$assocfile"
|
||||||
|
echo "$decoration" | $JQ ".releaseid = \"$2\"" >"$1/$DECORATION_FILENAME"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
# Load missing cache entries (batch mode)
|
# Load missing cache entries (batch mode)
|
||||||
#
|
#
|
||||||
# argument $1: type
|
# argument $1: type
|
||||||
|
@@ -25,3 +25,8 @@ err() {
|
|||||||
info() {
|
info() {
|
||||||
echo "$(date) [$$]>${INFO}Info:${OFF} ${1:-}" | tee -a "$LOGFILE" | cut -d ">" -f 2- >/dev/stderr
|
echo "$(date) [$$]>${INFO}Info:${OFF} ${1:-}" | tee -a "$LOGFILE" | cut -d ">" -f 2- >/dev/stderr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Like `info` but without newlnes on stderr.
|
||||||
|
infonn() {
|
||||||
|
echo "$(date) [$$]>${INFO}Info:${OFF} ${1:-}" | tee -a "$LOGFILE" | cut -d ">" -f 2- | tr '\n' ' ' >/dev/stderr
|
||||||
|
}
|
||||||
|
@@ -46,3 +46,8 @@ preview_artist() {
|
|||||||
#link=$(printf "More info:\033]8;;%s\033\\ %s\033]8;;\033\\" "https://musicbrainz.org/" "[MusicBrainz]")
|
#link=$(printf "More info:\033]8;;%s\033\\ %s\033]8;;\033\\" "https://musicbrainz.org/" "[MusicBrainz]")
|
||||||
printf "$APV_FORMAT" "$desc" "${lifespan:-}"
|
printf "$APV_FORMAT" "$desc" "${lifespan:-}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print message if there is nothing to be shown
|
||||||
|
preview_nothing() {
|
||||||
|
echo "No preview available."
|
||||||
|
}
|
||||||
|
@@ -6,15 +6,19 @@
|
|||||||
|
|
||||||
# Colors (internal only)
|
# Colors (internal only)
|
||||||
ESC=$(printf '\033')
|
ESC=$(printf '\033')
|
||||||
|
BOLD="${ESC}[1m"
|
||||||
FAINT="${ESC}[2m"
|
FAINT="${ESC}[2m"
|
||||||
|
UNDERLINE="${ESC}[4m"
|
||||||
CARTIST="${ESC}[38;5;209m"
|
CARTIST="${ESC}[38;5;209m"
|
||||||
CTITLE="${ESC}[38;5;229m"
|
CTITLE="${ESC}[38;5;229m"
|
||||||
|
CRELINFO="${ESC}[38;5;179m"
|
||||||
CYEAR="${ESC}[38;5;179m"
|
CYEAR="${ESC}[38;5;179m"
|
||||||
CDISAMB="$FAINT${ESC}[38;5;172m"
|
CDISAMB="$FAINT${ESC}[38;5;172m"
|
||||||
CNOTE="${ESC}[38;5;242m"
|
CNOTE="${ESC}[38;5;242m"
|
||||||
CXXX="${ESC}[38;5;109m"
|
CXXX="${ESC}[38;5;109m"
|
||||||
CDESC="${ESC}[38;5;254m"
|
CDESC="${ESC}[38;5;254m"
|
||||||
CLIFE="${ESC}[38;5;251m"
|
CLIFE="${ESC}[38;5;251m"
|
||||||
|
CKB="${ESC}[38;5;224m"
|
||||||
OFF="${ESC}[m"
|
OFF="${ESC}[m"
|
||||||
|
|
||||||
# Pointers
|
# Pointers
|
||||||
@@ -25,24 +29,24 @@ FORMAT_LOCAL="${FORMAT_LOCAL:-"🔆"}"
|
|||||||
FORMAT_CURRENT="${FORMAT_CURRENT:-"👉"}"
|
FORMAT_CURRENT="${FORMAT_CURRENT:-"👉"}"
|
||||||
export FORMAT_LOCAL FORMAT_CURRENT
|
export FORMAT_LOCAL FORMAT_CURRENT
|
||||||
|
|
||||||
# Input prompts
|
# Input prompt
|
||||||
# =============
|
# =============
|
||||||
# General search prompt
|
# Search prompt
|
||||||
SEARCH_PROMPT=${SEARCH_PROMPT:-"🔎 〉"}
|
SEARCH_PROMPT=${SEARCH_PROMPT:-"🔎 〉"}
|
||||||
# Prompt that takes an artist name as argument
|
export SEARCH_PROMPT
|
||||||
ARTIST_PROMPT="${ARTIST_PROMPT:-"🎤 ${CARTIST}%s$OFF 〉"}"
|
|
||||||
# Prompt that takes an artist name and a release name as arguments (in that
|
|
||||||
# order)
|
|
||||||
FULL_PROMPT="${FULL_PROMPT:-"🎤 ${CARTIST}%s$OFF 》${CTITLE}%s$OFF 〉"}"
|
|
||||||
export SEARCH_PROMPT ARTIST_PROMPT FULL_PROMPT
|
|
||||||
|
|
||||||
# Visual representation of current mode
|
# Headers
|
||||||
# =====================================
|
# =======
|
||||||
# Sign to indicate `normal` mode
|
# Header that displays artist's name
|
||||||
PROMPT_NORMAL="${PROMPT_NORMAL:-"${FAINT}[n]${OFF}"}"
|
HEADER_ARTIST="${HEADER_ARTIST:-"🎤 ${CARTIST}%s$OFF 〉"}"
|
||||||
# Sign to indicate `insert` mode
|
# Header that displays the release-group name after artist's
|
||||||
PROMPT_INSERT="${PROMPT_INSERT:-"${FAINT}[i]${OFF}"}"
|
HEADER_ARTIST_RELEASEGROUP="${HEADER_ARTIST_RELEASEGROUP:-"🎤 ${CARTIST}%s$OFF 》${CTITLE}%s$OFF 〉"}"
|
||||||
export PROMPT_NORMAL PROMPT_INSERT
|
# Header that in addition to `HEADER_ARTIST_RELEASEGROUP` also shows some
|
||||||
|
# release information
|
||||||
|
HEADER_RELEASE="${HEADER_RELEASE:-"🎤 ${CARTIST}%s$OFF 》${CTITLE}%s$OFF 〉%s"}"
|
||||||
|
# The release information is formatted as follows (placeholders implicit):
|
||||||
|
HEADER_RELEASE_FORMAT="${HEADER_RELEASE_FORMAT:-"${CRELINFO}<<tracks>> tx <<media>> $OFF|$CRELINFO <<label>> <<country>> <<year>>$OFF"}"
|
||||||
|
export HEADER_ARTIST HEADER_ARTIST_RELEASEGROUP HEADER_RELEASE HEADER_RELEASE_FORMAT
|
||||||
|
|
||||||
# Artist view
|
# Artist view
|
||||||
# ===========
|
# ===========
|
||||||
@@ -152,3 +156,13 @@ REC_FORMAT="${REC_FORMAT:-"${CNOTE}${FAINT}<<med>>\t${CNOTE}<<nr>>$OFF\t${CTITLE
|
|||||||
# Format of a track in the playlist
|
# Format of a track in the playlist
|
||||||
REC_FORMAT_NO_NUMBER="${REC_FORMAT_NO_NUMBER:-"${CTITLE}<<title>>\t${CARTIST}<<artist>>\t${CXXX}<<duration>>$OFF"}"
|
REC_FORMAT_NO_NUMBER="${REC_FORMAT_NO_NUMBER:-"${CTITLE}<<title>>\t${CARTIST}<<artist>>\t${CXXX}<<duration>>$OFF"}"
|
||||||
export REC_FORMAT REC_FORMAT_NO_NUMBER
|
export REC_FORMAT REC_FORMAT_NO_NUMBER
|
||||||
|
|
||||||
|
# Keybinding themes
|
||||||
|
# =================
|
||||||
|
# Format keybinding group
|
||||||
|
KBF_GROUP="${KBF_GROUP:-"${UNDERLINE}${CKB}%s$OFF"}"
|
||||||
|
# Format key
|
||||||
|
KBF_KEY="${KBF_KEY:-"${BOLD}${CKB}%s$OFF"}"
|
||||||
|
# Format description
|
||||||
|
KBF_DESC="${KBF_DESC:-"${CKB}%s$OFF"}"
|
||||||
|
export KBF_GROUP KBF_KEY KBF_DESC
|
||||||
|
Reference in New Issue
Block a user