Compare commits
6 Commits
2cc8332560
...
d5b3d7c597
Author | SHA1 | Date | |
---|---|---|---|
d5b3d7c597 | |||
a2fd70e096 | |||
49411a2b22 | |||
fc14a0e0d5 | |||
70da0ed282 | |||
dfcae7cf89 |
471
src/main.sh
471
src/main.sh
@@ -2,6 +2,31 @@
|
|||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
|
# The user interface of this application is composed out of the following
|
||||||
|
# views.
|
||||||
|
# - VIEW_ARTIST: Show all release group of an artist
|
||||||
|
# - VIEW_RELEASEGROUP: Show all releases within a release group
|
||||||
|
# - VIEW_RELEASE: Show track list of release
|
||||||
|
# - VIEW_SEARCH_ARTIST: Interface to search artists on MusicBrainz
|
||||||
|
# - VIEW_SEARCH_ALBUM: Interface to search albums (release groups) on MusicBrainz
|
||||||
|
# - VIEW_LIST_ARTISTS: Presentation of all artists in the local database
|
||||||
|
# - VIEW_LIST_ALBUMS: Presentation of all albums (release groups) in the local database
|
||||||
|
# - VIEW_SELECT_ARTIST: Interface for the user to select an artist
|
||||||
|
# - VIEW_PLAYLIST: View on the currently loaded playlist and playlist manipulation
|
||||||
|
# - VIEW_QUIT: Exiting view, to terminate the application
|
||||||
|
#
|
||||||
|
# All views but the last three are handled within a single fzf instance. The
|
||||||
|
# views VIEW_SELECT_ARTIST, and VIEW_PLAYLIST run each in a separate fzf
|
||||||
|
# instance. The last view (VIEW_QUIT) does nothing but terminate the
|
||||||
|
# application.
|
||||||
|
#
|
||||||
|
# The fzf instance comprising VIEW_ARTIST - VIEW_LIST_ALBUMS is always in one
|
||||||
|
# of two modes: normale mode (MODE_NORMAL) or insert mode (MODE_INSERT). Both
|
||||||
|
# modes come with different key bindings. It is only in the insert mode that
|
||||||
|
# the query string can be written.
|
||||||
|
#
|
||||||
|
# All views and modes are referred to by the following constants. The values
|
||||||
|
# are arbitrary but distinct.
|
||||||
VIEW_ARTIST="artist"
|
VIEW_ARTIST="artist"
|
||||||
VIEW_RELEASEGROUP="rg"
|
VIEW_RELEASEGROUP="rg"
|
||||||
VIEW_RELEASE="release"
|
VIEW_RELEASE="release"
|
||||||
@@ -15,23 +40,15 @@ VIEW_QUIT="quit"
|
|||||||
MODE_NORMAL="hidden"
|
MODE_NORMAL="hidden"
|
||||||
MODE_INSERT="show"
|
MODE_INSERT="show"
|
||||||
|
|
||||||
# Load helper methods
|
# Methods and variables used in main instance and subprocesses
|
||||||
|
# Load application information
|
||||||
. "sh/info.sh"
|
. "sh/info.sh"
|
||||||
|
|
||||||
# Load helper methods
|
# Load logging methods
|
||||||
. "sh/helper.sh"
|
. "sh/log.sh"
|
||||||
|
|
||||||
# Load configuration
|
# Load query methods
|
||||||
. "sh/config.sh"
|
. "sh/query.sh"
|
||||||
|
|
||||||
# Load theme
|
|
||||||
. "sh/theme.sh"
|
|
||||||
|
|
||||||
# Load keys
|
|
||||||
. "sh/keys.sh"
|
|
||||||
|
|
||||||
# Load filters
|
|
||||||
. "sh/filter.sh"
|
|
||||||
|
|
||||||
# Load playback helper
|
# Load playback helper
|
||||||
. "sh/playback.sh"
|
. "sh/playback.sh"
|
||||||
@@ -39,12 +56,6 @@ MODE_INSERT="show"
|
|||||||
# Load playlist tools
|
# Load playlist tools
|
||||||
. "sh/playlist.sh"
|
. "sh/playlist.sh"
|
||||||
|
|
||||||
# Load AWK scripts
|
|
||||||
. "sh/awk.sh"
|
|
||||||
|
|
||||||
# Load tools
|
|
||||||
. "sh/tools.sh"
|
|
||||||
|
|
||||||
# Load MusicBrainz and Discogs methods
|
# Load MusicBrainz and Discogs methods
|
||||||
. "sh/api.sh"
|
. "sh/api.sh"
|
||||||
|
|
||||||
@@ -66,78 +77,80 @@ MODE_INSERT="show"
|
|||||||
# Load list-generating methods
|
# Load list-generating methods
|
||||||
. "sh/lists.sh"
|
. "sh/lists.sh"
|
||||||
|
|
||||||
# State management
|
|
||||||
. "sh/state.sh"
|
|
||||||
|
|
||||||
# FZF handlers
|
# FZF handlers
|
||||||
. "sh/fzf.sh"
|
. "sh/fzf.sh"
|
||||||
|
|
||||||
|
# Command-line options that may only be used internally.
|
||||||
|
# --lines
|
||||||
|
# --playback
|
||||||
|
# --playlist
|
||||||
|
# --action-playlistcursor
|
||||||
|
# --action-filter
|
||||||
|
# --action-gotoartist
|
||||||
|
# --action-draw
|
||||||
|
# --mbsearch
|
||||||
|
# --preview-artist
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
"--lines")
|
"--lines")
|
||||||
|
# Print lines that are fed into fzf.
|
||||||
|
#
|
||||||
|
# @argument $2: view
|
||||||
|
# @argument $3: MusicBrainz ID
|
||||||
|
#
|
||||||
|
# The first argument `view` may be one of VIEW_ARTIST, VIEW_RELEASEGROUP,
|
||||||
|
# VIEW_RELEASE, VIEW_LIST_ARTISTS, VIEW_LIST_ALBUMS, and VIEW_PLAYLIST. The
|
||||||
|
# MusicBrainz ID is required for the first three views, and denotes the
|
||||||
|
# MusicBrainz ID of the respective object.
|
||||||
view=${2:-}
|
view=${2:-}
|
||||||
mbid=${3:-}
|
mbid=${3:-}
|
||||||
case "$view" in
|
case "$view" in
|
||||||
"$VIEW_ARTIST")
|
"$VIEW_ARTIST") list_releasegroups "$mbid" ;;
|
||||||
list_releasegroups "$mbid"
|
"$VIEW_RELEASEGROUP") list_releases "$mbid" ;;
|
||||||
;;
|
"$VIEW_RELEASE") list_recordings "$mbid" ;;
|
||||||
"$VIEW_RELEASEGROUP")
|
"$VIEW_LIST_ARTISTS") list_local_artists ;;
|
||||||
list_releases "$mbid"
|
"$VIEW_LIST_ALBUMS") list_local_releasegroups ;;
|
||||||
;;
|
"$VIEW_PLAYLIST") list_playlist ;;
|
||||||
"$VIEW_RELEASE")
|
"$VIEW_SEARCH_ARTIST" | "$VIEW_SEARCH_ALBUM") fzf_reload_after_change ;;
|
||||||
list_recordings "$mbid"
|
|
||||||
;;
|
|
||||||
"$VIEW_LIST_ARTISTS")
|
|
||||||
list_local_artists
|
|
||||||
;;
|
|
||||||
"$VIEW_LIST_ALBUMS")
|
|
||||||
list_local_releasegroups
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"--playback")
|
"--playback")
|
||||||
view=${2:-}
|
# Control mpv instance (see `src/sh/playback.sh`)
|
||||||
mbid_current="${3:-}"
|
#
|
||||||
mbid="${4:-}"
|
# @argument $2: view
|
||||||
path="${5:-}"
|
# @argument $3: MusicBrainz ID of current object
|
||||||
pbcmd=$(playback_cmd_from_key "$FZF_KEY")
|
# @argument $4: MusicBrainz ID of selected object
|
||||||
case "$pbcmd" in
|
# @argument $5: Path to decoration file
|
||||||
"$PLAYBACK_CMD_PLAY")
|
shift
|
||||||
[ "$path" ] || exit 0
|
playback "$@"
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST" | "$VIEW_SEARCH_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ARTISTS" | "$VIEW_LIST_ALBUMS") debug "not implemented" ;;
|
|
||||||
"$VIEW_RELEASEGROUP") generate_playlist "$mbid" "$path" | mpv_play_list >/dev/null ;;
|
|
||||||
"$VIEW_RELEASE") generate_playlist "$mbid_current" "$path" "$mbid" | mpv_play_list >/dev/null ;;
|
|
||||||
"$VIEW_PLAYLIST") mpv_play_index $((FZF_POS - 1)) >/dev/null ;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
"$PLAYBACK_CMD_QUEUE")
|
|
||||||
[ "$path" ] || exit 0
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST" | "$VIEW_SEARCH_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ARTISTS" | "$VIEW_LIST_ALBUMS") debug "not implemented" ;;
|
|
||||||
"$VIEW_RELEASEGROUP") generate_playlist "$mbid" "$path" | mpv_queue_list >/dev/null ;;
|
|
||||||
"$VIEW_RELEASE") generate_playlist "$mbid_current" "$path" "$mbid" | mpv_queue_list >/dev/null ;;
|
|
||||||
"$VIEW_PLAYLIST") generate_playlist "$mbid_current" "$path" "$mbid" | mpv_queue_list >/dev/null ;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
"$PLAYBACK_CMD_QUEUE_NEXT")
|
|
||||||
[ "$path" ] || exit 0
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST" | "$VIEW_SEARCH_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ARTISTS" | "$VIEW_LIST_ALBUMS") debug "not implemented" ;;
|
|
||||||
"$VIEW_RELEASEGROUP") generate_playlist "$mbid" "$path" | mpv_queue_next_list >/dev/null ;;
|
|
||||||
"$VIEW_RELEASE") generate_playlist "$mbid_current" "$path" "$mbid" | mpv_queue_next_list >/dev/null ;;
|
|
||||||
"$VIEW_PLAYLIST") generate_playlist "$mbid_current" "$path" "$mbid" | mpv_queue_next_list >/dev/null ;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
"$PLAYBACK_CMD_TOGGLE_PLAYBACK") mpv_toggle_pause ;;
|
|
||||||
"$PLAYBACK_CMD_PLAY_NEXT") mpv_next ;;
|
|
||||||
"$PLAYBACK_CMD_PLAY_PREV") mpv_prev ;;
|
|
||||||
"$PLAYBACK_CMD_SEEK_FORWARD") mpv_seek_forward ;;
|
|
||||||
"$PLAYBACK_CMD_SEEK_BACKWARD") mpv_seek_backward ;;
|
|
||||||
esac
|
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"--filter")
|
"--playlist")
|
||||||
|
# Run playback commands (see `src/sh/playlits.sh`)
|
||||||
|
#
|
||||||
|
# @argument $2: playlist command
|
||||||
|
shift
|
||||||
|
playlist "$@"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
"--action-playlistcursor")
|
||||||
|
# Print fzf command to replace cursor in playlist
|
||||||
|
#
|
||||||
|
# This prints the command read by a `transform` fzf binding, with which the
|
||||||
|
# cursor is placed on the currently played track in the playlist view.
|
||||||
|
pos=$(mpv_playlist_position)
|
||||||
|
printf "pos(%s)" $((pos + 1))
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
"--action-filter")
|
||||||
|
# fzf instructions to invoke filters
|
||||||
|
#
|
||||||
|
# @argument #2: mode
|
||||||
|
# @argument #3: view
|
||||||
|
#
|
||||||
|
# This option takes the key pressed (FZF_KEY), translates it to the preset
|
||||||
|
# query of that key in that view, and prints the fzf instructions which sets
|
||||||
|
# that query.
|
||||||
mode=$2
|
mode=$2
|
||||||
view=$3
|
view=$3
|
||||||
q="$(default_query "$view" "$FZF_KEY")"
|
q="$(default_query "$view" "$FZF_KEY")"
|
||||||
@@ -146,29 +159,44 @@ case "${1:-}" in
|
|||||||
[ "$mode" = "$MODE_NORMAL" ] && printf "+hide-input"
|
[ "$mode" = "$MODE_NORMAL" ] && printf "+hide-input"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"--jumpto-artist")
|
"--action-gotoartist")
|
||||||
|
# fzf instructions to go to artist
|
||||||
|
#
|
||||||
|
# @argument $2: mode
|
||||||
|
# @argument $3: view
|
||||||
|
# @argument $4: MusicBrainz ID of current object
|
||||||
|
# @argument $5: MusicBrainz ID of selected object
|
||||||
|
#
|
||||||
|
# With this option, fzf instructions are printed that divert the user to the
|
||||||
|
# view VIEW_ARTIST of the artist of the selected object (of it is a
|
||||||
|
# single-artist object), or that divert the user to a choice
|
||||||
|
# (VIEW_SELECT_ARTIST) of all artists of the selected object. In the view
|
||||||
|
# VIEW_PLAYLIST, the latter path is also taken for single-artist objects. The
|
||||||
|
# reason for this is that VIEW_PLAYLIST and VIEW_ARTIST are not implemented
|
||||||
|
# in the same fzf instance, and VIEW_SELECT_ARTIST already provides an
|
||||||
|
# interface to switch from VIEW_PLAYLIST to VIEW_ARTIST.
|
||||||
mode=$2
|
mode=$2
|
||||||
view=$3
|
view=$3
|
||||||
mbid_cur="${4:-}"
|
mbid_cur="${4:-}"
|
||||||
mbid="${5:-}"
|
mbid="${5:-}"
|
||||||
case "$view" in
|
case "$view" in
|
||||||
"$VIEW_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ALBUMS") j="$(mb_releasegroup "$mbid" | $JQ -r --compact-output '."artist-credit"')" ;;
|
"$VIEW_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ALBUMS") j="$(mb_releasegroup "$mbid" | $JQ '."artist-credit"')" ;;
|
||||||
"$VIEW_RELEASEGROUP") j="$(mb_release "$mbid" | $JQ -r --compact-output '."artist-credit"')" ;;
|
"$VIEW_RELEASEGROUP") j="$(mb_release "$mbid" | $JQ '."artist-credit"')" ;;
|
||||||
"$VIEW_RELEASE" | "$VIEW_PLAYLIST") j="$(mb_release "$mbid_cur" | $JQ -r --compact-output ".media | map(.tracks) | flatten[] | select(.id == \"$mbid\") | .\"artist-credit\"")" ;;
|
"$VIEW_RELEASE" | "$VIEW_PLAYLIST") j="$(mb_release "$mbid_cur" | $JQ ".media | map(.tracks) | flatten[] | select(.id == \"$mbid\") | .\"artist-credit\"")" ;;
|
||||||
"$VIEW_SEARCH_ARTIST" | "$VIEW_LIST_ARTISTS") aid="$mbid" ;;
|
"$VIEW_SEARCH_ARTIST" | "$VIEW_LIST_ARTISTS") aid="$mbid" ;;
|
||||||
esac
|
esac
|
||||||
if [ "$view" = "$VIEW_PLAYLIST" ]; then
|
if [ "$view" = "$VIEW_PLAYLIST" ]; then
|
||||||
printf "print(%s)+print(%s)+accept" "$VIEW_SELECT_ARTIST" "$j"
|
printf "print(%s)+print(%s)+print(%s)+print(%s)+accept" "$VIEW_SELECT_ARTIST" "$j" "$view" "$mbid_cur"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
if [ "${j:-}" ]; then
|
if [ "${j:-}" ]; then
|
||||||
cnt=$(echo "$j" | $JQ 'length')
|
cnt=$(echo "$j" | $JQ 'length')
|
||||||
[ "$cnt" -eq 1 ] && aid="$(echo "$j" | $JQ -r '.[0].artist.id')"
|
[ "$cnt" -eq 1 ] && aid="$(echo "$j" | $JQ '.[0].artist.id')"
|
||||||
fi
|
fi
|
||||||
[ "${aid:-}" ] && $0 --draw "$mode" "$VIEW_ARTIST" "$aid" || printf "print(%s)+print(%s)+accept" "$VIEW_SELECT_ARTIST" "$j"
|
[ "${aid:-}" ] && $0 --action-draw "$mode" "$VIEW_ARTIST" "$aid" || printf "print(%s)+print(%s)+print(%s)+print(%s)+accept" "$VIEW_SELECT_ARTIST" "$j" "$view" "$mbid_cur"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"--draw")
|
"--action-draw")
|
||||||
# Generate fzf command to draw screen.
|
# Generate fzf command to draw screen.
|
||||||
#
|
#
|
||||||
# @argument $2: mode (default `normal`)
|
# @argument $2: mode (default `normal`)
|
||||||
@@ -206,8 +234,6 @@ case "${1:-}" in
|
|||||||
# - VIEW_RELEASEGROUP: For single-artist release groups, divert to
|
# - VIEW_RELEASEGROUP: For single-artist release groups, divert to
|
||||||
# VIEW_ARTIST of that artist, else display the artist selection.
|
# VIEW_ARTIST of that artist, else display the artist selection.
|
||||||
# - VIEW_RELEASE: Divert view to VIEW_LIST_RELEASEGROUP.
|
# - VIEW_RELEASE: Divert view to VIEW_LIST_RELEASEGROUP.
|
||||||
#
|
|
||||||
# Hence, the view is only diverted in this last case.
|
|
||||||
mode="${2:-"$MODE_NORMAL"}"
|
mode="${2:-"$MODE_NORMAL"}"
|
||||||
view="${3:-"$VIEW_LIST_ARTISTS"}"
|
view="${3:-"$VIEW_LIST_ARTISTS"}"
|
||||||
mbid="${4:-}"
|
mbid="${4:-}"
|
||||||
@@ -222,11 +248,11 @@ case "${1:-}" in
|
|||||||
;;
|
;;
|
||||||
"$VIEW_RELEASEGROUP")
|
"$VIEW_RELEASEGROUP")
|
||||||
view="$VIEW_ARTIST"
|
view="$VIEW_ARTIST"
|
||||||
mbid="$(mb_releasegroup "$mbid" | $JQ -r --compact-output '."artist-credit"[0].artist.id')"
|
mbid="$(mb_releasegroup "$mbid" | $JQ '."artist-credit"[0].artist.id')"
|
||||||
;;
|
;;
|
||||||
"$VIEW_RELEASE")
|
"$VIEW_RELEASE")
|
||||||
view="$VIEW_RELEASEGROUP"
|
view="$VIEW_RELEASEGROUP"
|
||||||
mbid="$(mb_release "$mbid" | $JQ -r --compact-output '."release-group".id')"
|
mbid="$(mb_release "$mbid" | $JQ '."release-group".id')"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
@@ -264,31 +290,40 @@ case "${1:-}" in
|
|||||||
[ "$mode" = "$MODE_NORMAL" ] && printf "+hide-input"
|
[ "$mode" = "$MODE_NORMAL" ] && printf "+hide-input"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"--fzf-reload")
|
"--mbsearch")
|
||||||
fzf_handle_reload
|
# Trigger search on MusicBrainz
|
||||||
exit 0
|
#
|
||||||
;;
|
# @argument $2: view
|
||||||
"--fzf-load")
|
#
|
||||||
fzf_handle_load
|
# This stops any search being executed and initiates a new query through the
|
||||||
exit 0
|
# MusicBrainz API. The results will be made available through the ``--lines
|
||||||
;;
|
# <view>`` command.
|
||||||
"--fzf-info")
|
|
||||||
fzf_info
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
"--fzf-change-reload")
|
|
||||||
fzf_reload_after_change
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
"--fzf-change")
|
|
||||||
fzf_handle_change "$2"
|
fzf_handle_change "$2"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"--fzf-key")
|
"--preview-artist")
|
||||||
fzf_handle_key "${2:-}" "${3:-}" "${4:-}"
|
# Generate content for artist preview
|
||||||
|
#
|
||||||
|
# @argument $2: MusicBrainz Artist ID
|
||||||
|
#
|
||||||
|
# This prints the text to be displayed in the preview window for the
|
||||||
|
# specified artist.
|
||||||
|
__preview_artist "$2"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Non-interactive user commands intended to the user. These commands do not
|
||||||
|
# require temporary files, fzf, nor the mpv instance.
|
||||||
|
case "${1:-}" in
|
||||||
"--decorate")
|
"--decorate")
|
||||||
|
# Decorate directory with tagged audio files
|
||||||
|
#
|
||||||
|
# @argument $2: path
|
||||||
|
#
|
||||||
|
# This method reads the tags of the audio files in the specified directory.
|
||||||
|
# If the audio files contain MusicBrainz tags, and they are consistent, then
|
||||||
|
# a decoration file is written to that directory.
|
||||||
[ ! "${2:-}" ] && err "You did not specify a directory." && exit 1
|
[ ! "${2:-}" ] && err "You did not specify a directory." && exit 1
|
||||||
[ ! -d "$2" ] && err "Path $2 does not point to a directory." && exit 1
|
[ ! -d "$2" ] && err "Path $2 does not point to a directory." && exit 1
|
||||||
if ! decorate "$2"; then
|
if ! decorate "$2"; then
|
||||||
@@ -298,6 +333,13 @@ case "${1:-}" in
|
|||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"--reload")
|
"--reload")
|
||||||
|
# Reload database of local music
|
||||||
|
#
|
||||||
|
# @argument $2: path
|
||||||
|
#
|
||||||
|
# This method reconstructs the database of locally available music. This is
|
||||||
|
# done by traversing the directories under `path` and looking for decorated
|
||||||
|
# entries.
|
||||||
[ ! "${2:-}" ] && err "Path to decorated music is missing." && exit 1
|
[ ! "${2:-}" ] && err "Path to decorated music is missing." && exit 1
|
||||||
[ ! -d "$2" ] && err "Path does not point to a directory." && exit 1
|
[ ! -d "$2" ] && err "Path does not point to a directory." && exit 1
|
||||||
info "Reloading information of local music directory $2"
|
info "Reloading information of local music directory $2"
|
||||||
@@ -305,41 +347,8 @@ case "${1:-}" in
|
|||||||
info "Done"
|
info "Done"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"--preview-artist")
|
|
||||||
__preview_artist "$2"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
"--playlistcmd")
|
|
||||||
case "$2" in
|
|
||||||
"$PLAYLIST_CMD_REMOVE") mpv_rm_index $((FZF_POS - 1)) ;;
|
|
||||||
"$PLAYLIST_CMD_UP") mpv_playlist_move $((FZF_POS - 1)) $((FZF_POS - 2)) ;;
|
|
||||||
"$PLAYLIST_CMD_DOWN") mpv_playlist_move $((FZF_POS - 0)) $((FZF_POS - 1)) ;;
|
|
||||||
"$PLAYLIST_CMD_CLEAR") mpv_playlist_clear ;;
|
|
||||||
"$PLAYLIST_CMD_CLEAR_ABOVE")
|
|
||||||
for i in $(seq "$FZF_POS"); do
|
|
||||||
mpv_rm_index 0
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
"$PLAYLIST_CMD_CLEAR_BELOW")
|
|
||||||
cnt=$(mpv_playlist_count)
|
|
||||||
rem=$((cnt - FZF_POS + 1))
|
|
||||||
for i in $(seq "$rem"); do
|
|
||||||
mpv_rm_index $((FZF_POS - 1))
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
"--playlist-place-cursor")
|
|
||||||
pos=$(mpv_playlist_position)
|
|
||||||
printf "pos(%s)" $((pos + 1))
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
"--playlist")
|
|
||||||
list_playlist
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
"--help")
|
"--help")
|
||||||
|
# Print help string
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: $0 [OPTION]
|
Usage: $0 [OPTION]
|
||||||
|
|
||||||
@@ -362,32 +371,17 @@ EOF
|
|||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"--refresh-view")
|
"--refresh-view")
|
||||||
|
# Recompute main views
|
||||||
|
#
|
||||||
|
# With this method, the content for the views VIEW_LIST_ARTISTS and VIEW_LIST_ALBUMS are recomputed.
|
||||||
precompute_view
|
precompute_view
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Set window title
|
# Interactive user commands
|
||||||
printf '\033]0;%s\007' "$WINDOW_TITLE"
|
# If no unknown command is passed, then this will continue to starting the mpv
|
||||||
|
# instance and fzf.
|
||||||
# Generate filenames for temporary files
|
|
||||||
tmpdir=$(mktemp -d)
|
|
||||||
LOCKFILE="$tmpdir/lock"
|
|
||||||
RESULTS="$tmpdir/results"
|
|
||||||
PIDFILE="$tmpdir/pid"
|
|
||||||
trap 'rm -rf "$tmpdir"' EXIT INT
|
|
||||||
export LOCKFILE RESULTS PIDFILE
|
|
||||||
|
|
||||||
statedir=$(mktemp -d)
|
|
||||||
STATEFILE="$statedir/state"
|
|
||||||
ARGSFILE="$statedir/state-args"
|
|
||||||
STATEFILE_LAST="$statedir/state2"
|
|
||||||
ARGSFILE_LAST="$statedir/state-args2"
|
|
||||||
touch "$STATEFILE" "$ARGSFILE" "$STATEFILE_LAST" "$ARGSFILE_LAST"
|
|
||||||
export STATEFILE ARGSFILE STATEFILE_LAST ARGSFILE_LAST
|
|
||||||
|
|
||||||
# Views and modes
|
|
||||||
|
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
"--artist")
|
"--artist")
|
||||||
[ ! "${2:-}" ] && err "MusicBrainz Artist ID not specified (see --help)" && exit 1
|
[ ! "${2:-}" ] && err "MusicBrainz Artist ID not specified (see --help)" && exit 1
|
||||||
@@ -408,7 +402,6 @@ case "${1:-}" in
|
|||||||
MBID="$2"
|
MBID="$2"
|
||||||
;;
|
;;
|
||||||
"--search-artist")
|
"--search-artist")
|
||||||
state_init "$VIEW_SEARCH_ARTIST" "$MODE_INSERT" "${2:-}"
|
|
||||||
VIEW="$VIEW_SEARCH_ARTIST"
|
VIEW="$VIEW_SEARCH_ARTIST"
|
||||||
MODE="$MODE_INSERT"
|
MODE="$MODE_INSERT"
|
||||||
MBID=""
|
MBID=""
|
||||||
@@ -434,6 +427,47 @@ case "${1:-}" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Start application:
|
||||||
|
# - load configuration
|
||||||
|
# - load and export theme
|
||||||
|
# - load and export preset filters
|
||||||
|
# - load and export keys
|
||||||
|
# - load and export tools
|
||||||
|
# - load and export awk scripts
|
||||||
|
# - set title
|
||||||
|
# - get temporary directory for temporary files
|
||||||
|
# - start mpv daemon
|
||||||
|
# - enter main loop and start fzf
|
||||||
|
|
||||||
|
# Load configuration
|
||||||
|
. "sh/config.sh"
|
||||||
|
|
||||||
|
# Load theme
|
||||||
|
. "sh/theme.sh"
|
||||||
|
|
||||||
|
# Load filters
|
||||||
|
. "sh/filter.sh"
|
||||||
|
|
||||||
|
# Load keys
|
||||||
|
. "sh/keys.sh"
|
||||||
|
|
||||||
|
# Load tools
|
||||||
|
. "sh/tools.sh"
|
||||||
|
|
||||||
|
# Load AWK scripts
|
||||||
|
. "sh/awk.sh"
|
||||||
|
|
||||||
|
# Set window title
|
||||||
|
printf '\033]0;%s\007' "$WINDOW_TITLE"
|
||||||
|
|
||||||
|
# Generate filenames for temporary files
|
||||||
|
tmpdir=$(mktemp -d)
|
||||||
|
LOCKFILE="$tmpdir/lock"
|
||||||
|
RESULTS="$tmpdir/results"
|
||||||
|
PIDFILE="$tmpdir/pid"
|
||||||
|
trap 'rm -rf "$tmpdir"' EXIT INT
|
||||||
|
export LOCKFILE RESULTS PIDFILE
|
||||||
|
|
||||||
# Start mpv
|
# Start mpv
|
||||||
mpv_start
|
mpv_start
|
||||||
|
|
||||||
@@ -455,25 +489,30 @@ mpv_start
|
|||||||
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_BORDER_LABEL = %s ]"
|
||||||
IN_LIST_ARTISTS_VIEW="$(printf "$IN_VIEW_PATTERN" "$VIEW_LIST_ARTISTS")"
|
IN_LIST_ARTISTS_VIEW="$(printf "$IN_VIEW_PATTERN" "$VIEW_LIST_ARTISTS")"
|
||||||
IN_LIST_ALBUMS_VIEW="$(printf "$IN_VIEW_PATTERN" "$VIEW_LIST_ALBUMS")"
|
|
||||||
IN_SEARCH_ARTIST_VIEW="$(printf "$IN_VIEW_PATTERN" "$VIEW_SEARCH_ARTIST")"
|
|
||||||
IN_SEARCH_ALBUM_VIEW="$(printf "$IN_VIEW_PATTERN" "$VIEW_SEARCH_ALBUM")"
|
|
||||||
FZF_CURRENT_MODE="\$FZF_INPUT_STATE"
|
FZF_CURRENT_MODE="\$FZF_INPUT_STATE"
|
||||||
FZF_CURRENT_VIEW="\$FZF_BORDER_LABEL"
|
FZF_CURRENT_VIEW="\$FZF_BORDER_LABEL"
|
||||||
FZF_RELOAD_PLAYLIST="reload-sync($0 --playlist)"
|
FZF_RELOAD_PLAYLIST="reload-sync($0 --lines $VIEW_PLAYLIST)"
|
||||||
FZF_POS_PLAYLIST="transform:$0 --playlist-place-cursor"
|
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"
|
||||||
while true; do
|
while true; do
|
||||||
case "$VIEW" in
|
case "$VIEW" in
|
||||||
"$VIEW_SELECT_ARTIST")
|
"$VIEW_SELECT_ARTIST")
|
||||||
|
info "SELECT ARTIST VIEW with ARGS=$ARGS"
|
||||||
|
info "$(echo "$ARGS" | list_artists_from_json)"
|
||||||
sel=$(
|
sel=$(
|
||||||
echo "$ARGS" |
|
echo "$ARGS" | list_artists_from_json | $FZF \
|
||||||
list_artists_from_json |
|
--bind="$KEYS_DOWN:down" \
|
||||||
$FZF \
|
--bind="$KEYS_UP:up" \
|
||||||
--bind="$KEYS_HALFPAGE_DOWN,$KEYS_HALFPAGE_UP,\
|
--bind="$KEYS_HALFPAGE_DOWN:half-page-down" \
|
||||||
$KEYS_BROWSE,\
|
--bind="$KEYS_HALFPAGE_UP:half-page-up" \
|
||||||
$KEYS_OPEN,\
|
--bind="enter,$KEYS_IN:print($VIEW_ARTIST)+accept" \
|
||||||
$KEYS_FILTER_LOCAL:transform:$0 --fzf-key {2} {3} {4}" \
|
--bind="$KEYS_OUT,$KEYS_QUIT:print($LASTVIEW)+print($LASTARG)+accept" \
|
||||||
|
--bind="$KEYS_LIST_ARTISTS:print($VIEW_LIST_ARTISTS)+accept" \
|
||||||
|
--bind="$KEYS_LIST_ALBUMS:print($VIEW_LIST_ALBUMS)+accept" \
|
||||||
|
--bind="$KEYS_SEARCH_ARTIST:print($VIEW_SEARCH_ARTIST)+accept" \
|
||||||
|
--bind="$KEYS_SEARCH_ALBUM:print($VIEW_SEARCH_ALBUM)+accept" \
|
||||||
|
--bind="$KEYS_BROWSE:execute-silent:open \"https://musicbrainz.org/artist/{r3}\"" \
|
||||||
|
--bind="$KEYS_SHOW_PLAYLIST:print($VIEW_PLAYLIST)+print()+accept" \
|
||||||
-0 -1 \
|
-0 -1 \
|
||||||
--border="bold" \
|
--border="bold" \
|
||||||
--border-label="Select artist" \
|
--border-label="Select artist" \
|
||||||
@@ -484,10 +523,16 @@ $KEYS_FILTER_LOCAL:transform:$0 --fzf-key {2} {3} {4}" \
|
|||||||
--accept-nth="{3}" \
|
--accept-nth="{3}" \
|
||||||
--with-nth="{1}" || true
|
--with-nth="{1}" || true
|
||||||
)
|
)
|
||||||
[ "$sel" ] || continue
|
lines=$(echo "$sel" | wc -l)
|
||||||
MODE="$MODE_NORMAL"
|
if [ "$lines" -eq 1 ]; then
|
||||||
VIEW="$VIEW_ARTIST"
|
VIEW="$VIEW_ARTIST"
|
||||||
MBID="$sel"
|
MBID="$sel"
|
||||||
|
else
|
||||||
|
VIEW="$(echo "$sel" | head -1)"
|
||||||
|
MBID="$(echo "$sel" | head -2 | tail -1)"
|
||||||
|
fi
|
||||||
|
LASTVIEW="$VIEW_SELECT_ARTIST"
|
||||||
|
LASTARG="$ARGS"
|
||||||
;;
|
;;
|
||||||
"$VIEW_PLAYLIST")
|
"$VIEW_PLAYLIST")
|
||||||
sel=$(
|
sel=$(
|
||||||
@@ -504,7 +549,8 @@ $KEYS_FILTER_LOCAL:transform:$0 --fzf-key {2} {3} {4}" \
|
|||||||
--bind="$KEYS_HALFPAGE_UP:half-page-up" \
|
--bind="$KEYS_HALFPAGE_UP:half-page-up" \
|
||||||
--bind="$KEYS_N_BOT:last" \
|
--bind="$KEYS_N_BOT:last" \
|
||||||
--bind="$KEYS_N_TOP:first" \
|
--bind="$KEYS_N_TOP:first" \
|
||||||
--bind="$KEYS_SELECT_ARTIST:transform:$0 --jumpto-artist $MODE_NORMAL $VIEW_PLAYLIST {2} {3}" \
|
--bind="$KEYS_OUT,$KEYS_N_OUT,$KEYS_QUIT,$KEYS_N_QUIT:print($LASTVIEW)+print($LASTARG)+print($VIEW_PLAYLIST)+print()+accept" \
|
||||||
|
--bind="$KEYS_SELECT_ARTIST:transform:$0 --action-gotoartist $MODE_NORMAL $VIEW_PLAYLIST {2} {3}" \
|
||||||
--bind="$KEYS_LIST_ARTISTS:print($VIEW_LIST_ARTISTS)+accept" \
|
--bind="$KEYS_LIST_ARTISTS:print($VIEW_LIST_ARTISTS)+accept" \
|
||||||
--bind="$KEYS_LIST_ALBUMS:print($VIEW_LIST_ALBUMS)+accept" \
|
--bind="$KEYS_LIST_ALBUMS:print($VIEW_LIST_ALBUMS)+accept" \
|
||||||
--bind="$KEYS_SEARCH_ARTIST:print($VIEW_SEARCH_ARTIST)+accept" \
|
--bind="$KEYS_SEARCH_ARTIST:print($VIEW_SEARCH_ARTIST)+accept" \
|
||||||
@@ -513,14 +559,13 @@ $KEYS_FILTER_LOCAL:transform:$0 --fzf-key {2} {3} {4}" \
|
|||||||
--bind="$KEYS_OPEN:execute-silent:open \"\$(dirname {4})\"" \
|
--bind="$KEYS_OPEN:execute-silent:open \"\$(dirname {4})\"" \
|
||||||
--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 --playlistcmd $PLAYLIST_CMD_REMOVE)+$FZF_RELOAD_PLAYLIST" \
|
--bind="$KEYS_PLAYLIST_REMOVE:execute-silent($0 --playlist $PLAYLIST_CMD_REMOVE)+$FZF_RELOAD_PLAYLIST" \
|
||||||
--bind="$KEYS_PLAYLIST_UP:execute-silent($0 --playlistcmd $PLAYLIST_CMD_UP)+up+$FZF_RELOAD_PLAYLIST" \
|
--bind="$KEYS_PLAYLIST_UP:execute-silent($0 --playlist $PLAYLIST_CMD_UP)+up+$FZF_RELOAD_PLAYLIST" \
|
||||||
--bind="$KEYS_PLAYLIST_DOWN:execute-silent($0 --playlistcmd $PLAYLIST_CMD_DOWN)+down+$FZF_RELOAD_PLAYLIST" \
|
--bind="$KEYS_PLAYLIST_DOWN:execute-silent($0 --playlist $PLAYLIST_CMD_DOWN)+down+$FZF_RELOAD_PLAYLIST" \
|
||||||
--bind="$KEYS_PLAYLIST_CLEAR:execute-silent($0 --playlistcmd $PLAYLIST_CMD_CLEAR)+$FZF_RELOAD_PLAYLIST" \
|
--bind="$KEYS_PLAYLIST_CLEAR:execute-silent($0 --playlist $PLAYLIST_CMD_CLEAR)+$FZF_RELOAD_PLAYLIST" \
|
||||||
--bind="$KEYS_PLAYLIST_CLEAR_ABOVE:execute-silent($0 --playlistcmd $PLAYLIST_CMD_CLEAR_ABOVE)+$FZF_RELOAD_PLAYLIST" \
|
--bind="$KEYS_PLAYLIST_CLEAR_ABOVE:execute-silent($0 --playlist $PLAYLIST_CMD_CLEAR_ABOVE)+$FZF_RELOAD_PLAYLIST" \
|
||||||
--bind="$KEYS_PLAYLIST_CLEAR_BELOW:execute-silent($0 --playlistcmd $PLAYLIST_CMD_CLEAR_BELOW)+$FZF_RELOAD_PLAYLIST" \
|
--bind="$KEYS_PLAYLIST_CLEAR_BELOW:execute-silent($0 --playlist $PLAYLIST_CMD_CLEAR_BELOW)+$FZF_RELOAD_PLAYLIST" \
|
||||||
--bind="$KEYS_PLAYLIST_GOTO_RELEASE:print($VIEW_RELEASE)+accept" \
|
--bind="$KEYS_PLAYLIST_GOTO_RELEASE:print($VIEW_RELEASE)+accept" \
|
||||||
--bind="$KEYS_PLAYLIST_QUIT:print($VIEW_LIST_ARTISTS)+accept" \
|
|
||||||
--delimiter="\t" \
|
--delimiter="\t" \
|
||||||
--with-nth="{1}" \
|
--with-nth="{1}" \
|
||||||
--accept-nth="{2}" || true
|
--accept-nth="{2}" || true
|
||||||
@@ -528,6 +573,8 @@ $KEYS_FILTER_LOCAL:transform:$0 --fzf-key {2} {3} {4}" \
|
|||||||
VIEW="$(echo "$sel" | head -1)"
|
VIEW="$(echo "$sel" | head -1)"
|
||||||
ARGS="$(echo "$sel" | head -2 | tail -1)"
|
ARGS="$(echo "$sel" | head -2 | tail -1)"
|
||||||
MBID=$ARGS
|
MBID=$ARGS
|
||||||
|
LASTVIEW="$(echo "$sel" | head -3 | tail -1)"
|
||||||
|
LASTARG="$(echo "$sel" | head -4 | tail -1)"
|
||||||
;;
|
;;
|
||||||
"$VIEW_QUIT")
|
"$VIEW_QUIT")
|
||||||
break
|
break
|
||||||
@@ -552,7 +599,7 @@ $KEYS_FILTER_LOCAL:transform:$0 --fzf-key {2} {3} {4}" \
|
|||||||
--info="inline-right" \
|
--info="inline-right" \
|
||||||
--header-first \
|
--header-first \
|
||||||
--header-border="bottom" \
|
--header-border="bottom" \
|
||||||
--bind="start:transform:$0 --draw $MODE $VIEW $MBID" \
|
--bind="start:transform:$0 --action-draw $MODE $VIEW $MBID" \
|
||||||
--bind="$KEYS_I_NORMAL:transform:$IN_NORMAL_MODE || echo hide-input" \
|
--bind="$KEYS_I_NORMAL:transform:$IN_NORMAL_MODE || echo hide-input" \
|
||||||
--bind="$KEYS_N_INSERT:transform:$IN_NORMAL_MODE && echo show-input || $PUT_FZF_KEY_LOGIC" \
|
--bind="$KEYS_N_INSERT:transform:$IN_NORMAL_MODE && echo show-input || $PUT_FZF_KEY_LOGIC" \
|
||||||
--bind="$KEYS_DOWN:down" \
|
--bind="$KEYS_DOWN:down" \
|
||||||
@@ -563,28 +610,28 @@ $KEYS_FILTER_LOCAL:transform:$0 --fzf-key {2} {3} {4}" \
|
|||||||
--bind="$KEYS_N_UP:transform:$IN_NORMAL_MODE && echo up || $PUT_FZF_KEY_LOGIC" \
|
--bind="$KEYS_N_UP:transform:$IN_NORMAL_MODE && echo up || $PUT_FZF_KEY_LOGIC" \
|
||||||
--bind="$KEYS_N_BOT:transform:$IN_NORMAL_MODE && echo last || $PUT_FZF_KEY_LOGIC" \
|
--bind="$KEYS_N_BOT:transform:$IN_NORMAL_MODE && echo last || $PUT_FZF_KEY_LOGIC" \
|
||||||
--bind="$KEYS_N_TOP:transform:$IN_NORMAL_MODE && echo first || $PUT_FZF_KEY_LOGIC" \
|
--bind="$KEYS_N_TOP:transform:$IN_NORMAL_MODE && echo first || $PUT_FZF_KEY_LOGIC" \
|
||||||
--bind="$KEYS_IN:transform:[ {3} ] && $0 --draw $FZF_CURRENT_MODE $FZF_CURRENT_VIEW {3} \"+1\"" \
|
--bind="$KEYS_IN:transform:[ {3} ] && $0 --action-draw $FZF_CURRENT_MODE $FZF_CURRENT_VIEW {3} \"+1\"" \
|
||||||
--bind="$KEYS_OUT:transform:[ {2} ] && $0 --draw $FZF_CURRENT_MODE $FZF_CURRENT_VIEW {2} \"-1\"" \
|
--bind="$KEYS_OUT:transform:[ {2} ] && $0 --action-draw $FZF_CURRENT_MODE $FZF_CURRENT_VIEW {2} \"-1\"" \
|
||||||
--bind="$KEYS_N_IN:transform:$IN_NORMAL_MODE && ([ {3} ] && $0 --draw $FZF_CURRENT_MODE $FZF_CURRENT_VIEW {3} \"+1\") || $PUT_FZF_KEY_LOGIC" \
|
--bind="$KEYS_N_IN:transform:$IN_NORMAL_MODE && ([ {3} ] && $0 --action-draw $FZF_CURRENT_MODE $FZF_CURRENT_VIEW {3} \"+1\") || $PUT_FZF_KEY_LOGIC" \
|
||||||
--bind="$KEYS_N_OUT:transform:$IN_NORMAL_MODE && ([ {2} ] && $0 --draw $FZF_CURRENT_MODE $FZF_CURRENT_VIEW {2} \"-1\") || $PUT_FZF_KEY_LOGIC" \
|
--bind="$KEYS_N_OUT:transform:$IN_NORMAL_MODE && ([ {2} ] && $0 --action-draw $FZF_CURRENT_MODE $FZF_CURRENT_VIEW {2} \"-1\") || $PUT_FZF_KEY_LOGIC" \
|
||||||
--bind="$KEYS_SELECT_ARTIST:transform:$0 --jumpto-artist $FZF_CURRENT_MODE $FZF_CURRENT_VIEW {2} {3}" \
|
--bind="$KEYS_SELECT_ARTIST:transform:$0 --action-gotoartist $FZF_CURRENT_MODE $FZF_CURRENT_VIEW {2} {3}" \
|
||||||
--bind="$KEYS_LIST_ARTISTS:transform:$0 --draw \$FZF_INPUT_STATE $VIEW_LIST_ARTISTS" \
|
--bind="$KEYS_LIST_ARTISTS:transform:$0 --action-draw \$FZF_INPUT_STATE $VIEW_LIST_ARTISTS" \
|
||||||
--bind="$KEYS_LIST_ALBUMS:transform:$0 --draw \$FZF_INPUT_STATE $VIEW_LIST_ALBUMS" \
|
--bind="$KEYS_LIST_ALBUMS:transform:$0 --action-draw \$FZF_INPUT_STATE $VIEW_LIST_ALBUMS" \
|
||||||
--bind="$KEYS_SEARCH_ARTIST:transform:$0 --draw $MODE_INSERT $VIEW_SEARCH_ARTIST" \
|
--bind="$KEYS_SEARCH_ARTIST:transform:$0 --action-draw $MODE_INSERT $VIEW_SEARCH_ARTIST" \
|
||||||
--bind="$KEYS_SEARCH_ALBUM:transform:$0 --draw $MODE_INSERT $VIEW_SEARCH_ALBUM" \
|
--bind="$KEYS_SEARCH_ALBUM:transform:$0 --action-draw $MODE_INSERT $VIEW_SEARCH_ALBUM" \
|
||||||
--bind="$KEYS_SWITCH_ARTIST_ALBUM:transform:case $FZF_CURRENT_VIEW in
|
--bind="$KEYS_SWITCH_ARTIST_ALBUM:transform:case $FZF_CURRENT_VIEW in
|
||||||
$VIEW_LIST_ARTISTS) $0 --draw $FZF_CURRENT_MODE $VIEW_LIST_ALBUMS ;;
|
$VIEW_LIST_ARTISTS) $0 --action-draw $FZF_CURRENT_MODE $VIEW_LIST_ALBUMS ;;
|
||||||
$VIEW_LIST_ALBUMS) $0 --draw $FZF_CURRENT_MODE $VIEW_LIST_ARTISTS ;;
|
$VIEW_LIST_ALBUMS) $0 --action-draw $FZF_CURRENT_MODE $VIEW_LIST_ARTISTS ;;
|
||||||
$VIEW_SEARCH_ARTIST) $0 --draw $MODE_INSERT $VIEW_SEARCH_ALBUM ;;
|
$VIEW_SEARCH_ARTIST) $0 --action-draw $MODE_INSERT $VIEW_SEARCH_ALBUM ;;
|
||||||
$VIEW_SEARCH_ALBUM) $0 --draw $MODE_INSERT $VIEW_SEARCH_ARTIST ;;
|
$VIEW_SEARCH_ALBUM) $0 --action-draw $MODE_INSERT $VIEW_SEARCH_ARTIST ;;
|
||||||
esac" \
|
esac" \
|
||||||
--bind="$KEYS_SWITCH_LOCAL_REMOTE:transform:case $FZF_CURRENT_VIEW in
|
--bind="$KEYS_SWITCH_LOCAL_REMOTE:transform:case $FZF_CURRENT_VIEW in
|
||||||
$VIEW_LIST_ARTISTS) $0 --draw $MODE_INSERT $VIEW_SEARCH_ARTIST ;;
|
$VIEW_LIST_ARTISTS) $0 --action-draw $MODE_INSERT $VIEW_SEARCH_ARTIST ;;
|
||||||
$VIEW_LIST_ALBUMS) $0 --draw $MODE_INSERT $VIEW_SEARCH_ALBUM ;;
|
$VIEW_LIST_ALBUMS) $0 --action-draw $MODE_INSERT $VIEW_SEARCH_ALBUM ;;
|
||||||
$VIEW_SEARCH_ARTIST) $0 --draw $MODE_NORMAL $VIEW_LIST_ARTISTS ;;
|
$VIEW_SEARCH_ARTIST) $0 --action-draw $MODE_NORMAL $VIEW_LIST_ARTISTS ;;
|
||||||
$VIEW_SEARCH_ALBUM) $0 --draw $MODE_NORMAL $VIEW_LIST_ALBUMS ;;
|
$VIEW_SEARCH_ALBUM) $0 --action-draw $MODE_NORMAL $VIEW_LIST_ALBUMS ;;
|
||||||
esac" \
|
esac" \
|
||||||
--bind="$KEYS_FILTER:transform:$0 --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_BORDER_LABEL in
|
||||||
@@ -597,12 +644,12 @@ open \"https://musicbrainz.org/\$t/{r3}\"" \
|
|||||||
--bind="$KEYS_OPEN:execute-silent:
|
--bind="$KEYS_OPEN:execute-silent:
|
||||||
[ {4} ] || exit 0
|
[ {4} ] || exit 0
|
||||||
open \"\$(dirname {4})\"" \
|
open \"\$(dirname {4})\"" \
|
||||||
--bind="$KEYS_SHOW_PLAYLIST:print($VIEW_PLAYLIST)+accept" \
|
--bind="$KEYS_SHOW_PLAYLIST:transform:echo \"print($VIEW_PLAYLIST)+print()+print($FZF_CURRENT_VIEW)+print({2})+accept\"" \
|
||||||
--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 --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_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="change:execute-silent($0 --fzf-change $FZF_CURRENT_VIEW &)+reload:$0 --fzf-change-reload" \
|
--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-artist {3}" \
|
||||||
--delimiter="\t" \
|
--delimiter="\t" \
|
||||||
@@ -610,10 +657,8 @@ open \"\$(dirname {4})\"" \
|
|||||||
)
|
)
|
||||||
VIEW="$(echo "$sel" | head -1)"
|
VIEW="$(echo "$sel" | head -1)"
|
||||||
ARGS="$(echo "$sel" | head -2 | tail -1)"
|
ARGS="$(echo "$sel" | head -2 | tail -1)"
|
||||||
|
LASTVIEW="$(echo "$sel" | head -3 | tail -1)"
|
||||||
|
LASTARG="$(echo "$sel" | head -4 | tail -1)"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
#[ \"$MODE\" = \"$MODE_NORMAL\" ] && echo \"+hide-input\" || echo \"+show-input\"
|
|
||||||
# --bind="load:transform:$0 --fzf-load" \
|
|
||||||
# --bind="change:execute-silent($0 --fzf-change &)+reload:$0 --fzf-change-reload" \
|
|
||||||
# --bind="$KEYS_ALL:transform:$0 --fzf-key {2} {3} {4}" \
|
|
||||||
|
@@ -2,7 +2,6 @@ MB_MAX_RETRIES=10
|
|||||||
MB_BROWSE_STEPS=100
|
MB_BROWSE_STEPS=100
|
||||||
USER_AGENT="$APP_NAME/$APP_VERSION ($APP_WEBSITE)"
|
USER_AGENT="$APP_NAME/$APP_VERSION ($APP_WEBSITE)"
|
||||||
SLEEP_ON_ERROR=1
|
SLEEP_ON_ERROR=1
|
||||||
export MB_BROWSE_STEPS
|
|
||||||
|
|
||||||
__api_mb() {
|
__api_mb() {
|
||||||
tmpout=$(mktemp)
|
tmpout=$(mktemp)
|
||||||
|
@@ -1,27 +1,31 @@
|
|||||||
AWK_ARTISTS=$(
|
if [ ! "${AWK_LOADED:-}" ]; then
|
||||||
|
AWK_ARTISTS=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include awk/artists.awk
|
@@include awk/artists.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_ARTISTS
|
export AWK_ARTISTS
|
||||||
|
|
||||||
AWK_RELEASES=$(
|
AWK_RELEASES=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include awk/releases.awk
|
@@include awk/releases.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_RELEASES
|
export AWK_RELEASES
|
||||||
|
|
||||||
AWK_RELEASEGROUPS=$(
|
AWK_RELEASEGROUPS=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include awk/releasegroups.awk
|
@@include awk/releasegroups.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_RELEASEGROUPS
|
export AWK_RELEASEGROUPS
|
||||||
|
|
||||||
AWK_RECORDINGS=$(
|
AWK_RECORDINGS=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include awk/recordings.awk
|
@@include awk/recordings.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_RECORDINGS
|
export AWK_RECORDINGS
|
||||||
|
|
||||||
|
export AWK_LOADED=1
|
||||||
|
fi
|
||||||
|
@@ -82,7 +82,7 @@ cache_append_artist_releasegroups() {
|
|||||||
cat >"$tmpf"
|
cat >"$tmpf"
|
||||||
updated=$(mktemp)
|
updated=$(mktemp)
|
||||||
f="$CACHEDIR/$TYPE_ARTIST/$(__radix "$1")/$artist_releasegroups_filename"
|
f="$CACHEDIR/$TYPE_ARTIST/$(__radix "$1")/$artist_releasegroups_filename"
|
||||||
$JQ -r --slurpfile n "$tmpf" '."release-groups" += ($n[0]|."release-groups")' "$f" >"$updated" && mv "$updated" "$f"
|
$JQ --slurpfile n "$tmpf" '."release-groups" += ($n[0]|."release-groups")' "$f" >"$updated" && mv "$updated" "$f"
|
||||||
rm -f "$tmpf"
|
rm -f "$tmpf"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ cache_append_releasegroup_releases() {
|
|||||||
cat >"$tmpf"
|
cat >"$tmpf"
|
||||||
updated=$(mktemp)
|
updated=$(mktemp)
|
||||||
f="$CACHEDIR/$TYPE_RELEASEGROUP/$(__radix "$1")/$releasegroup_releases_filename"
|
f="$CACHEDIR/$TYPE_RELEASEGROUP/$(__radix "$1")/$releasegroup_releases_filename"
|
||||||
$JQ -r --slurpfile n "$tmpf" '."releases" += ($n[0]|."releases")' "$f" >"$updated" && mv "$updated" "$f"
|
$JQ --slurpfile n "$tmpf" '."releases" += ($n[0]|."releases")' "$f" >"$updated" && mv "$updated" "$f"
|
||||||
rm -f "$tmpf"
|
rm -f "$tmpf"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
# Configuration capabilities
|
||||||
CONFIGFILE_DEFAULT="$HOME/.config/$APP_NAME/config"
|
CONFIGFILE_DEFAULT="$HOME/.config/$APP_NAME/config"
|
||||||
CONFIGFILE="${CONFIGFILE:-"$CONFIGFILE_DEFAULT"}"
|
CONFIGFILE="${CONFIGFILE:-"$CONFIGFILE_DEFAULT"}"
|
||||||
[ "$CONFIGFILE" != "$CONFIGFILE_DEFAULT" ] && [ ! -f "$CONFIGFILE" ] && err "The configuration file manually specified with the environment variable CONFIGFILE=($CONFIGFILE) does not exist." && exit 1
|
[ "$CONFIGFILE" != "$CONFIGFILE_DEFAULT" ] && [ ! -f "$CONFIGFILE" ] && err "The configuration file manually specified with the environment variable CONFIGFILE=($CONFIGFILE) does not exist." && exit 1
|
||||||
|
173
src/sh/filter.sh
173
src/sh/filter.sh
@@ -1,34 +1,6 @@
|
|||||||
# The default queries depend on the current view, and are usually derived from
|
# Preset filters
|
||||||
# the theme. Nevertheless, they may be overwritten with the configuration file.
|
|
||||||
# Note that filters are not used in the views VIEW_SEARCH_ARTIST and
|
|
||||||
# VIEW_SEARCH_ALBUM. The reason for this is that in those modes, changing the
|
|
||||||
# query string triggers a search on the MusicBrainz website (the input is not a
|
|
||||||
# filter, but a query).
|
|
||||||
#
|
#
|
||||||
# The keybinding KEYS_FILTER_LOCAL triggers a filter of QUERY_LOCAL in the
|
# See `src/sh/query.sh` for details and the associated methods.
|
||||||
# views VIEW_ARTIST, VIEW_RELEASEGROUP, and VIEW_RELEASE only. Here, it is only
|
|
||||||
# possible to adjust QUERY_LOCAL via the configuration. The keybinding KEYS_FILTER_0
|
|
||||||
# resets the query. F_1_.. filters are the default filters when the respective
|
|
||||||
# view is entered. For all other keys, the filters are individually
|
|
||||||
# configurable, by specifying e.g., F_3_VIEW_LIST_ALBUMS.
|
|
||||||
#
|
|
||||||
# Derived queries
|
|
||||||
# To derive the queries from the theme, we must perform some steps: 1) remove
|
|
||||||
# colors, and 2) escape white spaces. This is implemented in the method
|
|
||||||
# `__clean_filter`.
|
|
||||||
#
|
|
||||||
# List of derived queries:
|
|
||||||
# - QUERY_LOCAL: Hide items that are not locally available
|
|
||||||
# - q_has_secondary: Release groups with secondary types
|
|
||||||
# - q_album: Release group is of type Album
|
|
||||||
# - q_ep: Release group is of type EP
|
|
||||||
# - q_single: Release group is of type single
|
|
||||||
# - q_official: Release is official
|
|
||||||
|
|
||||||
__clean_filter() {
|
|
||||||
cat | sed "s/${ESC}\[[0-9;]*[mK]//g" | sed "s/ /\\\ /g"
|
|
||||||
}
|
|
||||||
|
|
||||||
QUERY_LOCAL="${QUERY_LOCAL:-"$(printf "'%s'" "$FORMAT_LOCAL" | __clean_filter)"}"
|
QUERY_LOCAL="${QUERY_LOCAL:-"$(printf "'%s'" "$FORMAT_LOCAL" | __clean_filter)"}"
|
||||||
q_has_seconary="$(printf "$FORMAT_TYPE_HAS_SECONDARY" "" | __clean_filter)"
|
q_has_seconary="$(printf "$FORMAT_TYPE_HAS_SECONDARY" "" | __clean_filter)"
|
||||||
q_album="$(printf "%s" "$FORMAT_TYPE_ALBUM" | __clean_filter)"
|
q_album="$(printf "%s" "$FORMAT_TYPE_ALBUM" | __clean_filter)"
|
||||||
@@ -37,6 +9,7 @@ q_single=$(printf "%s" "$FORMAT_TYPE_SINGLE" | sed "s/${ESC}\[[0-9;]*[mK]//g" |
|
|||||||
if printf "$RV_FORMAT" | grep -q "<<status>>"; then
|
if printf "$RV_FORMAT" | grep -q "<<status>>"; then
|
||||||
q_official=$(printf "'%s'" "$FORMAT_STATUS_OFFICIAL" | sed "s/${ESC}\[[0-9;]*[mK]//g" | sed "s/ /\\\ /g")
|
q_official=$(printf "'%s'" "$FORMAT_STATUS_OFFICIAL" | sed "s/${ESC}\[[0-9;]*[mK]//g" | sed "s/ /\\\ /g")
|
||||||
fi
|
fi
|
||||||
|
export QUERY_LOCAL
|
||||||
|
|
||||||
F_1_VIEW_ARTIST="${F_1_VIEW_ARTIST:-"!'$q_has_seconary'"}"
|
F_1_VIEW_ARTIST="${F_1_VIEW_ARTIST:-"!'$q_has_seconary'"}"
|
||||||
F_2_VIEW_ARTIST="${F_2_VIEW_ARTIST:-"'$q_album'"}"
|
F_2_VIEW_ARTIST="${F_2_VIEW_ARTIST:-"'$q_album'"}"
|
||||||
@@ -47,6 +20,9 @@ F_6_VIEW_ARTIST="${F_6_VIEW_ARTIST:-}"
|
|||||||
F_7_VIEW_ARTIST="${F_7_VIEW_ARTIST:-}"
|
F_7_VIEW_ARTIST="${F_7_VIEW_ARTIST:-}"
|
||||||
F_8_VIEW_ARTIST="${F_8_VIEW_ARTIST:-}"
|
F_8_VIEW_ARTIST="${F_8_VIEW_ARTIST:-}"
|
||||||
F_9_VIEW_ARTIST="${F_9_VIEW_ARTIST:-}"
|
F_9_VIEW_ARTIST="${F_9_VIEW_ARTIST:-}"
|
||||||
|
export F_1_VIEW_ARTIST F_2_VIEW_ARTIST F_3_VIEW_ARTIST F_4_VIEW_ARTIST \
|
||||||
|
F_5_VIEW_ARTIST F_6_VIEW_ARTIST F_7_VIEW_ARTIST F_8_VIEW_ARTIST \
|
||||||
|
F_9_VIEW_ARTIST
|
||||||
|
|
||||||
F_1_VIEW_RELEASEGROUP="${F_1_VIEW_RELEASEGROUP:-"${q_official:-}"}"
|
F_1_VIEW_RELEASEGROUP="${F_1_VIEW_RELEASEGROUP:-"${q_official:-}"}"
|
||||||
F_2_VIEW_RELEASEGROUP="${F_2_VIEW_RELEASEGROUP:-}"
|
F_2_VIEW_RELEASEGROUP="${F_2_VIEW_RELEASEGROUP:-}"
|
||||||
@@ -57,6 +33,9 @@ F_6_VIEW_RELEASEGROUP="${F_6_VIEW_RELEASEGROUP:-}"
|
|||||||
F_7_VIEW_RELEASEGROUP="${F_7_VIEW_RELEASEGROUP:-}"
|
F_7_VIEW_RELEASEGROUP="${F_7_VIEW_RELEASEGROUP:-}"
|
||||||
F_8_VIEW_RELEASEGROUP="${F_8_VIEW_RELEASEGROUP:-}"
|
F_8_VIEW_RELEASEGROUP="${F_8_VIEW_RELEASEGROUP:-}"
|
||||||
F_9_VIEW_RELEASEGROUP="${F_9_VIEW_RELEASEGROUP:-}"
|
F_9_VIEW_RELEASEGROUP="${F_9_VIEW_RELEASEGROUP:-}"
|
||||||
|
export F_1_VIEW_RELEASEGROUP F_2_VIEW_RELEASEGROUP F_3_VIEW_RELEASEGROUP \
|
||||||
|
F_4_VIEW_RELEASEGROUP F_5_VIEW_RELEASEGROUP F_6_VIEW_RELEASEGROUP \
|
||||||
|
F_7_VIEW_RELEASEGROUP F_8_VIEW_RELEASEGROUP F_9_VIEW_RELEASEGROUP
|
||||||
|
|
||||||
F_1_VIEW_RELEASE="${F_1_VIEW_RELEASE:-}"
|
F_1_VIEW_RELEASE="${F_1_VIEW_RELEASE:-}"
|
||||||
F_2_VIEW_RELEASE="${F_2_VIEW_RELEASE:-}"
|
F_2_VIEW_RELEASE="${F_2_VIEW_RELEASE:-}"
|
||||||
@@ -67,6 +46,9 @@ F_6_VIEW_RELEASE="${F_6_VIEW_RELEASE:-}"
|
|||||||
F_7_VIEW_RELEASE="${F_7_VIEW_RELEASE:-}"
|
F_7_VIEW_RELEASE="${F_7_VIEW_RELEASE:-}"
|
||||||
F_8_VIEW_RELEASE="${F_8_VIEW_RELEASE:-}"
|
F_8_VIEW_RELEASE="${F_8_VIEW_RELEASE:-}"
|
||||||
F_9_VIEW_RELEASE="${F_9_VIEW_RELEASE:-}"
|
F_9_VIEW_RELEASE="${F_9_VIEW_RELEASE:-}"
|
||||||
|
export F_1_VIEW_RELEASE F_2_VIEW_RELEASE F_3_VIEW_RELEASE F_4_VIEW_RELEASE \
|
||||||
|
F_5_VIEW_RELEASE F_6_VIEW_RELEASE F_7_VIEW_RELEASE F_8_VIEW_RELEASE \
|
||||||
|
F_9_VIEW_RELEASE
|
||||||
|
|
||||||
F_1_LIST_ARTISTS="${F_1_LIST_ARTISTS:-}"
|
F_1_LIST_ARTISTS="${F_1_LIST_ARTISTS:-}"
|
||||||
F_2_LIST_ARTISTS="${F_2_LIST_ARTISTS:-}"
|
F_2_LIST_ARTISTS="${F_2_LIST_ARTISTS:-}"
|
||||||
@@ -77,6 +59,9 @@ F_6_LIST_ARTISTS="${F_6_LIST_ARTISTS:-}"
|
|||||||
F_7_LIST_ARTISTS="${F_7_LIST_ARTISTS:-}"
|
F_7_LIST_ARTISTS="${F_7_LIST_ARTISTS:-}"
|
||||||
F_8_LIST_ARTISTS="${F_8_LIST_ARTISTS:-}"
|
F_8_LIST_ARTISTS="${F_8_LIST_ARTISTS:-}"
|
||||||
F_9_LIST_ARTISTS="${F_9_LIST_ARTISTS:-}"
|
F_9_LIST_ARTISTS="${F_9_LIST_ARTISTS:-}"
|
||||||
|
export F_1_LIST_ARTISTS F_2_LIST_ARTISTS F_3_LIST_ARTISTS F_4_LIST_ARTISTS \
|
||||||
|
F_5_LIST_ARTISTS F_6_LIST_ARTISTS F_7_LIST_ARTISTS F_8_LIST_ARTISTS \
|
||||||
|
F_9_LIST_ARTISTS
|
||||||
|
|
||||||
F_1_LIST_ALBUMS="${F_1_LIST_ALBUMS:-}"
|
F_1_LIST_ALBUMS="${F_1_LIST_ALBUMS:-}"
|
||||||
F_2_LIST_ALBUMS="${F_2_LIST_ALBUMS:-}"
|
F_2_LIST_ALBUMS="${F_2_LIST_ALBUMS:-}"
|
||||||
@@ -87,128 +72,6 @@ F_6_LIST_ALBUMS="${F_6_LIST_ALBUMS:-}"
|
|||||||
F_7_LIST_ALBUMS="${F_7_LIST_ALBUMS:-}"
|
F_7_LIST_ALBUMS="${F_7_LIST_ALBUMS:-}"
|
||||||
F_8_LIST_ALBUMS="${F_8_LIST_ALBUMS:-}"
|
F_8_LIST_ALBUMS="${F_8_LIST_ALBUMS:-}"
|
||||||
F_9_LIST_ALBUMS="${F_9_LIST_ALBUMS:-}"
|
F_9_LIST_ALBUMS="${F_9_LIST_ALBUMS:-}"
|
||||||
|
export F_1_LIST_ALBUMS F_2_LIST_ALBUMS F_3_LIST_ALBUMS F_4_LIST_ALBUMS \
|
||||||
# Determine preset query
|
F_5_LIST_ALBUMS F_6_LIST_ALBUMS F_7_LIST_ALBUMS F_8_LIST_ALBUMS \
|
||||||
# @argument $1: Current view
|
F_9_LIST_ALBUMS
|
||||||
# @argument $2: Key pressed (optional)
|
|
||||||
#
|
|
||||||
# If the key is not given, then the F_1_.. query is used for the respective
|
|
||||||
# view, i.e, its as if a key from KEYS_FILTER_1 has been pressed.
|
|
||||||
default_query() {
|
|
||||||
view=$1
|
|
||||||
key="${2:-"$(echo "$KEYS_FILTER_1" | cut -d ',' -f 1)"}"
|
|
||||||
case ",$KEYS_FILTER_LOCAL," in
|
|
||||||
*",$key,"*)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST" | "$VIEW_RELEASEGROUP" | "$VIEW_RELEASE") echo "$QUERY_LOCAL" ;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_FILTER_1," in
|
|
||||||
*",$key,"*)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST") echo "$F_1_VIEW_ARTIST" ;;
|
|
||||||
"$VIEW_RELEASEGROUP") echo "$F_1_VIEW_RELEASEGROUP" ;;
|
|
||||||
"$VIEW_RELEASE") echo "$F_1_VIEW_RELEASE" ;;
|
|
||||||
"$VIEW_LIST_ARTISTS") echo "$F_1_LIST_ARTISTS" ;;
|
|
||||||
"$VIEW_LIST_ALBUMS") echo "$F_1_LIST_ALBUMS" ;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_FILTER_2," in
|
|
||||||
*",$key,"*)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST") echo "$F_2_VIEW_ARTIST" ;;
|
|
||||||
"$VIEW_RELEASEGROUP") echo "$F_2_VIEW_RELEASEGROUP" ;;
|
|
||||||
"$VIEW_RELEASE") echo "$F_2_VIEW_RELEASE" ;;
|
|
||||||
"$VIEW_LIST_ARTISTS") echo "$F_2_LIST_ARTISTS" ;;
|
|
||||||
"$VIEW_LIST_ALBUMS") echo "$F_2_LIST_ALBUMS" ;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_FILTER_3," in
|
|
||||||
*",$key,"*)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST") echo "$F_3_VIEW_ARTIST" ;;
|
|
||||||
"$VIEW_RELEASEGROUP") echo "$F_3_VIEW_RELEASEGROUP" ;;
|
|
||||||
"$VIEW_RELEASE") echo "$F_3_VIEW_RELEASE" ;;
|
|
||||||
"$VIEW_LIST_ARTISTS") echo "$F_3_LIST_ARTISTS" ;;
|
|
||||||
"$VIEW_LIST_ALBUMS") echo "$F_3_LIST_ALBUMS" ;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_FILTER_4," in
|
|
||||||
*",$key,"*)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST") echo "$F_4_VIEW_ARTIST" ;;
|
|
||||||
"$VIEW_RELEASEGROUP") echo "$F_4_VIEW_RELEASEGROUP" ;;
|
|
||||||
"$VIEW_RELEASE") echo "$F_4_VIEW_RELEASE" ;;
|
|
||||||
"$VIEW_LIST_ARTISTS") echo "$F_4_LIST_ARTISTS" ;;
|
|
||||||
"$VIEW_LIST_ALBUMS") echo "$F_4_LIST_ALBUMS" ;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_FILTER_5," in
|
|
||||||
*",$key,"*)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST") echo "$F_5_VIEW_ARTIST" ;;
|
|
||||||
"$VIEW_RELEASEGROUP") echo "$F_5_VIEW_RELEASEGROUP" ;;
|
|
||||||
"$VIEW_RELEASE") echo "$F_5_VIEW_RELEASE" ;;
|
|
||||||
"$VIEW_LIST_ARTISTS") echo "$F_5_LIST_ARTISTS" ;;
|
|
||||||
"$VIEW_LIST_ALBUMS") echo "$F_5_LIST_ALBUMS" ;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_FILTER_6," in
|
|
||||||
*",$key,"*)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST") echo "$F_6_VIEW_ARTIST" ;;
|
|
||||||
"$VIEW_RELEASEGROUP") echo "$F_6_VIEW_RELEASEGROUP" ;;
|
|
||||||
"$VIEW_RELEASE") echo "$F_6_VIEW_RELEASE" ;;
|
|
||||||
"$VIEW_LIST_ARTISTS") echo "$F_6_LIST_ARTISTS" ;;
|
|
||||||
"$VIEW_LIST_ALBUMS") echo "$F_6_LIST_ALBUMS" ;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_FILTER_7," in
|
|
||||||
*",$key,"*)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST") echo "$F_7_VIEW_ARTIST" ;;
|
|
||||||
"$VIEW_RELEASEGROUP") echo "$F_7_VIEW_RELEASEGROUP" ;;
|
|
||||||
"$VIEW_RELEASE") echo "$F_7_VIEW_RELEASE" ;;
|
|
||||||
"$VIEW_LIST_ARTISTS") echo "$F_7_LIST_ARTISTS" ;;
|
|
||||||
"$VIEW_LIST_ALBUMS") echo "$F_7_LIST_ALBUMS" ;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_FILTER_8," in
|
|
||||||
*",$key,"*)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST") echo "$F_8_VIEW_ARTIST" ;;
|
|
||||||
"$VIEW_RELEASEGROUP") echo "$F_8_VIEW_RELEASEGROUP" ;;
|
|
||||||
"$VIEW_RELEASE") echo "$F_8_VIEW_RELEASE" ;;
|
|
||||||
"$VIEW_LIST_ARTISTS") echo "$F_8_LIST_ARTISTS" ;;
|
|
||||||
"$VIEW_LIST_ALBUMS") echo "$F_8_LIST_ALBUMS" ;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_FILTER_9," in
|
|
||||||
*",$key,"*)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST") echo "$F_9_VIEW_ARTIST" ;;
|
|
||||||
"$VIEW_RELEASEGROUP") echo "$F_9_VIEW_RELEASEGROUP" ;;
|
|
||||||
"$VIEW_RELEASE") echo "$F_9_VIEW_RELEASE" ;;
|
|
||||||
"$VIEW_LIST_ARTISTS") echo "$F_9_LIST_ARTISTS" ;;
|
|
||||||
"$VIEW_LIST_ALBUMS") echo "$F_9_LIST_ALBUMS" ;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
# Doing nothing is the same as this last block:
|
|
||||||
# case ",$KEYS_FILTER_0," in
|
|
||||||
# *",$key,"*)
|
|
||||||
# case "$view" in
|
|
||||||
# "$VIEW_ARTIST" | "$VIEW_RELEASEGROUP" | "$VIEW_RELEASE" | "$VIEW_LIST_ARTISTS" | "$VIEW_LIST_ALBUMS") echo "" ;;
|
|
||||||
# esac
|
|
||||||
# ;;
|
|
||||||
# esac
|
|
||||||
}
|
|
||||||
|
496
src/sh/fzf.sh
496
src/sh/fzf.sh
@@ -10,162 +10,27 @@ fzf_command_set_header() {
|
|||||||
"$VIEW_LIST_ARTISTS") header="Search locally available artist" ;;
|
"$VIEW_LIST_ARTISTS") header="Search locally available artist" ;;
|
||||||
"$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 -r '.name')"
|
name="$(mb_artist "$mbid" | $JQ '.name')"
|
||||||
header=$(printf "$ARTIST_PROMPT" "$name")
|
header=$(printf "$ARTIST_PROMPT" "$name")
|
||||||
;;
|
;;
|
||||||
"$VIEW_RELEASEGROUP")
|
"$VIEW_RELEASEGROUP")
|
||||||
title="$(mb_releasegroup "$mbid" |
|
title="$(mb_releasegroup "$mbid" |
|
||||||
$JQ -r '.title')"
|
$JQ '.title')"
|
||||||
artist="$(mb_releasegroup "$mbid" |
|
artist="$(mb_releasegroup "$mbid" |
|
||||||
$JQ -r '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
|
$JQ '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
|
||||||
header=$(printf "$FULL_PROMPT" "$artist" "$title")
|
header=$(printf "$FULL_PROMPT" "$artist" "$title")
|
||||||
;;
|
;;
|
||||||
"$VIEW_RELEASE")
|
"$VIEW_RELEASE")
|
||||||
title="$(mb_release "$mbid" |
|
title="$(mb_release "$mbid" |
|
||||||
$JQ -r '.title')"
|
$JQ '.title')"
|
||||||
artist="$(mb_release "$mbid" |
|
artist="$(mb_release "$mbid" |
|
||||||
$JQ -r '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
|
$JQ '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
|
||||||
header=$(printf "$FULL_PROMPT" "$artist" "$title")
|
header=$(printf "$FULL_PROMPT" "$artist" "$title")
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
printf "+change-header(%s)" "${header:-"???"}"
|
printf "+change-header(%s)" "${header:-"???"}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print the command that tells fzf to load the data
|
|
||||||
# @argument $1: view
|
|
||||||
# @argument $2: mbid
|
|
||||||
fzf_command_load_data() {
|
|
||||||
view=$1
|
|
||||||
mbid=${2:-}
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_SEARCH_ARTIST") ;;
|
|
||||||
"$VIEW_SEARCH_ALBUM") ;;
|
|
||||||
"$VIEW_LIST_ARTISTS") ;;
|
|
||||||
"$VIEW_LIST_ALBUMS") ;;
|
|
||||||
"$VIEW_ARTIST") ;;
|
|
||||||
"$VIEW_RELEASEGROUP") ;;
|
|
||||||
"$VIEW_RELEASE") ;;
|
|
||||||
esac
|
|
||||||
printf "+reload($0 --lines %s %s)" "$VIEW_LIST_ARTISTS" ""
|
|
||||||
}
|
|
||||||
|
|
||||||
# Set prompt of input field
|
|
||||||
# @argument $1: view
|
|
||||||
# @argument $2: mode
|
|
||||||
__set_prompt() {
|
|
||||||
view=$1
|
|
||||||
mode=$2
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST")
|
|
||||||
name="$(mb_artist "$args" | $JQ -r '.name')"
|
|
||||||
PROMPT=$(printf "$ARTIST_PROMPT" "$name")
|
|
||||||
;;
|
|
||||||
"$VIEW_RELEASEGROUP")
|
|
||||||
title="$(mb_releasegroup "$args" |
|
|
||||||
$JQ -r '.title')"
|
|
||||||
artist="$(mb_releasegroup "$args" |
|
|
||||||
$JQ -r '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
|
|
||||||
PROMPT=$(printf "$FULL_PROMPT" "$artist" "$title")
|
|
||||||
;;
|
|
||||||
"$VIEW_RELEASE")
|
|
||||||
title="$(mb_release "$args" |
|
|
||||||
$JQ -r '.title')"
|
|
||||||
artist="$(mb_release "$args" |
|
|
||||||
$JQ -r '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
|
|
||||||
PROMPT=$(printf "$FULL_PROMPT" "$artist" "$title")
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
[ "$mode" = "$MODE_INSERT" ] && PT="$PROMPT_INSERT" || PT="$PROMPT_NORMAL"
|
|
||||||
printf "+change-header(%s %s)" "$PT" "${PROMPT:-"$SEARCH_PROMPT"}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Reload data for FZF
|
|
||||||
fzf_handle_reload() {
|
|
||||||
view=$(state_get_view)
|
|
||||||
mode=$(state_get_mode)
|
|
||||||
args=$(state_get_args)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST")
|
|
||||||
list_releasegroups "$args"
|
|
||||||
;;
|
|
||||||
"$VIEW_RELEASEGROUP")
|
|
||||||
list_releases "$args"
|
|
||||||
;;
|
|
||||||
"$VIEW_RELEASE")
|
|
||||||
list_recordings "$args"
|
|
||||||
;;
|
|
||||||
"$VIEW_LIST_ARTISTS")
|
|
||||||
list_local_artists
|
|
||||||
;;
|
|
||||||
"$VIEW_LIST_ALBUMS")
|
|
||||||
list_local_releasegroups
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
# Handle for after loading data into FZF
|
|
||||||
fzf_handle_load() {
|
|
||||||
view=$(state_get_view)
|
|
||||||
mode=$(state_get_mode)
|
|
||||||
args=$(state_get_args)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST")
|
|
||||||
QUERY="!'$QUERY_HAS_SECONDARY' "
|
|
||||||
;;
|
|
||||||
"$VIEW_RELEASEGROUP")
|
|
||||||
[ "$QUERY_RV" ] && QUERY="'$QUERY_RV' " || QUERY=""
|
|
||||||
;;
|
|
||||||
"$VIEW_SEARCH_ARTIST")
|
|
||||||
ENABLE_CHANGE=1
|
|
||||||
DISABLE_SEARCH=1
|
|
||||||
SHOW_PREVIEW=1
|
|
||||||
;;
|
|
||||||
"$VIEW_SEARCH_ALBUM")
|
|
||||||
ENABLE_CHANGE=1
|
|
||||||
DISABLE_SEARCH=1
|
|
||||||
;;
|
|
||||||
"$VIEW_LIST_ARTISTS")
|
|
||||||
SHOW_PREVIEW=1
|
|
||||||
;;
|
|
||||||
"$VIEW_LIST_ALBUMS") ;;
|
|
||||||
esac
|
|
||||||
[ "${DISABLE_SEARCH:-}" ] && printf "+disable-search+change-query(%s)+disable-search" "${QUERY:-"$FZF_QUERY"}" || printf "+enable-search+change-query(%s)+enable-search" "${QUERY:-}"
|
|
||||||
[ "${SHOW_PREVIEW:-}" ] && printf "+show-preview" || printf "+hide-preview"
|
|
||||||
[ "${ENABLE_CHANGE:-}" ] && printf "+rebind(change)" || printf "+unbind(change)"
|
|
||||||
__set_prompt "$view" "$mode"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Print info string for FZF
|
|
||||||
fzf_info() {
|
|
||||||
view=$(state_get_view)
|
|
||||||
mode=$(state_get_mode)
|
|
||||||
args=$(state_get_args)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_SEARCH_ARTIST")
|
|
||||||
echo "Search music artist on MusicBrainz"
|
|
||||||
;;
|
|
||||||
"$VIEW_SEARCH_ALBUM")
|
|
||||||
echo "Search album on MusicBrainz"
|
|
||||||
;;
|
|
||||||
"$VIEW_LIST_ARTISTS")
|
|
||||||
echo "Search artists"
|
|
||||||
;;
|
|
||||||
"$VIEW_LIST_ALBUMS")
|
|
||||||
echo "Search albums"
|
|
||||||
;;
|
|
||||||
"$VIEW_SELECT_ARTIST")
|
|
||||||
debug "Select artist (WE SHOULDNT SEE THIS; THIS IS A BUG!)"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if [ "$FZF_KEY" ]; then
|
|
||||||
printf "[last key: %s] %s/%s" "$FZF_KEY" "$FZF_MATCH_COUNT" "$FZF_TOTAL_COUNT"
|
|
||||||
else
|
|
||||||
printf "%s/%s" "$FZF_MATCH_COUNT" "$FZF_TOTAL_COUNT"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
# Reload hook that is used after change in query
|
# Reload hook that is used after change in query
|
||||||
fzf_reload_after_change() {
|
fzf_reload_after_change() {
|
||||||
# Wait for async. process to terminate
|
# Wait for async. process to terminate
|
||||||
@@ -195,7 +60,7 @@ fzf_handle_change() {
|
|||||||
sleep 1
|
sleep 1
|
||||||
if [ "$view" = "$VIEW_SEARCH_ARTIST" ]; then
|
if [ "$view" = "$VIEW_SEARCH_ARTIST" ]; then
|
||||||
api_mb_search_artist "$FZF_QUERY" |
|
api_mb_search_artist "$FZF_QUERY" |
|
||||||
$JQ -r '.artists[] | [
|
$JQ '.artists[] | [
|
||||||
.id,
|
.id,
|
||||||
.type,
|
.type,
|
||||||
.name,
|
.name,
|
||||||
@@ -214,7 +79,7 @@ fzf_handle_change() {
|
|||||||
true
|
true
|
||||||
else
|
else
|
||||||
api_mb_search_releasegroup "$FZF_QUERY" |
|
api_mb_search_releasegroup "$FZF_QUERY" |
|
||||||
$JQ -r '."release-groups"[] | [
|
$JQ '."release-groups"[] | [
|
||||||
.id,
|
.id,
|
||||||
."primary-type",
|
."primary-type",
|
||||||
(."secondary-types" // []|join(";")),
|
(."secondary-types" // []|join(";")),
|
||||||
@@ -255,350 +120,3 @@ fzf_handle_change() {
|
|||||||
# Process ends now: Display and quit
|
# Process ends now: Display and quit
|
||||||
rm -f "$LOCKFILE" "$PIDFILE"
|
rm -f "$LOCKFILE" "$PIDFILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Handle FZF keypress
|
|
||||||
# @argument $1: MusicBrainz ID of parent object
|
|
||||||
# @argument $2: MusicBrainz ID of selected object
|
|
||||||
# @argument $3: Path to decoration file (optional)
|
|
||||||
fzf_handle_key() {
|
|
||||||
parentmbid="${1:-}"
|
|
||||||
mbid="${2:-}"
|
|
||||||
path="${3:-}"
|
|
||||||
view=$(state_get_view)
|
|
||||||
mode=$(state_get_mode)
|
|
||||||
args=$(state_get_args)
|
|
||||||
|
|
||||||
# If we are in the insert mode, and the key pressed is an "input" key, then
|
|
||||||
# put it and quit.
|
|
||||||
if [ "$mode" = "$MODE_INSERT" ]; then
|
|
||||||
case ",$KEYS_INPUT_SINGLE," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
printf "put(%s)" "$FZF_KEY"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_INPUT_SPECIAL," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
case "$FZF_KEY" in
|
|
||||||
"space") printf "put( )" ;;
|
|
||||||
"backspace") printf "backward-delete-char" ;;
|
|
||||||
"delete") printf "delete-char" ;;
|
|
||||||
"left") printf "backward-char" ;;
|
|
||||||
"right") printf "forward-char" ;;
|
|
||||||
esac
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Keys in insert mode only
|
|
||||||
case ",$KEYS_I_NORMAL," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_PLAYLIST") ;;
|
|
||||||
*)
|
|
||||||
state_update_keep_args "$view" "$MODE_NORMAL"
|
|
||||||
__set_prompt "$view" "$MODE_NORMAL"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Keys exclusive to playlist view
|
|
||||||
if [ "$view" = "$VIEW_PLAYLIST" ]; then
|
|
||||||
case ",$KEYS_PLAYLIST_RELOAD," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
debug "hit playlist reload key"
|
|
||||||
debug "going to call $(printf "reload:%s" "$0 --fzf-reload")"
|
|
||||||
printf "reload:%s" "$0 --fzf-reload"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Handle key press
|
|
||||||
case ",$KEYS_HALFPAGE_DOWN," in
|
|
||||||
*",$FZF_KEY,"*) printf "half-page-down" ;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_HALFPAGE_UP," in
|
|
||||||
*",$FZF_KEY,"*) printf "half-page-up" ;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_OPEN," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
[ "$path" ] || return 0
|
|
||||||
open "$(dirname "$path")"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_BROWSE," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
[ "$mbid" ] || return 0
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_SEARCH_ARTIST" | "$VIEW_LIST_ARTISTS" | "$VIEW_SELECT_ARTIST") urltype="artist" ;;
|
|
||||||
"$VIEW_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ALBUMS") urltype="release-group" ;;
|
|
||||||
"$VIEW_RELEASEGROUP") urltype="release" ;;
|
|
||||||
"$VIEW_RELEASE" | "$VIEW_PLAYLIST") urltype="track" ;;
|
|
||||||
esac
|
|
||||||
[ "${urltype:-}" ] && printf "execute-silent(xdg-open \"https://musicbrainz.org/%s/%s\" &)" "$urltype" "$mbid"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_OUT," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST")
|
|
||||||
VIEW_NEXT="$VIEW_LIST_ARTISTS"
|
|
||||||
;;
|
|
||||||
"$VIEW_RELEASEGROUP")
|
|
||||||
VIEW_NEXT="$VIEW_SELECT_ARTIST"
|
|
||||||
VIEW_NEXT_ARGS="$(mb_releasegroup "$args" | $JQ -r --compact-output '."artist-credit"')"
|
|
||||||
ACCEPT=1
|
|
||||||
;;
|
|
||||||
"$VIEW_RELEASE")
|
|
||||||
VIEW_NEXT="$VIEW_RELEASEGROUP"
|
|
||||||
VIEW_NEXT_ARGS="$(mb_release "$args" | $JQ -r --compact-output '."release-group".id')"
|
|
||||||
;;
|
|
||||||
"$VIEW_PLAYLIST")
|
|
||||||
VIEW_NEXT="$VIEW_RELEASE"
|
|
||||||
VIEW_NEXT_ARGS="$parentmbid"
|
|
||||||
ACCEPT=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_IN," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
[ "$mbid" ] || return 0
|
|
||||||
VIEW_NEXT_ARGS="$mbid"
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_LIST_ARTISTS" | "$VIEW_SEARCH_ARTIST")
|
|
||||||
VIEW_NEXT="$VIEW_ARTIST"
|
|
||||||
;;
|
|
||||||
"$VIEW_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ALBUMS")
|
|
||||||
VIEW_NEXT="$VIEW_RELEASEGROUP"
|
|
||||||
;;
|
|
||||||
"$VIEW_RELEASEGROUP")
|
|
||||||
VIEW_NEXT="$VIEW_RELEASE"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_SELECT_ARTIST," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
[ "$mbid" ] || return 0
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST" | "$VIEW_SEARCH_ARTIST" | "$VIEW_LIST_ARTISTS")
|
|
||||||
VIEW_NEXT_ARGS="$(mb_releasegroup "$mbid" | $JQ -r --compact-output '."artist-credit"')"
|
|
||||||
ACCEPT=1
|
|
||||||
;;
|
|
||||||
"$VIEW_RELEASEGROUP" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ALBUMS")
|
|
||||||
VIEW_NEXT_ARGS="$(mb_release "$mbid" | $JQ -r --compact-output '."artist-credit"')"
|
|
||||||
ACCEPT=1
|
|
||||||
;;
|
|
||||||
"$VIEW_RELEASE")
|
|
||||||
VIEW_NEXT_ARGS="$(mb_release "$args" | $JQ -r --compact-output '."artist-credit"')"
|
|
||||||
ACCEPT=1
|
|
||||||
;;
|
|
||||||
"$VIEW_PLAYLIST")
|
|
||||||
debug "NOT IMPLEMENTED"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
[ "$VIEW_NEXT_ARGS" ] && VIEW_NEXT="$VIEW_SELECT_ARTIST"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_FILTER_LOCAL," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_SEARCH_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_PLAYLIST") ;;
|
|
||||||
*) QUERY="'$QUERY_LOCAL' " ;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
# VIEW_RELEASEGROUP="rg"
|
|
||||||
# VIEW_RELEASE="release"
|
|
||||||
# VIEW_LIST_ARTISTS="list-artists"
|
|
||||||
# VIEW_SELECT_ARTIST="select-artist"
|
|
||||||
# VIEW_PLAYLIST="playlist"
|
|
||||||
case ",$KEYS_FILTER_1," in *",$FZF_KEY,"*) case "$view" in "$VIEW_ARTIST" | "$VIEW_LIST_ALBUMS") QUERY="!'$QUERY_HAS_SECONDARY' " ;; esac ;; esac
|
|
||||||
case ",$KEYS_FILTER_2," in *",$FZF_KEY,"*) case "$view" in "$VIEW_ARTIST" | "$VIEW_LIST_ALBUMS") QUERY="!'$QUERY_HAS_SECONDARY' '$QUERY_ALBUM' " ;; esac ;; esac
|
|
||||||
case ",$KEYS_FILTER_3," in *",$FZF_KEY,"*) case "$view" in "$VIEW_ARTIST" | "$VIEW_LIST_ALBUMS") QUERY="!'$QUERY_HAS_SECONDARY' '$QUERY_EP' " ;; esac ;; esac
|
|
||||||
case ",$KEYS_FILTER_4," in *",$FZF_KEY,"*) case "$view" in "$VIEW_ARTIST" | "$VIEW_LIST_ALBUMS") QUERY="!'$QUERY_HAS_SECONDARY' '$QUERY_SINGLE' " ;; esac ;; esac
|
|
||||||
case ",$KEYS_SWITCH_ARTIST_ALBUM," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_SEARCH_ARTIST") VIEW_NEXT="$VIEW_SEARCH_ALBUM" ;;
|
|
||||||
"$VIEW_SEARCH_ALBUM") VIEW_NEXT="$VIEW_SEARCH_ARTIST" ;;
|
|
||||||
"$VIEW_LIST_ARTISTS") VIEW_NEXT="$VIEW_LIST_ALBUMS" ;;
|
|
||||||
"$VIEW_LIST_ALBUMS") VIEW_NEXT="$VIEW_LIST_ARTISTS" ;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_SWITCH_LOCAL_REMOTE," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_SEARCH_ARTIST") VIEW_NEXT="$VIEW_LIST_ARTISTS" ;;
|
|
||||||
"$VIEW_SEARCH_ALBUM") VIEW_NEXT="$VIEW_LIST_ALBUMS" ;;
|
|
||||||
"$VIEW_LIST_ARTISTS")
|
|
||||||
VIEW_NEXT="$VIEW_SEARCH_ARTIST"
|
|
||||||
MODE_NEXT="$MODE_INSERT"
|
|
||||||
;;
|
|
||||||
"$VIEW_LIST_ALBUMS")
|
|
||||||
VIEW_NEXT="$VIEW_SEARCH_ALBUM"
|
|
||||||
MODE_NEXT="$MODE_INSERT"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_SHOW_PLAYLIST," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
VIEW_NEXT="$VIEW_PLAYLIST"
|
|
||||||
ACCEPT=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_PLAY," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
[ "$path" ] || return 0
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST" | "$VIEW_SEARCH_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ARTISTS" | "$VIEW_LIST_ALBUMS")
|
|
||||||
debug "not implemented"
|
|
||||||
;;
|
|
||||||
"$VIEW_RELEASEGROUP")
|
|
||||||
generate_playlist "$mbid" "$path" | mpv_play_list >/dev/null
|
|
||||||
;;
|
|
||||||
"$VIEW_RELEASE")
|
|
||||||
generate_playlist "$parentmbid" "$path" "$mbid" | mpv_play_list >/dev/null
|
|
||||||
;;
|
|
||||||
"$VIEW_PLAYLIST")
|
|
||||||
generate_playlist "$parentmbid" "$path" "$mbid" | mpv_play_list >/dev/null
|
|
||||||
VIEW_NEXT="$VIEW_PLAYLIST"
|
|
||||||
ACCEPT=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_QUEUE," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
[ "$path" ] || return 0
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST" | "$VIEW_SEARCH_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ARTISTS" | "$VIEW_LIST_ALBUMS")
|
|
||||||
debug "not implemented"
|
|
||||||
;;
|
|
||||||
"$VIEW_RELEASEGROUP")
|
|
||||||
generate_playlist "$mbid" "$path" | mpv_queue_list >/dev/null
|
|
||||||
;;
|
|
||||||
"$VIEW_RELEASE")
|
|
||||||
generate_playlist "$parentmbid" "$path" "$mbid" | mpv_queue_list >/dev/null
|
|
||||||
;;
|
|
||||||
"$VIEW_PLAYLIST")
|
|
||||||
generate_playlist "$parentmbid" "$path" "$mbid" | mpv_queue_list >/dev/null
|
|
||||||
VIEW_NEXT="$VIEW_PLAYLIST"
|
|
||||||
ACCEPT=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Keys in normal mode only
|
|
||||||
if [ "$mode" = "$MODE_NORMAL" ]; then
|
|
||||||
case ",$KEYS_N_DOWN," in
|
|
||||||
*",$FZF_KEY,"*) printf "down" ;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_N_UP," in
|
|
||||||
*",$FZF_KEY,"*) printf "up" ;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_N_OUT," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_ARTIST")
|
|
||||||
VIEW_NEXT="$VIEW_LIST_ARTISTS"
|
|
||||||
;;
|
|
||||||
"$VIEW_RELEASEGROUP")
|
|
||||||
VIEW_NEXT="$VIEW_SELECT_ARTIST"
|
|
||||||
VIEW_NEXT_ARGS="$(mb_releasegroup "$args" | $JQ -r --compact-output '."artist-credit"')"
|
|
||||||
ACCEPT=1
|
|
||||||
;;
|
|
||||||
"$VIEW_RELEASE")
|
|
||||||
VIEW_NEXT="$VIEW_RELEASEGROUP"
|
|
||||||
VIEW_NEXT_ARGS="$(mb_release "$args" | $JQ -r --compact-output '."release-group".id')"
|
|
||||||
;;
|
|
||||||
"$VIEW_PLAYLIST")
|
|
||||||
VIEW_NEXT="$VIEW_RELEASE"
|
|
||||||
VIEW_NEXT_ARGS="$parentmbid"
|
|
||||||
ACCEPT=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_N_IN," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
[ "$mbid" ] || return 0
|
|
||||||
VIEW_NEXT_ARGS="$mbid"
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_LIST_ARTISTS" | "$VIEW_SEARCH_ARTIST")
|
|
||||||
VIEW_NEXT="$VIEW_ARTIST"
|
|
||||||
;;
|
|
||||||
"$VIEW_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ALBUMS")
|
|
||||||
VIEW_NEXT="$VIEW_RELEASEGROUP"
|
|
||||||
;;
|
|
||||||
"$VIEW_RELEASEGROUP")
|
|
||||||
VIEW_NEXT="$VIEW_RELEASE"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_N_TOP," in
|
|
||||||
*",$FZF_KEY,"*) printf "first" ;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_N_BOT," in
|
|
||||||
*",$FZF_KEY,"*) printf "last" ;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_N_QUIT," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_SELECT_ARTIST" | "$VIEW_PLAYLIST") printf "accept" ;;
|
|
||||||
*) printf "print(Q)+abort" ;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_N_INSERT," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
case "$view" in
|
|
||||||
"$VIEW_PLAYLIST") ;;
|
|
||||||
*)
|
|
||||||
state_update_keep_args "$view" "$MODE_INSERT"
|
|
||||||
__set_prompt "$view" "$MODE_INSERT"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_N_TOGGLE_PLAYBACK," in
|
|
||||||
*",$FZF_KEY,"*) mpv_toggle_pause >/dev/null ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case ",$KEYS_N_PLAY_NEXT," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
mpv_next >/dev/null
|
|
||||||
[ "$view" = "$VIEW_PLAYLIST" ] && VIEW_NEXT="$VIEW_PLAYLIST" && ACCEPT=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_N_PLAY_PREV," in
|
|
||||||
*",$FZF_KEY,"*)
|
|
||||||
mpv_prev >/dev/null
|
|
||||||
[ "$view" = "$VIEW_PLAYLIST" ] && VIEW_NEXT="$VIEW_PLAYLIST" && ACCEPT=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_N_SEEK_FORWARD," in
|
|
||||||
*",$FZF_KEY,"*) mpv_seek_forward >/dev/null ;;
|
|
||||||
esac
|
|
||||||
case ",$KEYS_N_SEEK_BACKWARD," in
|
|
||||||
*",$FZF_KEY,"*) mpv_seek_backward >/dev/null ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Post processing
|
|
||||||
[ "${QUERY:-}" ] && printf "+change-query(%s)" "$QUERY"
|
|
||||||
if [ "${VIEW_NEXT:-}" ]; then
|
|
||||||
[ "$VIEW_NEXT" = "$VIEW_PLAYLIST" ] && MODE_NEXT="$MODE_NORMAL"
|
|
||||||
state_update "$VIEW_NEXT" "${MODE_NEXT:-"$mode"}" "${VIEW_NEXT_ARGS:-}"
|
|
||||||
[ "$MODE_NEXT" = "$MODE_INSERT" ] && printf "+enable-search" || printf "+disable-search"
|
|
||||||
[ "${ACCEPT:-}" ] && printf "+accept" || printf "+reload:%s" "$0 --fzf-reload"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
@@ -1,19 +0,0 @@
|
|||||||
ERR="\033[38;5;196m"
|
|
||||||
INFO="\033[38;5;75m"
|
|
||||||
DBG=$ERR
|
|
||||||
OFF="\033[m"
|
|
||||||
LOGDIR="$HOME/.local/state/$APP_NAME"
|
|
||||||
[ -d "$LOGDIR" ] || mkdir -p "$LOGDIR"
|
|
||||||
LOGFILE="$LOGDIR/log"
|
|
||||||
|
|
||||||
err() {
|
|
||||||
echo "${ERR}ERROR:${OFF} ${1:-}" >/dev/stderr
|
|
||||||
}
|
|
||||||
|
|
||||||
info() {
|
|
||||||
echo "${INFO}Info:${OFF} ${1:-}" >/dev/stderr
|
|
||||||
}
|
|
||||||
|
|
||||||
debug() {
|
|
||||||
echo "${DBG}DEBUG${OFF} ${INFO} [$$] $(date)${OFF}: $*" >>"$LOGFILE"
|
|
||||||
}
|
|
@@ -1,5 +1,5 @@
|
|||||||
|
# Application information
|
||||||
APP_NAME="muf"
|
APP_NAME="muf"
|
||||||
APP_VERSION="zero.zero"
|
APP_VERSION="zero.zero"
|
||||||
APP_WEBSITE="https://git.indyfac.ch/amin/muf"
|
APP_WEBSITE="https://git.indyfac.ch/amin/muf"
|
||||||
WINDOW_TITLE="🔎🎶 $APP_NAME | a simple music finder and player"
|
WINDOW_TITLE="🔎🎶 $APP_NAME | a simple music finder and player"
|
||||||
export APP_NAME APP_VERSION APP_WEBSITE WINDOW_TITLE
|
|
||||||
|
@@ -81,6 +81,7 @@
|
|||||||
# Mode selection:
|
# Mode selection:
|
||||||
KEYS_I_NORMAL="${KEYS_I_NORMAL:-"esc"}"
|
KEYS_I_NORMAL="${KEYS_I_NORMAL:-"esc"}"
|
||||||
KEYS_N_INSERT="${KEYS_N_INSERT:-"a,i,/,?"}"
|
KEYS_N_INSERT="${KEYS_N_INSERT:-"a,i,/,?"}"
|
||||||
|
export KEYS_I_NORMAL KEYS_N_INSERT
|
||||||
|
|
||||||
# Vertical navigation:
|
# Vertical navigation:
|
||||||
KEYS_DOWN="${KEYS_DOWN:-"ctrl-j,down"}"
|
KEYS_DOWN="${KEYS_DOWN:-"ctrl-j,down"}"
|
||||||
@@ -91,6 +92,8 @@ KEYS_N_DOWN="${KEYS_N_DOWN:-"j"}"
|
|||||||
KEYS_N_UP="${KEYS_N_UP:-"k"}"
|
KEYS_N_UP="${KEYS_N_UP:-"k"}"
|
||||||
KEYS_N_BOT="${KEYS_N_BOT:-"G"}"
|
KEYS_N_BOT="${KEYS_N_BOT:-"G"}"
|
||||||
KEYS_N_TOP="${KEYS_N_TOP:-"1"}"
|
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:
|
# Horizontal navigation:
|
||||||
KEYS_IN="${KEYS_IN:-"ctrl-l"}"
|
KEYS_IN="${KEYS_IN:-"ctrl-l"}"
|
||||||
@@ -104,6 +107,9 @@ KEYS_SEARCH_ARTIST="${KEYS_SEARCH_ARTIST:-"alt-z"}"
|
|||||||
KEYS_SEARCH_ALBUM="${KEYS_SEARCH_ALBUM:-"alt-x"}"
|
KEYS_SEARCH_ALBUM="${KEYS_SEARCH_ALBUM:-"alt-x"}"
|
||||||
KEYS_SWITCH_ARTIST_ALBUM="${KEYS_SWITCH_ARTIST_ALBUM:-"tab"}"
|
KEYS_SWITCH_ARTIST_ALBUM="${KEYS_SWITCH_ARTIST_ALBUM:-"tab"}"
|
||||||
KEYS_SWITCH_LOCAL_REMOTE="${KEYS_SWITCH_LOCAL_REMOTE:-"ctrl-/"}"
|
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_SELECT_ARTIST KEYS_SEARCH_ALBUM \
|
||||||
|
KEYS_SWITCH_ARTIST_ALBUM KEYS_SWITCH_LOCAL_REMOTE
|
||||||
|
|
||||||
# Filtering:
|
# Filtering:
|
||||||
KEYS_FILTER_LOCAL="${KEYS_FILTER_LOCAL:-"alt-l"}"
|
KEYS_FILTER_LOCAL="${KEYS_FILTER_LOCAL:-"alt-l"}"
|
||||||
@@ -118,6 +124,9 @@ KEYS_FILTER_8="${KEYS_FILTER_8:-"alt-8"}"
|
|||||||
KEYS_FILTER_9="${KEYS_FILTER_9:-"alt-9"}"
|
KEYS_FILTER_9="${KEYS_FILTER_9:-"alt-9"}"
|
||||||
KEYS_FILTER_0="${KEYS_FILTER_0:-"alt-0"}"
|
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"
|
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:
|
# Specials:
|
||||||
KEYS_BROWSE="${KEYS_BROWSE:-"alt-b"}"
|
KEYS_BROWSE="${KEYS_BROWSE:-"alt-b"}"
|
||||||
@@ -125,6 +134,7 @@ KEYS_OPEN="${KEYS_OPEN:-"alt-o"}"
|
|||||||
KEYS_SHOW_PLAYLIST="${KEYS_SHOW_PLAYLIST:-"ctrl-p"}"
|
KEYS_SHOW_PLAYLIST="${KEYS_SHOW_PLAYLIST:-"ctrl-p"}"
|
||||||
KEYS_QUIT="${KEYS_QUIT:-"ctrl-c"}"
|
KEYS_QUIT="${KEYS_QUIT:-"ctrl-c"}"
|
||||||
KEYS_N_QUIT="${KEYS_N_QUIT:-"q"}"
|
KEYS_N_QUIT="${KEYS_N_QUIT:-"q"}"
|
||||||
|
export KEYS_BROWSE KEYS_OPEN KEYS_SHOW_PLAYLIST KEYS_QUIT KEYS_N_QUIT
|
||||||
|
|
||||||
# Playback:
|
# Playback:
|
||||||
KEYS_PLAY="${KEYS_PLAY:-"enter"}"
|
KEYS_PLAY="${KEYS_PLAY:-"enter"}"
|
||||||
@@ -145,6 +155,11 @@ KEYS_N_PLAY_PREV="${KEYS_N_PLAY_PREV:-"left,p"}"
|
|||||||
KEYS_N_SEEK_FORWARD="${KEYS_N_SEEK_FORWARD:-"N,f"}"
|
KEYS_N_SEEK_FORWARD="${KEYS_N_SEEK_FORWARD:-"N,f"}"
|
||||||
KEYS_N_SEEK_BACKWARD="${KEYS_N_SEEK_BACKWARD:-"P,b"}"
|
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"
|
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):
|
# Playlist (in the playlist, there is no `insert` mode):
|
||||||
KEYS_PLAYLIST_RELOAD="${KEYS_PLAYLIST_RELOAD:-"r,ctrl-r"}"
|
KEYS_PLAYLIST_RELOAD="${KEYS_PLAYLIST_RELOAD:-"r,ctrl-r"}"
|
||||||
@@ -157,40 +172,7 @@ KEYS_PLAYLIST_CLEAR_BELOW="${KEYS_PLAYLIST_CLEAR_BELOW:-"D"}"
|
|||||||
KEYS_PLAYLIST_GOTO_RELEASE="${KEYS_PLAYLIST_GOTO_RELEASE:-"ctrl-g"}"
|
KEYS_PLAYLIST_GOTO_RELEASE="${KEYS_PLAYLIST_GOTO_RELEASE:-"ctrl-g"}"
|
||||||
KEYS_PLAYLIST_STORE="${KEYS_PLAYLIST_STORE:-"ctrl-s"}"
|
KEYS_PLAYLIST_STORE="${KEYS_PLAYLIST_STORE:-"ctrl-s"}"
|
||||||
KEYS_PLAYLIST_LOAD="${KEYS_PLAYLIST_LOAD:-"ctrl-o"}"
|
KEYS_PLAYLIST_LOAD="${KEYS_PLAYLIST_LOAD:-"ctrl-o"}"
|
||||||
KEYS_PLAYLIST_QUIT="${KEYS_PLAYLIST_QUIT:-"q,ctrl-c,esc"}"
|
export KEYS_PLAYLIST_RELOAD KEYS_PLAYLIST_REMOVE KEYS_PLAYLIST_UP \
|
||||||
|
KEYS_PLAYLIST_DOWN KEYS_PLAYLIST_CLEAR KEYS_PLAYLIST_CLEAR_ABOVE \
|
||||||
## Not yet characterized
|
KEYS_PLAYLIST_CLEAR_BELOW KEYS_PLAYLIST_GOTO_RELEASE KEYS_PLAYLIST_STORE \
|
||||||
##########################
|
KEYS_PLAYLIST_LOAD
|
||||||
|
|
||||||
KEYS_INPUT_SINGLE='0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,!,",#,$,%,&,\,(,),*,+,,,-,.,/,:,;,<,=,>,?,@,[,\,\,],^,_,`,{,|,},~'
|
|
||||||
KEYS_INPUT_SINGLE="$KEYS_INPUT_SINGLE,'"
|
|
||||||
KEYS_INPUT_SPECIAL="space,backspace,delete,left,right"
|
|
||||||
export KEYS_INPUT_SINGLE KEYS_INPUT_SPECIAL
|
|
||||||
|
|
||||||
# Normal and insert mode
|
|
||||||
KEYS_NI="$KEYS_HALFPAGE_DOWN,$KEYS_HALFPAGE_UP,$KEYS_BROWSE,$KEYS_OPEN,$KEYS_OUT,$KEYS_IN,$KEYS_SELECT_ARTIST,$KEYS_FILTER_LOCAL,$KEYS_FILTER_1,$KEYS_FILTER_2,$KEYS_FILTER_3,$KEYS_FILTER_4,$KEYS_SWITCH_ARTIST_ALBUM,$KEYS_SWITCH_LOCAL_REMOTE,$KEYS_PLAY,$KEYS_QUEUE,$KEYS_SHOW_PLAYLIST"
|
|
||||||
export KEYS_NI
|
|
||||||
|
|
||||||
# Keys in normal mode only
|
|
||||||
KEYS_N="$KEYS_N_DOWN,$KEYS_N_UP,$KEYS_N_OUT,$KEYS_N_IN,$KEYS_N_TOP,$KEYS_N_BOT,$KEYS_N_QUIT,$KEYS_N_INSERT,$KEYS_N_TOGGLE_PLAYBACK,$KEYS_N_PLAY_NEXT,$KEYS_N_PLAY_PREV,$KEYS_N_SEEK_FORWARD,$KEYS_N_SEEK_BACKWARD"
|
|
||||||
export KEYS_N
|
|
||||||
|
|
||||||
# Keys in insert mode only
|
|
||||||
KEYS_I="$KEYS_I_NORMAL"
|
|
||||||
export KEYS_I
|
|
||||||
|
|
||||||
# Special playlist keys
|
|
||||||
KEYS_PLAYLIST="$KEYS_PLAYLIST_RELOAD"
|
|
||||||
export KEYS_PLAYLIST
|
|
||||||
|
|
||||||
# Grouping
|
|
||||||
KEYS_ALL="$KEYS_NI,$KEYS_N,$KEYS_I,$KEYS_INPUT_SINGLE,$KEYS_INPUT_SPECIAL,$KEYS_PLAYLIST"
|
|
||||||
|
|
||||||
export KEYS_HALFPAGE_DOWN KEYS_HALFPAGE_UP KEYS_OPEN KEYS_BROWSE KEYS_OUT KEYS_IN \
|
|
||||||
KEYS_SELECT_ARTIST KEYS_FILTER_LOCAL KEYS_FILTER_1 KEYS_FILTER_2 KEYS_FILETER_3 KEYS_FILTER_4 \
|
|
||||||
KEYS_SWITCH_ARTIST_ALBUM KEYS_SWITCH_LOCAL_REMOTE KEYS_PLAY KEYS_QUEUE \
|
|
||||||
KEYS_N_DOWN KEYS_N_UP KEYS_N_OUT KEYS_N_IN KEYS_N_TOP KEYS_N_BOT KEYS_N_QUIT KEYS_N_INSERT \
|
|
||||||
KEYS_N_TOGGLE_PLAYBACK KEYS_N_PLAY_NEXT KEYS_N_PLAY_PREV KEYS_N_SEEK_FORWARD \
|
|
||||||
KEYS_N_SEEK_BACKWARD KEYS_SHOW_PLAYLIST \
|
|
||||||
KEYS_I_NORMAL \
|
|
||||||
KEYS_GROUP_NI KEYS_GROUP_N KEYS_GROUP_I KEYS PLAYLIST KEYS_ALL
|
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
# List release groups of given artist
|
# List release groups of given artist
|
||||||
# argument $1: MB artist id
|
# argument $1: MB artist id
|
||||||
list_releasegroups() {
|
list_releasegroups() {
|
||||||
name=$(mb_artist "$1" | $JQ -r '.name')
|
name=$(mb_artist "$1" | $JQ '.name')
|
||||||
mb_artist_releasegroups "$1" |
|
mb_artist_releasegroups "$1" |
|
||||||
$JQ -r '."release-groups"[] | [
|
$JQ '."release-groups"[] | [
|
||||||
.id,
|
.id,
|
||||||
."primary-type",
|
."primary-type",
|
||||||
(."secondary-types" // []|join(";")),
|
(."secondary-types" // []|join(";")),
|
||||||
@@ -50,11 +50,11 @@ list_releasegroups() {
|
|||||||
# argument $1: MB release-group id
|
# argument $1: MB release-group id
|
||||||
list_releases() {
|
list_releases() {
|
||||||
title="$(mb_releasegroup "$1" |
|
title="$(mb_releasegroup "$1" |
|
||||||
$JQ -r '.title')"
|
$JQ '.title')"
|
||||||
artist="$(mb_releasegroup "$1" |
|
artist="$(mb_releasegroup "$1" |
|
||||||
$JQ -r '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
|
$JQ '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
|
||||||
mb_releasegroup_releases "$1" |
|
mb_releasegroup_releases "$1" |
|
||||||
$JQ -r '."releases"[] | [
|
$JQ '."releases"[] | [
|
||||||
.id,
|
.id,
|
||||||
.status,
|
.status,
|
||||||
.date,
|
.date,
|
||||||
@@ -97,10 +97,10 @@ list_recordings() {
|
|||||||
deco="$(grep "$1" "$LOCALDATA_RELEASES" | cut -d "$(printf '\t')" -f 2)"
|
deco="$(grep "$1" "$LOCALDATA_RELEASES" | cut -d "$(printf '\t')" -f 2)"
|
||||||
if [ "$deco" ]; then
|
if [ "$deco" ]; then
|
||||||
rectmp=$(mktemp)
|
rectmp=$(mktemp)
|
||||||
$JQ -r '.tracks | keys | join("\n")' "$deco" >"$rectmp"
|
$JQ '.tracks | keys | join("\n")' "$deco" >"$rectmp"
|
||||||
fi
|
fi
|
||||||
mb_release "$1" |
|
mb_release "$1" |
|
||||||
$JQ -r \
|
$JQ \
|
||||||
--arg rid "$1" \
|
--arg rid "$1" \
|
||||||
--arg deco "$deco" \
|
--arg deco "$deco" \
|
||||||
'.media[] |
|
'.media[] |
|
||||||
@@ -146,51 +146,10 @@ list_local_releases() {
|
|||||||
cat "$LOCALDATA_RELEASES_VIEW" 2>/dev/null
|
cat "$LOCALDATA_RELEASES_VIEW" 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate playlist from MB release ID and path to decoration
|
|
||||||
# @argument $1: MusicBrainz Release ID
|
|
||||||
# @argument $2: Path to decoration file
|
|
||||||
# @argument $3: MusicBrainz Track ID to select (optional)
|
|
||||||
generate_playlist() {
|
|
||||||
printf "#EXTM3U\n"
|
|
||||||
dir="$(dirname "$2")"
|
|
||||||
mb_release "$1" |
|
|
||||||
$JQ -r \
|
|
||||||
--slurpfile decofile "$2" \
|
|
||||||
--arg base "$dir" \
|
|
||||||
--arg deco "$2" \
|
|
||||||
--arg tid "${3:-}" \
|
|
||||||
'$decofile[].tracks as $filenames |
|
|
||||||
. |
|
|
||||||
.id as $rid |
|
|
||||||
.media[] |
|
|
||||||
.position as $pos |
|
|
||||||
.tracks |
|
|
||||||
if ($tid == "") then . else map(select(.id == $tid)) end |
|
|
||||||
map({
|
|
||||||
t: [
|
|
||||||
$rid,
|
|
||||||
.id,
|
|
||||||
$pos,
|
|
||||||
.number,
|
|
||||||
.length,
|
|
||||||
.title,
|
|
||||||
(."artist-credit" | map([.name, .joinphrase] | join("")) | join("")),
|
|
||||||
$deco
|
|
||||||
] | join("\t"),
|
|
||||||
length: (.length / 1000 | round | tostring),
|
|
||||||
$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("#EXTINF:" + .length + "," + .t + "\n" + $base + "/" + .file)[]'
|
|
||||||
}
|
|
||||||
|
|
||||||
# Generate artist list from JSON
|
# Generate artist list from JSON
|
||||||
list_artists_from_json() {
|
list_artists_from_json() {
|
||||||
cat |
|
cat |
|
||||||
$JQ -r 'map([.artist.id, .artist.type, .name] | join("\t")) | join("\n")' |
|
$JQ 'map([.artist.id, .artist.type, .name] | join("\t")) | join("\n")' |
|
||||||
awk \
|
awk \
|
||||||
-F "\t" \
|
-F "\t" \
|
||||||
-v file_local_artists="${LOCALDATA_ARTISTS:-}" \
|
-v file_local_artists="${LOCALDATA_ARTISTS:-}" \
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
gettags() {
|
gettags() {
|
||||||
ffprobe -v error -show_entries format_tags -print_format json "$1" |
|
ffprobe -v error -show_entries format_tags -print_format json "$1" |
|
||||||
$JQ -r --compact-output '.format.tags | {
|
$JQ '.format.tags | {
|
||||||
trackid: (."MusicBrainz Release Track Id" // ."MUSICBRAINZ_RELEASETRACKID" // ."MusicBrainz/Release Track Id" // ""),
|
trackid: (."MusicBrainz Release Track Id" // ."MUSICBRAINZ_RELEASETRACKID" // ."MusicBrainz/Release Track Id" // ""),
|
||||||
releaseid: (."MusicBrainz Album Id" // ."MUSICBRAINZ_ALBUMID" // ."MusicBrainz/Album Id" // "")
|
releaseid: (."MusicBrainz Album Id" // ."MUSICBRAINZ_ALBUMID" // ."MusicBrainz/Album Id" // "")
|
||||||
}'
|
}'
|
||||||
@@ -19,8 +19,8 @@ decorate() {
|
|||||||
(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') >"$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 -r '.releaseid')
|
rid=$(echo "$mbid" | $JQ '.releaseid')
|
||||||
tid=$(echo "$mbid" | $JQ -r '.trackid')
|
tid=$(echo "$mbid" | $JQ '.trackid')
|
||||||
if [ ! "$rid" ] || [ ! "$tid" ]; then
|
if [ ! "$rid" ] || [ ! "$tid" ]; then
|
||||||
err "File $f: Seems not tagged"
|
err "File $f: Seems not tagged"
|
||||||
releaseid=""
|
releaseid=""
|
||||||
@@ -40,7 +40,7 @@ decorate() {
|
|||||||
done <"$tmpf"
|
done <"$tmpf"
|
||||||
rm -f "$tmpf"
|
rm -f "$tmpf"
|
||||||
if [ "$releaseid" ]; then
|
if [ "$releaseid" ]; then
|
||||||
echo "$decoration" | $JQ --compact-output ".releaseid = \"$releaseid\"" >"$1/$DECORATION_FILENAME"
|
echo "$decoration" | $JQ ".releaseid = \"$releaseid\"" >"$1/$DECORATION_FILENAME"
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@@ -75,13 +75,13 @@ __batch_load_missing() {
|
|||||||
while IFS= read -r mbid; do
|
while IFS= read -r mbid; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"$TYPE_ARTIST")
|
"$TYPE_ARTIST")
|
||||||
name=$(mb_artist "$mbid" | $JQ -r ".name")
|
name=$(mb_artist "$mbid" | $JQ ".name")
|
||||||
;;
|
;;
|
||||||
"$TYPE_RELEASEGROUP")
|
"$TYPE_RELEASEGROUP")
|
||||||
name=$(mb_releasegroup "$mbid" | $JQ -r ".title")
|
name=$(mb_releasegroup "$mbid" | $JQ ".title")
|
||||||
;;
|
;;
|
||||||
"$TYPE_RELEASE")
|
"$TYPE_RELEASE")
|
||||||
name=$(mb_release "$mbid" | $JQ -r ".title")
|
name=$(mb_release "$mbid" | $JQ ".title")
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
cnt=$((cnt + 1))
|
cnt=$((cnt + 1))
|
||||||
@@ -107,7 +107,7 @@ DECORATION_FILENAME=${DECORATION_FILENAME:-"mbid.json"}
|
|||||||
precompute_view() {
|
precompute_view() {
|
||||||
info "Precomputing artist view"
|
info "Precomputing artist view"
|
||||||
while IFS= read -r aid; do
|
while IFS= read -r aid; do
|
||||||
mb_artist "$aid" | $JQ -r '[
|
mb_artist "$aid" | $JQ '[
|
||||||
.id,
|
.id,
|
||||||
.type,
|
.type,
|
||||||
.name,
|
.name,
|
||||||
@@ -129,7 +129,7 @@ precompute_view() {
|
|||||||
sed 's| \+\([0-9a-f-]\+\) \+\([0-9a-f-]\+\)$|\t\1\t\2|' >"$LOCALDATA_ARTISTS_VIEW"
|
sed 's| \+\([0-9a-f-]\+\) \+\([0-9a-f-]\+\)$|\t\1\t\2|' >"$LOCALDATA_ARTISTS_VIEW"
|
||||||
info "Precomputing releasegroup view"
|
info "Precomputing releasegroup view"
|
||||||
while IFS= read -r rgid; do
|
while IFS= read -r rgid; do
|
||||||
mb_releasegroup "$rgid" | $JQ -r '[
|
mb_releasegroup "$rgid" | $JQ '[
|
||||||
.id,
|
.id,
|
||||||
."primary-type",
|
."primary-type",
|
||||||
(."secondary-types" // []|join(";")),
|
(."secondary-types" // []|join(";")),
|
||||||
@@ -172,7 +172,7 @@ precompute_view() {
|
|||||||
info "Precomputing release view"
|
info "Precomputing release view"
|
||||||
cut -d "$(printf '\t')" -f 1 "$LOCALDATA_RELEASES" |
|
cut -d "$(printf '\t')" -f 1 "$LOCALDATA_RELEASES" |
|
||||||
while IFS= read -r rid; do
|
while IFS= read -r rid; do
|
||||||
mb_release "$rid" | $JQ -r '[
|
mb_release "$rid" | $JQ '[
|
||||||
.id,
|
.id,
|
||||||
.status,
|
.status,
|
||||||
.date,
|
.date,
|
||||||
@@ -215,15 +215,15 @@ load_local() {
|
|||||||
[ -f "$tmpreleases" ] || exit 1
|
[ -f "$tmpreleases" ] || exit 1
|
||||||
info "Locating and parsing decoration files ($DECORATION_FILENAME)"
|
info "Locating and parsing decoration files ($DECORATION_FILENAME)"
|
||||||
find "$1" -type f -name "$DECORATION_FILENAME" -print0 |
|
find "$1" -type f -name "$DECORATION_FILENAME" -print0 |
|
||||||
xargs -0 -P 4 $JQ -r '.releaseid+"\t"+input_filename' |
|
xargs -0 -P 4 $JQ '.releaseid+"\t"+input_filename' |
|
||||||
tee "$LOCALDATA_RELEASES" |
|
tee "$LOCALDATA_RELEASES" |
|
||||||
cut -d "$(printf '\t')" -f 1 >"$tmpreleases"
|
cut -d "$(printf '\t')" -f 1 >"$tmpreleases"
|
||||||
__batch_load_missing "$TYPE_RELEASE" "$tmpreleases"
|
__batch_load_missing "$TYPE_RELEASE" "$tmpreleases"
|
||||||
# Get release groups and album artists
|
# Get release groups and album artists
|
||||||
while IFS= read -r rid; do
|
while IFS= read -r rid; do
|
||||||
mb=$(mb_release "$rid")
|
mb=$(mb_release "$rid")
|
||||||
echo "$mb" | $JQ -r '."release-group".id' >>"$LOCALDATA_RELEASEGROUPS"
|
echo "$mb" | $JQ '."release-group".id' >>"$LOCALDATA_RELEASEGROUPS"
|
||||||
echo "$mb" | $JQ -r '."release-group"."artist-credit" | map(.artist.id) | join("\n")' >>"$LOCALDATA_ARTISTS"
|
echo "$mb" | $JQ '."release-group"."artist-credit" | map(.artist.id) | join("\n")' >>"$LOCALDATA_ARTISTS"
|
||||||
done <"$tmpreleases"
|
done <"$tmpreleases"
|
||||||
tf=$(mktemp)
|
tf=$(mktemp)
|
||||||
sort "$LOCALDATA_RELEASEGROUPS" | uniq >"$tf" && mv "$tf" "$LOCALDATA_RELEASEGROUPS"
|
sort "$LOCALDATA_RELEASEGROUPS" | uniq >"$tf" && mv "$tf" "$LOCALDATA_RELEASEGROUPS"
|
||||||
|
15
src/sh/log.sh
Normal file
15
src/sh/log.sh
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Logging methods
|
||||||
|
ERR="\033[38;5;196m"
|
||||||
|
INFO="\033[38;5;75m"
|
||||||
|
OFF="\033[m"
|
||||||
|
LOGDIR="$HOME/.local/state/$APP_NAME"
|
||||||
|
[ -d "$LOGDIR" ] || mkdir -p "$LOGDIR"
|
||||||
|
LOGFILE="$LOGDIR/log"
|
||||||
|
|
||||||
|
err() {
|
||||||
|
echo "$(date) [$$]>${ERR}ERROR:${OFF} ${1:-}" | tee -a "$LOGFILE" | cut -d ">" -f 2- >/dev/stderr
|
||||||
|
}
|
||||||
|
|
||||||
|
info() {
|
||||||
|
echo "$(date) [$$]>${INFO}Info:${OFF} ${1:-}" | tee -a "$LOGFILE" | cut -d ">" -f 2- >/dev/stderr
|
||||||
|
}
|
10
src/sh/mb.sh
10
src/sh/mb.sh
@@ -27,7 +27,7 @@ __mb_artist_cache_or_fetch_releasegroups() {
|
|||||||
if ! cache_get_artist_releasegroups "$1"; then
|
if ! cache_get_artist_releasegroups "$1"; then
|
||||||
api_mb_browse_artist_releasegroups "$1" | cache_put_artist_releasegroups "$1"
|
api_mb_browse_artist_releasegroups "$1" | cache_put_artist_releasegroups "$1"
|
||||||
rg="$(cache_get_artist_releasegroups "$1")"
|
rg="$(cache_get_artist_releasegroups "$1")"
|
||||||
total=$(printf "%s" "$rg" | $JQ -r '."release-group-count"')
|
total=$(printf "%s" "$rg" | $JQ '."release-group-count"')
|
||||||
seen=$MB_BROWSE_STEPS
|
seen=$MB_BROWSE_STEPS
|
||||||
while [ "$total" -gt "$seen" ]; do
|
while [ "$total" -gt "$seen" ]; do
|
||||||
# Fetch remaning release groups, and append to cache
|
# Fetch remaning release groups, and append to cache
|
||||||
@@ -43,7 +43,7 @@ __mb_releasegroup_cache_or_fetch_releases() {
|
|||||||
if ! cache_get_releasegroup_releases "$1"; then
|
if ! cache_get_releasegroup_releases "$1"; then
|
||||||
api_mb_browse_releasegroup_releases "$1" | cache_put_releasegroup_releases "$1"
|
api_mb_browse_releasegroup_releases "$1" | cache_put_releasegroup_releases "$1"
|
||||||
releases="$(cache_get_releasegroup_releases "$1")"
|
releases="$(cache_get_releasegroup_releases "$1")"
|
||||||
total=$(printf "%s" "$releases" | $JQ -r '."release-count"')
|
total=$(printf "%s" "$releases" | $JQ '."release-count"')
|
||||||
seen=$MB_BROWSE_STEPS
|
seen=$MB_BROWSE_STEPS
|
||||||
while [ "$total" -gt "$seen" ]; do
|
while [ "$total" -gt "$seen" ]; do
|
||||||
# Fetch remaning releases, and append to cache
|
# Fetch remaning releases, and append to cache
|
||||||
@@ -66,7 +66,7 @@ mb_artist() {
|
|||||||
mb_artist_wikidata() {
|
mb_artist_wikidata() {
|
||||||
if ! cache_get_artist_wikidata "$1"; then
|
if ! cache_get_artist_wikidata "$1"; then
|
||||||
wikidataid=$(mb_artist "$1" |
|
wikidataid=$(mb_artist "$1" |
|
||||||
$JQ -r '.relations |
|
$JQ '.relations |
|
||||||
map(select(.type=="wikidata")) |
|
map(select(.type=="wikidata")) |
|
||||||
.[0].url.resource // ""' |
|
.[0].url.resource // ""' |
|
||||||
awk -F "/" '{print $NF}')
|
awk -F "/" '{print $NF}')
|
||||||
@@ -89,7 +89,7 @@ mb_artist_enwikipedia() {
|
|||||||
# take the second route.
|
# take the second route.
|
||||||
wikidata=$(mb_artist_wikidata "$1" || true)
|
wikidata=$(mb_artist_wikidata "$1" || true)
|
||||||
wikiid=$(printf "%s" "$wikidata" |
|
wikiid=$(printf "%s" "$wikidata" |
|
||||||
$JQ -r '.enwiki.url // ""' |
|
$JQ '.enwiki.url // ""' |
|
||||||
awk -F "/" '{print $NF}')
|
awk -F "/" '{print $NF}')
|
||||||
[ ! "$wikiid" ] && return
|
[ ! "$wikiid" ] && return
|
||||||
api_wikipedia_en_summary "$wikiid" | cache_put_artist_enwikipedia "$1"
|
api_wikipedia_en_summary "$wikiid" | cache_put_artist_enwikipedia "$1"
|
||||||
@@ -102,7 +102,7 @@ mb_artist_enwikipedia() {
|
|||||||
mb_artist_discogs() {
|
mb_artist_discogs() {
|
||||||
if ! cache_get_artist_discogs "$1"; then
|
if ! cache_get_artist_discogs "$1"; then
|
||||||
discogsid=$(mb_artist "$1" |
|
discogsid=$(mb_artist "$1" |
|
||||||
$JQ -r '.relations |
|
$JQ '.relations |
|
||||||
map(select(.type=="discogs")) |
|
map(select(.type=="discogs")) |
|
||||||
.[0].url.resource // ""' |
|
.[0].url.resource // ""' |
|
||||||
awk -F "/" '{print $NF}')
|
awk -F "/" '{print $NF}')
|
||||||
|
@@ -11,7 +11,7 @@ __mpv_command_with_args2() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
__mpv_get() {
|
__mpv_get() {
|
||||||
__mpv_command_with_arg "expand-text" "$1" | $JQ -r '.data'
|
__mpv_command_with_arg "expand-text" "$1" | $JQ '.data'
|
||||||
}
|
}
|
||||||
|
|
||||||
mpv_playlist_count() {
|
mpv_playlist_count() {
|
||||||
|
@@ -1,3 +1,8 @@
|
|||||||
|
# Playback tools and helper
|
||||||
|
#
|
||||||
|
# The methods to control the mpv instance are in `src/sh/mpv.sh`. Here,
|
||||||
|
# a higher-level playback functionality is provided.
|
||||||
|
|
||||||
# Available playback commands
|
# Available playback commands
|
||||||
PLAYBACK_CMD_PLAY="play"
|
PLAYBACK_CMD_PLAY="play"
|
||||||
PLAYBACK_CMD_QUEUE="queue"
|
PLAYBACK_CMD_QUEUE="queue"
|
||||||
@@ -10,7 +15,7 @@ PLAYBACK_CMD_SEEK_BACKWARD="seekb"
|
|||||||
|
|
||||||
# Obtain playback command from key press
|
# Obtain playback command from key press
|
||||||
# @argument $1: key
|
# @argument $1: key
|
||||||
playback_cmd_from_key() {
|
__playback_cmd_from_key() {
|
||||||
key=$1
|
key=$1
|
||||||
case ",$KEYS_PLAY," in *",$key,"*) echo "$PLAYBACK_CMD_PLAY" && return ;; esac
|
case ",$KEYS_PLAY," in *",$key,"*) echo "$PLAYBACK_CMD_PLAY" && return ;; esac
|
||||||
case ",$KEYS_N_PLAY," in *",$key,"*) echo "$PLAYBACK_CMD_PLAY" && return ;; esac
|
case ",$KEYS_N_PLAY," in *",$key,"*) echo "$PLAYBACK_CMD_PLAY" && return ;; esac
|
||||||
@@ -29,3 +34,97 @@ playback_cmd_from_key() {
|
|||||||
case ",$KEYS_SEEK_BACKWARD," in *",$key,"*) echo "$PLAYBACK_CMD_SEEK_BACKWARD" && return ;; esac
|
case ",$KEYS_SEEK_BACKWARD," in *",$key,"*) echo "$PLAYBACK_CMD_SEEK_BACKWARD" && return ;; esac
|
||||||
case ",$KEYS_N_SEEK_BACKWARD," in *",$key,"*) echo "$PLAYBACK_CMD_SEEK_BACKWARD" && return ;; esac
|
case ",$KEYS_N_SEEK_BACKWARD," in *",$key,"*) echo "$PLAYBACK_CMD_SEEK_BACKWARD" && return ;; esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Generate playlist from MB release ID and path to decoration
|
||||||
|
# @argument $1: MusicBrainz Release ID
|
||||||
|
# @argument $2: Path to decoration file
|
||||||
|
# @argument $3: MusicBrainz Track ID to select (optional)
|
||||||
|
__generate_playlist() {
|
||||||
|
printf "#EXTM3U\n"
|
||||||
|
dir="$(dirname "$2")"
|
||||||
|
mb_release "$1" |
|
||||||
|
$JQ \
|
||||||
|
--slurpfile decofile "$2" \
|
||||||
|
--arg base "$dir" \
|
||||||
|
--arg deco "$2" \
|
||||||
|
--arg tid "${3:-}" \
|
||||||
|
'$decofile[].tracks as $filenames |
|
||||||
|
. |
|
||||||
|
.id as $rid |
|
||||||
|
.media[] |
|
||||||
|
.position as $pos |
|
||||||
|
.tracks |
|
||||||
|
if ($tid == "") then . else map(select(.id == $tid)) end |
|
||||||
|
map({
|
||||||
|
t: [
|
||||||
|
$rid,
|
||||||
|
.id,
|
||||||
|
$pos,
|
||||||
|
.number,
|
||||||
|
.length,
|
||||||
|
.title,
|
||||||
|
(."artist-credit" | map([.name, .joinphrase] | join("")) | join("")),
|
||||||
|
$deco
|
||||||
|
] | join("\t"),
|
||||||
|
length: (.length / 1000 | round | tostring),
|
||||||
|
$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("#EXTINF:" + .length + "," + .t + "\n" + $base + "/" + .file)[]'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main playback method
|
||||||
|
#
|
||||||
|
# @argument $1: view
|
||||||
|
# @argument $2: MusicBrainz ID of current object
|
||||||
|
# @argument $3: MusicBrainz ID of selected object
|
||||||
|
# @argument $4: Path to decoration file
|
||||||
|
#
|
||||||
|
# This option controls the mpv instance via a key pressed in fzf. The key
|
||||||
|
# pressed is stored in the environment variable FZF_KEY and is resolved to
|
||||||
|
# the playback command through the method `__playback_cmd_from_key`.
|
||||||
|
playback() {
|
||||||
|
view=${1:-}
|
||||||
|
mbid_current="${2:-}"
|
||||||
|
mbid="${3:-}"
|
||||||
|
path="${4:-}"
|
||||||
|
pbcmd=$(__playback_cmd_from_key "$FZF_KEY")
|
||||||
|
info "playback(): view=$view; mbid_current=$mbid_current; mbid=$mbid; path=$path; pbcmd=$pbcmd"
|
||||||
|
case "$pbcmd" in
|
||||||
|
"$PLAYBACK_CMD_PLAY")
|
||||||
|
[ "$path" ] || exit 0
|
||||||
|
case "$view" in
|
||||||
|
"$VIEW_ARTIST" | "$VIEW_SEARCH_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ARTISTS" | "$VIEW_LIST_ALBUMS") info "not implemented" ;;
|
||||||
|
"$VIEW_RELEASEGROUP") __generate_playlist "$mbid" "$path" | mpv_play_list >/dev/null ;;
|
||||||
|
"$VIEW_RELEASE") __generate_playlist "$mbid_current" "$path" "$mbid" | mpv_play_list >/dev/null ;;
|
||||||
|
"$VIEW_PLAYLIST") mpv_play_index $((FZF_POS - 1)) >/dev/null ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
"$PLAYBACK_CMD_QUEUE")
|
||||||
|
[ "$path" ] || exit 0
|
||||||
|
case "$view" in
|
||||||
|
"$VIEW_ARTIST" | "$VIEW_SEARCH_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ARTISTS" | "$VIEW_LIST_ALBUMS") info "not implemented" ;;
|
||||||
|
"$VIEW_RELEASEGROUP") __generate_playlist "$mbid" "$path" | mpv_queue_list >/dev/null ;;
|
||||||
|
"$VIEW_RELEASE") __generate_playlist "$mbid_current" "$path" "$mbid" | mpv_queue_list >/dev/null ;;
|
||||||
|
"$VIEW_PLAYLIST") __generate_playlist "$mbid_current" "$path" "$mbid" | mpv_queue_list >/dev/null ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
"$PLAYBACK_CMD_QUEUE_NEXT")
|
||||||
|
[ "$path" ] || exit 0
|
||||||
|
case "$view" in
|
||||||
|
"$VIEW_ARTIST" | "$VIEW_SEARCH_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ARTISTS" | "$VIEW_LIST_ALBUMS") info "not implemented" ;;
|
||||||
|
"$VIEW_RELEASEGROUP") __generate_playlist "$mbid" "$path" | mpv_queue_next_list >/dev/null ;;
|
||||||
|
"$VIEW_RELEASE") __generate_playlist "$mbid_current" "$path" "$mbid" | mpv_queue_next_list >/dev/null ;;
|
||||||
|
"$VIEW_PLAYLIST") __generate_playlist "$mbid_current" "$path" "$mbid" | mpv_queue_next_list >/dev/null ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
"$PLAYBACK_CMD_TOGGLE_PLAYBACK") mpv_toggle_pause ;;
|
||||||
|
"$PLAYBACK_CMD_PLAY_NEXT") mpv_next ;;
|
||||||
|
"$PLAYBACK_CMD_PLAY_PREV") mpv_prev ;;
|
||||||
|
"$PLAYBACK_CMD_SEEK_FORWARD") mpv_seek_forward ;;
|
||||||
|
"$PLAYBACK_CMD_SEEK_BACKWARD") mpv_seek_backward ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
@@ -4,3 +4,29 @@ PLAYLIST_CMD_DOWN="down"
|
|||||||
PLAYLIST_CMD_CLEAR="clear"
|
PLAYLIST_CMD_CLEAR="clear"
|
||||||
PLAYLIST_CMD_CLEAR_ABOVE="clear-above"
|
PLAYLIST_CMD_CLEAR_ABOVE="clear-above"
|
||||||
PLAYLIST_CMD_CLEAR_BELOW="clear-below"
|
PLAYLIST_CMD_CLEAR_BELOW="clear-below"
|
||||||
|
|
||||||
|
# Run playback commands
|
||||||
|
#
|
||||||
|
# @argument $1: playlist command
|
||||||
|
#
|
||||||
|
# This is a wrapper to execute mpv commands.
|
||||||
|
playlist() {
|
||||||
|
case "$1" in
|
||||||
|
"$PLAYLIST_CMD_REMOVE") mpv_rm_index $((FZF_POS - 1)) ;;
|
||||||
|
"$PLAYLIST_CMD_UP") mpv_playlist_move $((FZF_POS - 1)) $((FZF_POS - 2)) ;;
|
||||||
|
"$PLAYLIST_CMD_DOWN") mpv_playlist_move $((FZF_POS - 0)) $((FZF_POS - 1)) ;;
|
||||||
|
"$PLAYLIST_CMD_CLEAR") mpv_playlist_clear ;;
|
||||||
|
"$PLAYLIST_CMD_CLEAR_ABOVE")
|
||||||
|
for i in $(seq "$FZF_POS"); do
|
||||||
|
mpv_rm_index 0
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
"$PLAYLIST_CMD_CLEAR_BELOW")
|
||||||
|
cnt=$(mpv_playlist_count)
|
||||||
|
rem=$((cnt - FZF_POS + 1))
|
||||||
|
for i in $(seq "$rem"); do
|
||||||
|
mpv_rm_index $((FZF_POS - 1))
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
@@ -5,14 +5,14 @@ __shape() {
|
|||||||
# Print preview of artist
|
# Print preview of artist
|
||||||
# @input $1: MusicBrainz Artist ID
|
# @input $1: MusicBrainz Artist ID
|
||||||
__preview_artist() {
|
__preview_artist() {
|
||||||
desc=$(mb_artist_enwikipedia "$1" | $JQ -r '.extract' | __shape)
|
desc=$(mb_artist_enwikipedia "$1" | $JQ '.extract' | __shape)
|
||||||
[ "$desc" ] || desc=$(mb_artist_discogs "$1" | $JQ -r '.profile' | sed 's/\[a=\([^]]*\)\]/\1/g' | __shape)
|
[ "$desc" ] || desc=$(mb_artist_discogs "$1" | $JQ '.profile' | sed 's/\[a=\([^]]*\)\]/\1/g' | __shape)
|
||||||
if [ "$(mb_artist "$1" | $JQ -r '.type')" = "Person" ]; then
|
if [ "$(mb_artist "$1" | $JQ '.type')" = "Person" ]; then
|
||||||
# Show birth place and death place of person
|
# Show birth place and death place of person
|
||||||
lsb=$(mb_artist "$1" | $JQ -r '."life-span".begin // ""' | head -c 4)
|
lsb=$(mb_artist "$1" | $JQ '."life-span".begin // ""' | head -c 4)
|
||||||
lse=$(mb_artist "$1" | $JQ -r '."life-span".end // ""' | head -c 4)
|
lse=$(mb_artist "$1" | $JQ '."life-span".end // ""' | head -c 4)
|
||||||
ab=$(mb_artist "$1" | $JQ -r '."begin-area".name // ""')
|
ab=$(mb_artist "$1" | $JQ '."begin-area".name // ""')
|
||||||
ae=$(mb_artist "$1" | $JQ -r '."end-area".name // ""')
|
ae=$(mb_artist "$1" | $JQ '."end-area".name // ""')
|
||||||
if [ "$lsb" ] && [ "$ab" ]; then
|
if [ "$lsb" ] && [ "$ab" ]; then
|
||||||
begin=$(printf "$APV_DATEPLACE" "$lsb" "$ab")
|
begin=$(printf "$APV_DATEPLACE" "$lsb" "$ab")
|
||||||
elif [ "$lsb" ]; then
|
elif [ "$lsb" ]; then
|
||||||
|
155
src/sh/query.sh
Normal file
155
src/sh/query.sh
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
# The default queries depend on the current view, and are usually derived from
|
||||||
|
# the theme. Nevertheless, they may be overwritten with the configuration file.
|
||||||
|
# Note that filters are not used in the views VIEW_SEARCH_ARTIST and
|
||||||
|
# VIEW_SEARCH_ALBUM. The reason for this is that in those modes, changing the
|
||||||
|
# query string triggers a search on the MusicBrainz website (the input is not a
|
||||||
|
# filter, but a query).
|
||||||
|
#
|
||||||
|
# The keybinding KEYS_FILTER_LOCAL triggers a filter of QUERY_LOCAL in the
|
||||||
|
# views VIEW_ARTIST, VIEW_RELEASEGROUP, and VIEW_RELEASE only. Here, it is only
|
||||||
|
# possible to adjust QUERY_LOCAL via the configuration. The keybinding KEYS_FILTER_0
|
||||||
|
# resets the query. F_1_.. filters are the default filters when the respective
|
||||||
|
# view is entered. For all other keys, the filters are individually
|
||||||
|
# configurable, by specifying e.g., F_3_VIEW_LIST_ALBUMS.
|
||||||
|
#
|
||||||
|
# Derived queries
|
||||||
|
# To derive the queries from the theme, we must perform some steps: 1) remove
|
||||||
|
# colors, and 2) escape white spaces. This is implemented in the method
|
||||||
|
# `__clean_filter`.
|
||||||
|
#
|
||||||
|
# List of derived queries:
|
||||||
|
# - QUERY_LOCAL: Hide items that are not locally available
|
||||||
|
# - q_has_secondary: Release groups with secondary types
|
||||||
|
# - q_album: Release group is of type Album
|
||||||
|
# - q_ep: Release group is of type EP
|
||||||
|
# - q_single: Release group is of type single
|
||||||
|
# - q_official: Release is official
|
||||||
|
|
||||||
|
__clean_filter() {
|
||||||
|
cat | sed "s/${ESC}\[[0-9;]*[mK]//g" | sed "s/ /\\\ /g"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Determine preset query
|
||||||
|
# @argument $1: Current view
|
||||||
|
# @argument $2: Key pressed (optional)
|
||||||
|
#
|
||||||
|
# If the key is not given, then the F_1_.. query is used for the respective
|
||||||
|
# view, i.e, its as if a key from KEYS_FILTER_1 has been pressed.
|
||||||
|
default_query() {
|
||||||
|
view=$1
|
||||||
|
key="${2:-"$(echo "$KEYS_FILTER_1" | cut -d ',' -f 1)"}"
|
||||||
|
case ",$KEYS_FILTER_LOCAL," in
|
||||||
|
*",$key,"*)
|
||||||
|
case "$view" in
|
||||||
|
"$VIEW_ARTIST" | "$VIEW_RELEASEGROUP" | "$VIEW_RELEASE") echo "$QUERY_LOCAL" ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case ",$KEYS_FILTER_1," in
|
||||||
|
*",$key,"*)
|
||||||
|
case "$view" in
|
||||||
|
"$VIEW_ARTIST") echo "$F_1_VIEW_ARTIST" ;;
|
||||||
|
"$VIEW_RELEASEGROUP") echo "$F_1_VIEW_RELEASEGROUP" ;;
|
||||||
|
"$VIEW_RELEASE") echo "$F_1_VIEW_RELEASE" ;;
|
||||||
|
"$VIEW_LIST_ARTISTS") echo "$F_1_LIST_ARTISTS" ;;
|
||||||
|
"$VIEW_LIST_ALBUMS") echo "$F_1_LIST_ALBUMS" ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case ",$KEYS_FILTER_2," in
|
||||||
|
*",$key,"*)
|
||||||
|
case "$view" in
|
||||||
|
"$VIEW_ARTIST") echo "$F_2_VIEW_ARTIST" ;;
|
||||||
|
"$VIEW_RELEASEGROUP") echo "$F_2_VIEW_RELEASEGROUP" ;;
|
||||||
|
"$VIEW_RELEASE") echo "$F_2_VIEW_RELEASE" ;;
|
||||||
|
"$VIEW_LIST_ARTISTS") echo "$F_2_LIST_ARTISTS" ;;
|
||||||
|
"$VIEW_LIST_ALBUMS") echo "$F_2_LIST_ALBUMS" ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case ",$KEYS_FILTER_3," in
|
||||||
|
*",$key,"*)
|
||||||
|
case "$view" in
|
||||||
|
"$VIEW_ARTIST") echo "$F_3_VIEW_ARTIST" ;;
|
||||||
|
"$VIEW_RELEASEGROUP") echo "$F_3_VIEW_RELEASEGROUP" ;;
|
||||||
|
"$VIEW_RELEASE") echo "$F_3_VIEW_RELEASE" ;;
|
||||||
|
"$VIEW_LIST_ARTISTS") echo "$F_3_LIST_ARTISTS" ;;
|
||||||
|
"$VIEW_LIST_ALBUMS") echo "$F_3_LIST_ALBUMS" ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case ",$KEYS_FILTER_4," in
|
||||||
|
*",$key,"*)
|
||||||
|
case "$view" in
|
||||||
|
"$VIEW_ARTIST") echo "$F_4_VIEW_ARTIST" ;;
|
||||||
|
"$VIEW_RELEASEGROUP") echo "$F_4_VIEW_RELEASEGROUP" ;;
|
||||||
|
"$VIEW_RELEASE") echo "$F_4_VIEW_RELEASE" ;;
|
||||||
|
"$VIEW_LIST_ARTISTS") echo "$F_4_LIST_ARTISTS" ;;
|
||||||
|
"$VIEW_LIST_ALBUMS") echo "$F_4_LIST_ALBUMS" ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case ",$KEYS_FILTER_5," in
|
||||||
|
*",$key,"*)
|
||||||
|
case "$view" in
|
||||||
|
"$VIEW_ARTIST") echo "$F_5_VIEW_ARTIST" ;;
|
||||||
|
"$VIEW_RELEASEGROUP") echo "$F_5_VIEW_RELEASEGROUP" ;;
|
||||||
|
"$VIEW_RELEASE") echo "$F_5_VIEW_RELEASE" ;;
|
||||||
|
"$VIEW_LIST_ARTISTS") echo "$F_5_LIST_ARTISTS" ;;
|
||||||
|
"$VIEW_LIST_ALBUMS") echo "$F_5_LIST_ALBUMS" ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case ",$KEYS_FILTER_6," in
|
||||||
|
*",$key,"*)
|
||||||
|
case "$view" in
|
||||||
|
"$VIEW_ARTIST") echo "$F_6_VIEW_ARTIST" ;;
|
||||||
|
"$VIEW_RELEASEGROUP") echo "$F_6_VIEW_RELEASEGROUP" ;;
|
||||||
|
"$VIEW_RELEASE") echo "$F_6_VIEW_RELEASE" ;;
|
||||||
|
"$VIEW_LIST_ARTISTS") echo "$F_6_LIST_ARTISTS" ;;
|
||||||
|
"$VIEW_LIST_ALBUMS") echo "$F_6_LIST_ALBUMS" ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case ",$KEYS_FILTER_7," in
|
||||||
|
*",$key,"*)
|
||||||
|
case "$view" in
|
||||||
|
"$VIEW_ARTIST") echo "$F_7_VIEW_ARTIST" ;;
|
||||||
|
"$VIEW_RELEASEGROUP") echo "$F_7_VIEW_RELEASEGROUP" ;;
|
||||||
|
"$VIEW_RELEASE") echo "$F_7_VIEW_RELEASE" ;;
|
||||||
|
"$VIEW_LIST_ARTISTS") echo "$F_7_LIST_ARTISTS" ;;
|
||||||
|
"$VIEW_LIST_ALBUMS") echo "$F_7_LIST_ALBUMS" ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case ",$KEYS_FILTER_8," in
|
||||||
|
*",$key,"*)
|
||||||
|
case "$view" in
|
||||||
|
"$VIEW_ARTIST") echo "$F_8_VIEW_ARTIST" ;;
|
||||||
|
"$VIEW_RELEASEGROUP") echo "$F_8_VIEW_RELEASEGROUP" ;;
|
||||||
|
"$VIEW_RELEASE") echo "$F_8_VIEW_RELEASE" ;;
|
||||||
|
"$VIEW_LIST_ARTISTS") echo "$F_8_LIST_ARTISTS" ;;
|
||||||
|
"$VIEW_LIST_ALBUMS") echo "$F_8_LIST_ALBUMS" ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case ",$KEYS_FILTER_9," in
|
||||||
|
*",$key,"*)
|
||||||
|
case "$view" in
|
||||||
|
"$VIEW_ARTIST") echo "$F_9_VIEW_ARTIST" ;;
|
||||||
|
"$VIEW_RELEASEGROUP") echo "$F_9_VIEW_RELEASEGROUP" ;;
|
||||||
|
"$VIEW_RELEASE") echo "$F_9_VIEW_RELEASE" ;;
|
||||||
|
"$VIEW_LIST_ARTISTS") echo "$F_9_LIST_ARTISTS" ;;
|
||||||
|
"$VIEW_LIST_ALBUMS") echo "$F_9_LIST_ALBUMS" ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
# Doing nothing is the same as this last block:
|
||||||
|
# case ",$KEYS_FILTER_0," in
|
||||||
|
# *",$key,"*)
|
||||||
|
# case "$view" in
|
||||||
|
# "$VIEW_ARTIST" | "$VIEW_RELEASEGROUP" | "$VIEW_RELEASE" | "$VIEW_LIST_ARTISTS" | "$VIEW_LIST_ALBUMS") echo "" ;;
|
||||||
|
# esac
|
||||||
|
# ;;
|
||||||
|
# esac
|
||||||
|
}
|
@@ -1,49 +0,0 @@
|
|||||||
# Update state
|
|
||||||
# @argument $1: view
|
|
||||||
# @argument $2: mode
|
|
||||||
# @argument $3: arguments
|
|
||||||
state_update() {
|
|
||||||
mv "$STATEFILE" "$STATEFILE_LAST"
|
|
||||||
mv "$ARGSFILE" "$ARGSFILE_LAST"
|
|
||||||
printf "%s#%s" "${1:-}" "${2:-}" >"$STATEFILE"
|
|
||||||
printf "%s" "${3:-}" >"$ARGSFILE"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Initialize state
|
|
||||||
# @argument $1: view
|
|
||||||
# @argument $2: mode
|
|
||||||
# @argument $3: arguments
|
|
||||||
state_init() {
|
|
||||||
state_update "$1" "$2" "$3"
|
|
||||||
state_update "$1" "$2" "$3"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Update state and keep arguments
|
|
||||||
# @argument $1: view
|
|
||||||
# @argument $2: mode
|
|
||||||
state_update_keep_args() {
|
|
||||||
mv "$STATEFILE" "$STATEFILE_LAST"
|
|
||||||
cp "$ARGSFILE" "$ARGSFILE_LAST"
|
|
||||||
printf "%s#%s" "${1:-}" "${2:-}" >"$STATEFILE"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Go back to previous state
|
|
||||||
state_revert() {
|
|
||||||
cp "$STATEFILE_LAST" "$STATEFILE"
|
|
||||||
cp "$ARGSFILE_LAST" "$ARGSFILE"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get view
|
|
||||||
state_get_view() {
|
|
||||||
cut -d "#" -f 1 "$STATEFILE"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get mode
|
|
||||||
state_get_mode() {
|
|
||||||
cut -d "#" -f 2 "$STATEFILE"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get args
|
|
||||||
state_get_args() {
|
|
||||||
cat "$ARGSFILE"
|
|
||||||
}
|
|
@@ -23,6 +23,7 @@ OFF="${ESC}[m"
|
|||||||
FORMAT_LOCAL="${FORMAT_LOCAL:-"🔆"}"
|
FORMAT_LOCAL="${FORMAT_LOCAL:-"🔆"}"
|
||||||
# Pointer to the track currently playing (playlist)
|
# Pointer to the track currently playing (playlist)
|
||||||
FORMAT_CURRENT="${FORMAT_CURRENT:-"👉"}"
|
FORMAT_CURRENT="${FORMAT_CURRENT:-"👉"}"
|
||||||
|
export FORMAT_LOCAL FORMAT_CURRENT
|
||||||
|
|
||||||
# Input prompts
|
# Input prompts
|
||||||
# =============
|
# =============
|
||||||
@@ -33,6 +34,7 @@ ARTIST_PROMPT="${ARTIST_PROMPT:-"🎤 ${CARTIST}%s$OFF 〉"}"
|
|||||||
# Prompt that takes an artist name and a release name as arguments (in that
|
# Prompt that takes an artist name and a release name as arguments (in that
|
||||||
# order)
|
# order)
|
||||||
FULL_PROMPT="${FULL_PROMPT:-"🎤 ${CARTIST}%s$OFF 》${CTITLE}%s$OFF 〉"}"
|
FULL_PROMPT="${FULL_PROMPT:-"🎤 ${CARTIST}%s$OFF 》${CTITLE}%s$OFF 〉"}"
|
||||||
|
export SEARCH_PROMPT ARTIST_PROMPT FULL_PROMPT
|
||||||
|
|
||||||
# Visual representation of current mode
|
# Visual representation of current mode
|
||||||
# =====================================
|
# =====================================
|
||||||
@@ -40,6 +42,7 @@ FULL_PROMPT="${FULL_PROMPT:-"🎤 ${CARTIST}%s$OFF 》${CTITLE}%s$OFF 〉"}"
|
|||||||
PROMPT_NORMAL="${PROMPT_NORMAL:-"${FAINT}[n]${OFF}"}"
|
PROMPT_NORMAL="${PROMPT_NORMAL:-"${FAINT}[n]${OFF}"}"
|
||||||
# Sign to indicate `insert` mode
|
# Sign to indicate `insert` mode
|
||||||
PROMPT_INSERT="${PROMPT_INSERT:-"${FAINT}[i]${OFF}"}"
|
PROMPT_INSERT="${PROMPT_INSERT:-"${FAINT}[i]${OFF}"}"
|
||||||
|
export PROMPT_NORMAL PROMPT_INSERT
|
||||||
|
|
||||||
# Artist view
|
# Artist view
|
||||||
# ===========
|
# ===========
|
||||||
@@ -49,6 +52,7 @@ AV_PERSON="${AV_PERSON:-"🧑🎤 $CARTIST<<name>>$OFF"}"
|
|||||||
AV_GROUP="${AV_GROUP:-"🧑🤝🧑 $CARTIST<<name>>$OFF"}"
|
AV_GROUP="${AV_GROUP:-"🧑🤝🧑 $CARTIST<<name>>$OFF"}"
|
||||||
# Artist disambiguation string
|
# Artist disambiguation string
|
||||||
AV_DISAMBIGUATION="${AV_DISAMBIGUATION:-"$CDISAMB(<<disambiguation>>)$OFF"}"
|
AV_DISAMBIGUATION="${AV_DISAMBIGUATION:-"$CDISAMB(<<disambiguation>>)$OFF"}"
|
||||||
|
export AV_PERSON AV_GROUP AV_DISAMBIGUATION
|
||||||
|
|
||||||
# Release-group view
|
# Release-group view
|
||||||
# ==================
|
# ==================
|
||||||
@@ -58,6 +62,7 @@ RGV_RELEASE="${RGV_RELEASE:-"${CTITLE}<<title>>$OFF"}"
|
|||||||
RGV_RELEASE_W_ARTIST="${RGV_RELEASE_W_ARTIST:-"${CTITLE}<<title>>$OFF — ${CARTIST}<<artist>>$OFF"}"
|
RGV_RELEASE_W_ARTIST="${RGV_RELEASE_W_ARTIST:-"${CTITLE}<<title>>$OFF — ${CARTIST}<<artist>>$OFF"}"
|
||||||
# Year of the release group
|
# Year of the release group
|
||||||
RGV_YEAR="${RGV_YEAR:-"${CYEAR}(<<year>>)$OFF"}"
|
RGV_YEAR="${RGV_YEAR:-"${CYEAR}(<<year>>)$OFF"}"
|
||||||
|
export RGV_RELEASE RGV_RELEASE_W_ARTIST RGV_YEAR
|
||||||
|
|
||||||
# Release-group types
|
# Release-group types
|
||||||
# ===================
|
# ===================
|
||||||
@@ -88,6 +93,15 @@ FORMAT_TYPE_SECONDARY_DJMIX="${FORMAT_TYPE_SECONDARY_DJMIX:-"🪩 DJ-mix"}"
|
|||||||
FORMAT_TYPE_SECONDARY_MIXTAPE="${FORMAT_TYPE_SECONDARY_MIXTAPE:-"📼 mixtape"}"
|
FORMAT_TYPE_SECONDARY_MIXTAPE="${FORMAT_TYPE_SECONDARY_MIXTAPE:-"📼 mixtape"}"
|
||||||
FORMAT_TYPE_SECONDARY_DEMO="${FORMAT_TYPE_SECONDARY_DEMO:-"🧪 demo"}"
|
FORMAT_TYPE_SECONDARY_DEMO="${FORMAT_TYPE_SECONDARY_DEMO:-"🧪 demo"}"
|
||||||
FORMAT_TYPE_SECONDARY_FIELDREC="${FORMAT_TYPE_SECONDARY_FIELDREC:-"🌿 field recording"}"
|
FORMAT_TYPE_SECONDARY_FIELDREC="${FORMAT_TYPE_SECONDARY_FIELDREC:-"🌿 field recording"}"
|
||||||
|
export FORMAT_TYPE_ALBUM FORMAT_TYPE_EP FORMAT_TYPE_SINGLE \
|
||||||
|
FORMAT_TYPE_BROADCAST FORMAT_TYPE_OTHER FORMAT_TYPE_HAS_SECONDARY \
|
||||||
|
FORMAT_TYPE_SECONDARY FORMAT_TYPE_SECONDARY_COMPILATION \
|
||||||
|
FORMAT_TYPE_SECONDARY_SOUNDTRACK FORMAT_TYPE_SECONDARY_SPOKENWORD \
|
||||||
|
FORMAT_TYPE_SECONDARY_INTERVIEW FORMAT_TYPE_SECONDARY_AUDIOBOOK \
|
||||||
|
FORMAT_TYPE_SECONDARY_AUDIODRAMA FORMAT_TYPE_SECONDARY_LIVE \
|
||||||
|
FORMAT_TYPE_SECONDARY_REMIX FORMAT_TYPE_SECONDARY_DJMIX \
|
||||||
|
FORMAT_TYPE_SECONDARY_MIXTAPE FORMAT_TYPE_SECONDARY_DEMO \
|
||||||
|
FORMAT_TYPE_SECONDARY_FIELDREC
|
||||||
|
|
||||||
# Artist Preview
|
# Artist Preview
|
||||||
# ==============
|
# ==============
|
||||||
@@ -104,6 +118,7 @@ APV_DATEPLACE="${APV_DATEPLACE:-"$APV_DATE, $APV_PLACE"}"
|
|||||||
APV_BORN="${APV_BORN:-"🍼 Born: %s"}"
|
APV_BORN="${APV_BORN:-"🍼 Born: %s"}"
|
||||||
# String to represent when/where a person died
|
# String to represent when/where a person died
|
||||||
APV_DIED="${APV_DIED:-"🕯️ Died: %s"}"
|
APV_DIED="${APV_DIED:-"🕯️ Died: %s"}"
|
||||||
|
export APV_FORMAT APV_DATE APV_PLACE APV_DATEPLACE APV_BORN APV_DIED
|
||||||
|
|
||||||
# Release view
|
# Release view
|
||||||
# ============
|
# ============
|
||||||
@@ -115,6 +130,7 @@ RV_TITLE_ARTIST="${RV_TITLE_ARTIST:-"${FAINT}as ${CTITLE}<<title>>$OFF by ${FAIN
|
|||||||
RV_TITLE="${RV_TITLE:-"${FAINT}as ${CTITLE}<<title>>$OFF"}"
|
RV_TITLE="${RV_TITLE:-"${FAINT}as ${CTITLE}<<title>>$OFF"}"
|
||||||
# Additional string to display the artist
|
# Additional string to display the artist
|
||||||
RV_ARTIST="${RV_ARTIST:-"${FAINT}by ${CARTIST}<<artist>>$OFF"}"
|
RV_ARTIST="${RV_ARTIST:-"${FAINT}by ${CARTIST}<<artist>>$OFF"}"
|
||||||
|
export RV_FORMAT RV_TITLE_ARTIST RV_TITLE RV_ARTIST
|
||||||
|
|
||||||
# Release Status
|
# Release Status
|
||||||
# ==============
|
# ==============
|
||||||
@@ -125,6 +141,9 @@ FORMAT_STATUS_PSEUDO="${FORMAT_STATUS_PSEUDO:-"🌀"}"
|
|||||||
FORMAT_STATUS_WITHDRAWN="${FORMAT_STATUS_WITHDRAWN:-"🔙"}"
|
FORMAT_STATUS_WITHDRAWN="${FORMAT_STATUS_WITHDRAWN:-"🔙"}"
|
||||||
FORMAT_STATUS_EXPUNGED="${FORMAT_STATUS_EXPUNGED:-"🧹"}"
|
FORMAT_STATUS_EXPUNGED="${FORMAT_STATUS_EXPUNGED:-"🧹"}"
|
||||||
FORMAT_STATUS_CANCELLED="${FORMAT_STATUS_CANCELLED:-"❌"}"
|
FORMAT_STATUS_CANCELLED="${FORMAT_STATUS_CANCELLED:-"❌"}"
|
||||||
|
export FORMAT_STATUS_OFFICIAL FORMAT_STATUS_PROMO FORMAT_STATUS_BOOTLEG \
|
||||||
|
FORMAT_STATUS_PSEUDO FORMAT_STATUS_WITHDRAWN FORMAT_STATUS_EXPUNGED \
|
||||||
|
FORMAT_STATUS_CANCELLED
|
||||||
|
|
||||||
# Recording view
|
# Recording view
|
||||||
# ==============
|
# ==============
|
||||||
@@ -132,3 +151,4 @@ FORMAT_STATUS_CANCELLED="${FORMAT_STATUS_CANCELLED:-"❌"}"
|
|||||||
REC_FORMAT="${REC_FORMAT:-"${CNOTE}${FAINT}<<med>>\t${CNOTE}<<nr>>$OFF\t${CTITLE}<<title>>\t${CARTIST}<<artist>>\t${CXXX}<<duration>>$OFF"}"
|
REC_FORMAT="${REC_FORMAT:-"${CNOTE}${FAINT}<<med>>\t${CNOTE}<<nr>>$OFF\t${CTITLE}<<title>>\t${CARTIST}<<artist>>\t${CXXX}<<duration>>$OFF"}"
|
||||||
# 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
|
||||||
|
@@ -1,39 +1,43 @@
|
|||||||
if command -v "fzf" >/dev/null; then
|
if [ ! "${TOOLS_LOADED:-}" ]; then
|
||||||
|
if command -v "fzf" >/dev/null; then
|
||||||
FZF="fzf --black --ansi --cycle --tiebreak=chunk,index"
|
FZF="fzf --black --ansi --cycle --tiebreak=chunk,index"
|
||||||
else
|
else
|
||||||
err "Did not find the command-line fuzzy finder fzf."
|
err "Did not find the command-line fuzzy finder fzf."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
export FZF
|
export FZF
|
||||||
|
|
||||||
if command -v "curl" >/dev/null; then
|
if command -v "curl" >/dev/null; then
|
||||||
CURL="curl --silent"
|
CURL="curl --silent"
|
||||||
else
|
else
|
||||||
err "Did not find curl."
|
err "Did not find curl."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
export CURL
|
export CURL
|
||||||
|
|
||||||
if command -v "jq" >/dev/null; then
|
if command -v "jq" >/dev/null; then
|
||||||
JQ="jq"
|
JQ="jq -r --compact-output"
|
||||||
else
|
else
|
||||||
err "Did not find jq."
|
err "Did not find jq."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
export JQ
|
export JQ
|
||||||
|
|
||||||
if command -v "mpv" >/dev/null; then
|
if command -v "mpv" >/dev/null; then
|
||||||
MPV="mpv"
|
MPV="mpv"
|
||||||
else
|
else
|
||||||
err "Did not find mpv."
|
err "Did not find mpv."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
export MPV
|
export MPV
|
||||||
|
|
||||||
if command -v "socat" >/dev/null; then
|
if command -v "socat" >/dev/null; then
|
||||||
SOCAT="socat"
|
SOCAT="socat"
|
||||||
else
|
else
|
||||||
err "Did not find socat."
|
err "Did not find socat."
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
|
export SOCAT
|
||||||
|
|
||||||
|
export TOOLS_LOADED=1
|
||||||
fi
|
fi
|
||||||
export SOCAT
|
|
||||||
|
Reference in New Issue
Block a user