faster but quite buggy; no disc state storage
This commit is contained in:
		@@ -58,5 +58,5 @@ BEGIN {
 | 
				
			|||||||
  line_year = year ? format_year : ""
 | 
					  line_year = year ? format_year : ""
 | 
				
			||||||
  sub("<<year>>", year, line_year)
 | 
					  sub("<<year>>", year, line_year)
 | 
				
			||||||
  sortk = year ? year : 0
 | 
					  sortk = year ? year : 0
 | 
				
			||||||
  print sortk, l, line_type, line_release, line_year, line_sectype, "0", id
 | 
					  print sortk, l, line_type, line_release, line_year, line_sectype, artistid ? artistid : "0", id
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,18 +9,17 @@ BEGIN {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  parentid = $1
 | 
					  id = $1
 | 
				
			||||||
  id = $2
 | 
					  status = $2
 | 
				
			||||||
  status = $3
 | 
					  year = substr($3, 1, 4) + 0
 | 
				
			||||||
  year = substr($4, 1, 4) + 0
 | 
					 | 
				
			||||||
  year = year == 0 ? "" : year
 | 
					  year = year == 0 ? "" : year
 | 
				
			||||||
  covercount = $5
 | 
					  covercount = $4
 | 
				
			||||||
  label = $6
 | 
					  label = $5
 | 
				
			||||||
  trackcnt = $7
 | 
					  trackcnt = $6
 | 
				
			||||||
  media = $8
 | 
					  media = $7
 | 
				
			||||||
  country = $9
 | 
					  country = $8
 | 
				
			||||||
  title = $10
 | 
					  title = $9
 | 
				
			||||||
  artist = $11
 | 
					  artist = $10
 | 
				
			||||||
  switch (status) {
 | 
					  switch (status) {
 | 
				
			||||||
    case "Official": line_status = release_official; break
 | 
					    case "Official": line_status = release_official; break
 | 
				
			||||||
    case "Promotion": line_status = release_promotion; break
 | 
					    case "Promotion": line_status = release_promotion; break
 | 
				
			||||||
@@ -54,5 +53,5 @@ BEGIN {
 | 
				
			|||||||
  sub("<<country>>", country, line)
 | 
					  sub("<<country>>", country, line)
 | 
				
			||||||
  sortk = year ? year : 0
 | 
					  sortk = year ? year : 0
 | 
				
			||||||
  l = local_releases[id] ? format_local : ""
 | 
					  l = local_releases[id] ? format_local : ""
 | 
				
			||||||
  print sortk, l, line, parentid, id ":" local_releases[id]
 | 
					  print sortk, l, line, rgid ? rgid : "0", id ":" local_releases[id]
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										287
									
								
								src/main.sh
									
									
									
									
									
								
							
							
						
						
									
										287
									
								
								src/main.sh
									
									
									
									
									
								
							@@ -2,6 +2,21 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
set -eu
 | 
					set -eu
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					VIEW_ARTIST="artist"
 | 
				
			||||||
 | 
					VIEW_RELEASEGROUP="rg"
 | 
				
			||||||
 | 
					VIEW_RELEASE="release"
 | 
				
			||||||
 | 
					VIEW_SEARCH_ARTIST="search-artist"
 | 
				
			||||||
 | 
					VIEW_SEARCH_ALBUM="search-album"
 | 
				
			||||||
 | 
					VIEW_LIST_ARTISTS="list-artists"
 | 
				
			||||||
 | 
					VIEW_LIST_ALBUMS="list-albums"
 | 
				
			||||||
 | 
					VIEW_SELECT_ARTIST="select-artist"
 | 
				
			||||||
 | 
					VIEW_PLAYLIST="playlist"
 | 
				
			||||||
 | 
					MODE_NORMAL="hidden"
 | 
				
			||||||
 | 
					MODE_INSERT="show"
 | 
				
			||||||
 | 
					export VIEW_ARTIST VIEW_RELEASEGROUP VIEW_RELEASE VIEW_SEARCH_ARTIST \
 | 
				
			||||||
 | 
					  VIEW_SEARCH_ALBUM VIEW_LIST_ARTISTS VIEW_LIST_ALBUMS VIEW_SELECT_ARTIST \
 | 
				
			||||||
 | 
					  VIEW_PLAYLIST MODE_NORMAL MODE_INSERT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Load helper methods
 | 
					# Load helper methods
 | 
				
			||||||
. "sh/info.sh"
 | 
					. "sh/info.sh"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -51,6 +66,110 @@ set -eu
 | 
				
			|||||||
. "sh/fzf.sh"
 | 
					. "sh/fzf.sh"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
case "${1:-}" in
 | 
					case "${1:-}" in
 | 
				
			||||||
 | 
					"--lines")
 | 
				
			||||||
 | 
					  view=${2:-}
 | 
				
			||||||
 | 
					  mbid=${3:-}
 | 
				
			||||||
 | 
					  case "$view" in
 | 
				
			||||||
 | 
					  "$VIEW_ARTIST")
 | 
				
			||||||
 | 
					    list_releasegroups "$mbid"
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					  "$VIEW_RELEASEGROUP")
 | 
				
			||||||
 | 
					    list_releases "$mbid"
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					  "$VIEW_RELEASE")
 | 
				
			||||||
 | 
					    list_recordings "$mbid"
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					  "$VIEW_LIST_ARTISTS")
 | 
				
			||||||
 | 
					    list_local_artists
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					  "$VIEW_LIST_ALBUMS")
 | 
				
			||||||
 | 
					    list_local_releasegroups
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					  esac
 | 
				
			||||||
 | 
					  exit 0
 | 
				
			||||||
 | 
					  ;;
 | 
				
			||||||
 | 
					"--draw")
 | 
				
			||||||
 | 
					  debug "call to $*"
 | 
				
			||||||
 | 
					  # Generate fzf command to draw screen.
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
 | 
					  # @argument $2: mode (default `normal`)
 | 
				
			||||||
 | 
					  # @argument $3: view (default list artists)
 | 
				
			||||||
 | 
					  # @argument $4: MusicBrainz ID (optional)
 | 
				
			||||||
 | 
					  # @argument $5: level (optional)
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
 | 
					  # The argument `level` specifies the view relative to `view`: If `level` is
 | 
				
			||||||
 | 
					  # set to +1, then the specified MusicBrainz ID is an ID of an object one level
 | 
				
			||||||
 | 
					  # deeper than `view`. Alternatively, the argument `level` may be set to `-1`.
 | 
				
			||||||
 | 
					  # Anything else is interpreted as "on the level of `view`".
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
 | 
					  # The choice of possible arguments ($5) depends on the view.
 | 
				
			||||||
 | 
					  # These views are independent of the MusicBrainz ID ($4) and of the argument
 | 
				
			||||||
 | 
					  # ($5):
 | 
				
			||||||
 | 
					  # - VIEW_SEARCH_ARTIST: Get ready to query MusicBrainz for artists
 | 
				
			||||||
 | 
					  # - VIEW_SEARCH_ALBUM: Get ready to query MusicBrainz for albums
 | 
				
			||||||
 | 
					  # - VIEW_LIST_ARTISTS: List all locally available artists
 | 
				
			||||||
 | 
					  # - VIEW_LIST_ALBUMS: List al locally available albums
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
 | 
					  # If no argument ($5) is specified, then the remaining views act as follows:
 | 
				
			||||||
 | 
					  # - VIEW_ARTIST: Display all release groups of that artist
 | 
				
			||||||
 | 
					  # - VIEW_RELEASEGROUP: Display all releases within that release group
 | 
				
			||||||
 | 
					  # - VIEW_RELEASE: Display track list of specified release
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
 | 
					  # Here, if the argument is set to `-1`, then the parent entry is displayed:
 | 
				
			||||||
 | 
					  # - VIEW_ARTIST: Divert view to VIEW_LIST_ARTISTS
 | 
				
			||||||
 | 
					  # - VIEW_RELEASEGROUP: For single-artist release groups, divert to
 | 
				
			||||||
 | 
					  #   VIEW_ARTIST of that artist, else display the artist selection.
 | 
				
			||||||
 | 
					  # - VIEW_RELEASE: Divert view to VIEW_LIST_RELEASEGROUP.
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
 | 
					  # Alternatively, if the argument is set to `+1`, then the child entry is
 | 
				
			||||||
 | 
					  # displayed:
 | 
				
			||||||
 | 
					  # - VIEW_ARTIST: Divert view to VIEW_LIST_ARTISTS
 | 
				
			||||||
 | 
					  # - VIEW_RELEASEGROUP: For single-artist release groups, divert to
 | 
				
			||||||
 | 
					  #   VIEW_ARTIST of that artist, else display the artist selection.
 | 
				
			||||||
 | 
					  # - VIEW_RELEASE: Divert view to VIEW_LIST_RELEASEGROUP.
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
 | 
					  # Hence, the view is only diverted in this last case.
 | 
				
			||||||
 | 
					  mode="${2:-"$MODE_NORMAL"}"
 | 
				
			||||||
 | 
					  view="${3:-"$VIEW_LIST_ARTISTS"}"
 | 
				
			||||||
 | 
					  mbid="${4:-}"
 | 
				
			||||||
 | 
					  level="${5:-}"
 | 
				
			||||||
 | 
					  # Change state, if we are being diverted.
 | 
				
			||||||
 | 
					  case "$level" in
 | 
				
			||||||
 | 
					  "-1")
 | 
				
			||||||
 | 
					    case "$view" in
 | 
				
			||||||
 | 
					    "$VIEW_ARTIST")
 | 
				
			||||||
 | 
					      view="$VIEW_LIST_ARTISTS"
 | 
				
			||||||
 | 
					      mbid=""
 | 
				
			||||||
 | 
					      ;;
 | 
				
			||||||
 | 
					    "$VIEW_RELEASEGROUP")
 | 
				
			||||||
 | 
					      view="$VIEW_ARTIST"
 | 
				
			||||||
 | 
					      mbid="$(mb_releasegroup "$mbid" | $JQ -r --compact-output '."artist-credit"[0].artist.id')"
 | 
				
			||||||
 | 
					      ;;
 | 
				
			||||||
 | 
					    "$VIEW_RELEASE")
 | 
				
			||||||
 | 
					      view="$VIEW_RELEASEGROUP"
 | 
				
			||||||
 | 
					      mbid="$(mb_release "$mbid" | $JQ -r --compact-output '."release-group".id')"
 | 
				
			||||||
 | 
					      ;;
 | 
				
			||||||
 | 
					    esac
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					  "+1")
 | 
				
			||||||
 | 
					    case "$view" in
 | 
				
			||||||
 | 
					    "$VIEW_SEARCH_ARTIST" | "$VIEW_LIST_ARTISTS") view="$VIEW_ARTIST" ;;
 | 
				
			||||||
 | 
					    "$VIEW_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ALBUMS") view="$VIEW_RELEASEGROUP" ;;
 | 
				
			||||||
 | 
					    "$VIEW_RELEASEGROUP") view="$VIEW_RELEASE" ;;
 | 
				
			||||||
 | 
					    esac
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					  *) ;;
 | 
				
			||||||
 | 
					  esac
 | 
				
			||||||
 | 
					  # Store current state
 | 
				
			||||||
 | 
					  printf "change-border-label(%s)+change-list-label(%s)" "$view" "$mbid"
 | 
				
			||||||
 | 
					  debug "calling: $(printf "change-border-label(%s)+change-list-label(%s)" "$view" "$mbid")"
 | 
				
			||||||
 | 
					  [ "$mode" = "$MODE_NORMAL" ] && printf "+hide-input" || printf "+show-input"
 | 
				
			||||||
 | 
					  # Set header
 | 
				
			||||||
 | 
					  fzf_command_set_header "$view" "$mbid"
 | 
				
			||||||
 | 
					  # Load lines
 | 
				
			||||||
 | 
					  printf "+reload($0 --lines %s %s)" "$view" "$mbid"
 | 
				
			||||||
 | 
					  exit 0
 | 
				
			||||||
 | 
					  ;;
 | 
				
			||||||
"--fzf-reload")
 | 
					"--fzf-reload")
 | 
				
			||||||
  fzf_handle_reload
 | 
					  fzf_handle_reload
 | 
				
			||||||
  exit 0
 | 
					  exit 0
 | 
				
			||||||
@@ -148,38 +267,47 @@ touch "$STATEFILE" "$ARGSFILE" "$STATEFILE_LAST" "$ARGSFILE_LAST"
 | 
				
			|||||||
export STATEFILE ARGSFILE STATEFILE_LAST ARGSFILE_LAST
 | 
					export STATEFILE ARGSFILE STATEFILE_LAST ARGSFILE_LAST
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Views and modes
 | 
					# Views and modes
 | 
				
			||||||
VIEW_ARTIST="artist"
 | 
					 | 
				
			||||||
VIEW_RELEASEGROUP="rg"
 | 
					 | 
				
			||||||
VIEW_RELEASE="release"
 | 
					 | 
				
			||||||
VIEW_SEARCH_ARTIST="search-artist"
 | 
					 | 
				
			||||||
VIEW_SEARCH_ALBUM="search-album"
 | 
					 | 
				
			||||||
VIEW_LIST_ARTISTS="list-artists"
 | 
					 | 
				
			||||||
VIEW_LIST_ALBUMS="list-albums"
 | 
					 | 
				
			||||||
VIEW_SELECT_ARTIST="select-artist"
 | 
					 | 
				
			||||||
VIEW_PLAYLIST="playlist"
 | 
					 | 
				
			||||||
MODE_NORMAL="normal"
 | 
					 | 
				
			||||||
MODE_INSERT="insert"
 | 
					 | 
				
			||||||
export VIEW_ARTIST VIEW_RELEASEGROUP VIEW_RELEASE VIEW_SEARCH_ARTIST \
 | 
					 | 
				
			||||||
  VIEW_SEARCH_ALBUM VIEW_LIST_ARTISTS VIEW_LIST_ALBUMS VIEW_SELECT_ARTIST \
 | 
					 | 
				
			||||||
  VIEW_PLAYLIST MODE_NORMAL MODE_INSERT
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
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
 | 
				
			||||||
  state_init "$VIEW_ARTIST" "$MODE_NORMAL" "$2"
 | 
					  VIEW="$VIEW_ARTIST"
 | 
				
			||||||
 | 
					  MODE="$MODE_NORMAL"
 | 
				
			||||||
 | 
					  MBID="$2"
 | 
				
			||||||
  ;;
 | 
					  ;;
 | 
				
			||||||
"--releasegroup")
 | 
					"--releasegroup")
 | 
				
			||||||
  [ ! "${2:-}" ] && err "MusicBrainz Release-Group ID not specified (see --help)" && exit 1
 | 
					  [ ! "${2:-}" ] && err "MusicBrainz Release-Group ID not specified (see --help)" && exit 1
 | 
				
			||||||
  state_init "$VIEW_RELEASEGROUP" "$MODE_NORMAL" "$2"
 | 
					  VIEW="$VIEW_RELEASEGROUP"
 | 
				
			||||||
 | 
					  MODE="$MODE_NORMAL"
 | 
				
			||||||
 | 
					  MBID="$2"
 | 
				
			||||||
  ;;
 | 
					  ;;
 | 
				
			||||||
"--release")
 | 
					"--release")
 | 
				
			||||||
  [ ! "${2:-}" ] && err "MusicBrainz Release ID not specified (see --help)" && exit 1
 | 
					  [ ! "${2:-}" ] && err "MusicBrainz Release ID not specified (see --help)" && exit 1
 | 
				
			||||||
  state_init "$VIEW_RELEASE" "$MODE_NORMAL" "$2"
 | 
					  VIEW="$VIEW_RELEASE"
 | 
				
			||||||
 | 
					  MODE="$MODE_NORMAL"
 | 
				
			||||||
 | 
					  MBID="$2"
 | 
				
			||||||
 | 
					  ;;
 | 
				
			||||||
 | 
					"--search-artist")
 | 
				
			||||||
 | 
					  state_init "$VIEW_SEARCH_ARTIST" "$MODE_INSERT" "${2:-}"
 | 
				
			||||||
 | 
					  VIEW="$VIEW_SEARCH_ARTIST"
 | 
				
			||||||
 | 
					  MODE="$MODE_INSERT"
 | 
				
			||||||
 | 
					  MBID=""
 | 
				
			||||||
 | 
					  ;;
 | 
				
			||||||
 | 
					"--search-album")
 | 
				
			||||||
 | 
					  VIEW="$VIEW_SEARCH_ALBUM"
 | 
				
			||||||
 | 
					  MODE="$MODE_INSERT"
 | 
				
			||||||
 | 
					  MBID=""
 | 
				
			||||||
 | 
					  ;;
 | 
				
			||||||
 | 
					"--artists" | "")
 | 
				
			||||||
 | 
					  VIEW="$VIEW_LIST_ARTISTS"
 | 
				
			||||||
 | 
					  MODE="$MODE_NORMAL"
 | 
				
			||||||
 | 
					  MBID=""
 | 
				
			||||||
 | 
					  ;;
 | 
				
			||||||
 | 
					"--albums")
 | 
				
			||||||
 | 
					  VIEW="$VIEW_LIST_ALBUMS"
 | 
				
			||||||
 | 
					  MODE="$MODE_NORMAL"
 | 
				
			||||||
 | 
					  MBID=""
 | 
				
			||||||
  ;;
 | 
					  ;;
 | 
				
			||||||
"--search-artist") state_init "$VIEW_SEARCH_ARTIST" "$MODE_INSERT" "${2:-}" ;;
 | 
					 | 
				
			||||||
"--search-album") state_init "$VIEW_SEARCH_ALBUM" "$MODE_INSERT" "${2:-}" ;;
 | 
					 | 
				
			||||||
"--artists" | "") state_init "$VIEW_LIST_ARTISTS" "$MODE_NORMAL" "" ;;
 | 
					 | 
				
			||||||
"--albums") state_init "$VIEW_LIST_ALBUMS" "$MODE_NORMAL" "" ;;
 | 
					 | 
				
			||||||
*)
 | 
					*)
 | 
				
			||||||
  err "Unknown option $1 (see --help)"
 | 
					  err "Unknown option $1 (see --help)"
 | 
				
			||||||
  exit 1
 | 
					  exit 1
 | 
				
			||||||
@@ -189,12 +317,27 @@ esac
 | 
				
			|||||||
# Start mpv
 | 
					# Start mpv
 | 
				
			||||||
mpv_start
 | 
					mpv_start
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# $KEYS_PLAY main loop
 | 
					# main loop
 | 
				
			||||||
 | 
					# states are stored in (in)visible labels
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# mode: [$MODE_NORMAL, $MODE_INSERT]
 | 
				
			||||||
 | 
					# The mode is reflected on the input visibility. The variable $FZF_INPUT_STATE
 | 
				
			||||||
 | 
					# is set to "hidden" if and only if the mode is `normal`. To swtich to `normal`
 | 
				
			||||||
 | 
					# mode, we call `hide-input`. To switch to insert mode, we call `show-input`.
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# view: [$VIEW_*]
 | 
				
			||||||
 | 
					# The view is stored in $FZF_BORDER_LABEL. To set the view, call
 | 
				
			||||||
 | 
					# `change-border-label($VIEW)`.
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# argument: string
 | 
				
			||||||
 | 
					# The argument is stored in $FZF_LIST_LABEL. To set the argument, call
 | 
				
			||||||
 | 
					# `change-list-label($arg)`.
 | 
				
			||||||
 | 
					IN_NORMAL_MODE="[ \"\$FZF_INPUT_STATE\" = \"hidden\" ]"
 | 
				
			||||||
 | 
					PUT_FZF_KEY_LOGIC="case \"\$FZF_KEY\" in \"space\") echo \"put( )\";; \"backspace\"|\"bspace\"|\"bs\") echo \"backward-delete-char\";; \"delete\"|\"del\") echo \"delete-char\";; *) echo \"put(\$FZF_KEY)\";; esac"
 | 
				
			||||||
while true; do
 | 
					while true; do
 | 
				
			||||||
  view=$(state_get_view)
 | 
					 | 
				
			||||||
  mode=$(state_get_mode)
 | 
					  mode=$(state_get_mode)
 | 
				
			||||||
  args=$(state_get_args)
 | 
					  args=$(state_get_args)
 | 
				
			||||||
  case "$view" in
 | 
					  case "$VIEW" in
 | 
				
			||||||
  "$VIEW_SELECT_ARTIST")
 | 
					  "$VIEW_SELECT_ARTIST")
 | 
				
			||||||
    sel=$(
 | 
					    sel=$(
 | 
				
			||||||
      echo "$args" |
 | 
					      echo "$args" |
 | 
				
			||||||
@@ -230,19 +373,89 @@ $KEYS_FILTER_LOCAL:transform:$0 --fzf-key {2} {3} {4}" \
 | 
				
			|||||||
        --delimiter="\t" \
 | 
					        --delimiter="\t" \
 | 
				
			||||||
        --with-nth="{1}" >/dev/null
 | 
					        --with-nth="{1}" >/dev/null
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
  *) # Main instance
 | 
					  *)
 | 
				
			||||||
 | 
					    # Main instance
 | 
				
			||||||
 | 
					    #
 | 
				
			||||||
 | 
					    # KEY-BINDINGS:
 | 
				
			||||||
 | 
					    # Key variables contain comma-delimited sequences of keys. Every key
 | 
				
			||||||
 | 
					    # variable starts with `KEYS_`. Key variables with the prefix `KEYS_I_` are
 | 
				
			||||||
 | 
					    # exclusive to the `insert` mode. Key variables with the prefix `KEYS_N_`
 | 
				
			||||||
 | 
					    # are exclusive to the `normal` mode. All other keys are bound to both
 | 
				
			||||||
 | 
					    # modes. It is important that the keys used in `KEYS_N_` variables are
 | 
				
			||||||
 | 
					    # naturally printable or modifications of the input string. See
 | 
				
			||||||
 | 
					    # `$PUT_FZF_KEY_LOGIC` for details.
 | 
				
			||||||
 | 
					    #
 | 
				
			||||||
 | 
					    # Here is a list of all keys grouped by type.
 | 
				
			||||||
 | 
					    #
 | 
				
			||||||
 | 
					    #   Mode selection:
 | 
				
			||||||
 | 
					    #   - $KEYS_I_NORMAL: Switch to normal mode (insert mode)
 | 
				
			||||||
 | 
					    #   - $KEYS_N_INSERT: Switch to insert mode (normal mode)
 | 
				
			||||||
 | 
					    #
 | 
				
			||||||
 | 
					    #   Vertical navigation:
 | 
				
			||||||
 | 
					    #   - $KEYS_DOWN: Move cursor to the next line
 | 
				
			||||||
 | 
					    #   - $KEYS_UP: Move cursor to the previous line
 | 
				
			||||||
 | 
					    #   - $KEYS_HALFPAGE_UP: Move cursor half a page up
 | 
				
			||||||
 | 
					    #   - $KEYS_HALFPAGE_DOWN: Move cursor half a page up
 | 
				
			||||||
 | 
					    #   - $KEYS_N_DOWN: Move cursor to the next line (normal mode)
 | 
				
			||||||
 | 
					    #   - $KEYS_N_UP: Move cursor to the previous line (normal mode)
 | 
				
			||||||
 | 
					    #   - $KEYS_N_BOT: Move cursor to the last line (normal mode)
 | 
				
			||||||
 | 
					    #   - $KEYS_N_TOP: Move cursor to the first line (normal mode)
 | 
				
			||||||
 | 
					    #
 | 
				
			||||||
 | 
					    #   Horizontal navigation:
 | 
				
			||||||
 | 
					    #   - $KEYS_IN: Enter into selected item, down the hierarchy
 | 
				
			||||||
 | 
					    #   - $KEYS_OUT: Leave current item, up the hierarchy
 | 
				
			||||||
 | 
					    #
 | 
				
			||||||
 | 
					    #   Filtering:
 | 
				
			||||||
 | 
					    #
 | 
				
			||||||
 | 
					    #   Playback:
 | 
				
			||||||
 | 
					    #
 | 
				
			||||||
 | 
					    #   Extras:
 | 
				
			||||||
 | 
					    #   - $KEYS_BROWSE: Open MusicBrainz webpage of the selected item
 | 
				
			||||||
 | 
					    #   - $KEYS_OPEN: Open file manager in the directory of the selected item
 | 
				
			||||||
 | 
					    #--bind="start:change-border-label($VIEW)+change-list-label($MBID)+$MODE-input+transform:$0 --display" \
 | 
				
			||||||
    sel=$(
 | 
					    sel=$(
 | 
				
			||||||
      $FZF \
 | 
					      printf "" | $FZF \
 | 
				
			||||||
        --reverse \
 | 
					        --reverse \
 | 
				
			||||||
        --bind="start:reload:$0 --fzf-reload" \
 | 
					 | 
				
			||||||
        --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}" \
 | 
					 | 
				
			||||||
        --expect="ctrl-c" \
 | 
					 | 
				
			||||||
        --info="inline-right" \
 | 
					        --info="inline-right" \
 | 
				
			||||||
        --info-command="$0 --fzf-info" \
 | 
					        --header-first \
 | 
				
			||||||
        --preview-window="right,25%,border-left,wrap,<30(hidden)" \
 | 
					        --header-border="bottom" \
 | 
				
			||||||
        --preview="$0 --internal-preview-artist {3}" \
 | 
					        --bind="start:transform:$0 --draw $MODE $VIEW $MBID" \
 | 
				
			||||||
 | 
					        --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_DOWN:down" \
 | 
				
			||||||
 | 
					        --bind="$KEYS_UP:up" \
 | 
				
			||||||
 | 
					        --bind="$KEYS_HALFPAGE_DOWN:half-page-down" \
 | 
				
			||||||
 | 
					        --bind="$KEYS_HALFPAGE_UP:half-page-up" \
 | 
				
			||||||
 | 
					        --bind="$KEYS_N_DOWN:transform:$IN_NORMAL_MODE && echo \"down\" || $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_TOP:transform:$IN_NORMAL_MODE && echo \"first\" || $PUT_FZF_KEY_LOGIC" \
 | 
				
			||||||
 | 
					        --bind="$KEYS_IN:transform:[ {3} ] && $0 --draw \$FZF_INPUT_STATE \$FZF_BORDER_LABEL {3} \"+1\"" \
 | 
				
			||||||
 | 
					        --bind="$KEYS_OUT:transform:echo {2} >> /tmp/foo; echo {} >> /tmp/foo; [ {2} ] && $0 --draw \$FZF_INPUT_STATE \$FZF_BORDER_LABEL {2} \"-1\"" \
 | 
				
			||||||
 | 
					        --bind="$KEYS_BROWSE:execute-silent:
 | 
				
			||||||
 | 
					[ {3} ] || exit 0
 | 
				
			||||||
 | 
					case \"\$FZF_BORDER_LABEL\" in
 | 
				
			||||||
 | 
					  \"$VIEW_LIST_ARTISTS\" | \"$VIEW_SEARCH_ARTIST\") t=\"artist\" ;;
 | 
				
			||||||
 | 
					  \"$VIEW_ARTIST\" | \"$VIEW_SEARCH_ALBUM\" | \"$VIEW_LIST_ALBUMS\") t=\"release-group\" ;;
 | 
				
			||||||
 | 
					  \"$VIEW_RELEASEGROUP\") t=\"release\" ;;
 | 
				
			||||||
 | 
					  \"$VIEW_RELEASE\") t=\"track\" ;;
 | 
				
			||||||
 | 
					esac
 | 
				
			||||||
 | 
					open \"https://musicbrainz.org/\$t/{r3}\"" \
 | 
				
			||||||
 | 
					        --bind="$KEYS_OPEN:execute-silent:
 | 
				
			||||||
 | 
					[ {4} ] || exit 0
 | 
				
			||||||
 | 
					open \"\$(dirname {4})\"" \
 | 
				
			||||||
 | 
					        --bind="$KEYS_SELECT_ARTIST:" \
 | 
				
			||||||
 | 
					        --bind="$KEYS_FILTER_LOCAL:" \
 | 
				
			||||||
 | 
					        --bind="$KEYS_FILTER_1:" \
 | 
				
			||||||
 | 
					        --bind="$KEYS_FILTER_2:" \
 | 
				
			||||||
 | 
					        --bind="$KEYS_FILTER_3:" \
 | 
				
			||||||
 | 
					        --bind="$KEYS_FILTER_4:" \
 | 
				
			||||||
 | 
					        --bind="$KEYS_SWITCH_ARTIST_ALBUM:" \
 | 
				
			||||||
 | 
					        --bind="$KEYS_SWITCH_LOCAL_REMOTE:" \
 | 
				
			||||||
 | 
					        --bind="$KEYS_PLAY:" \
 | 
				
			||||||
 | 
					        --bind="$KEYS_QUEUE:" \
 | 
				
			||||||
 | 
					        --bind="$KEYS_SHOW_PLAYLIST:" \
 | 
				
			||||||
 | 
					        --expect="ctrl-c" \
 | 
				
			||||||
        --delimiter="\t" \
 | 
					        --delimiter="\t" \
 | 
				
			||||||
        --with-nth="{1}" || true
 | 
					        --with-nth="{1}" || true
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
@@ -250,3 +463,9 @@ $KEYS_FILTER_LOCAL:transform:$0 --fzf-key {2} {3} {4}" \
 | 
				
			|||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
  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}" \
 | 
				
			||||||
 | 
					#        --preview-window="right,25%,border-left,wrap,<30(hidden)" \
 | 
				
			||||||
 | 
					#        --preview="$0 --internal-preview-artist {3}" \
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,3 +1,54 @@
 | 
				
			|||||||
 | 
					# Print the command that sets the header.
 | 
				
			||||||
 | 
					# @argument $1: view
 | 
				
			||||||
 | 
					# @argument $2: mbid
 | 
				
			||||||
 | 
					fzf_command_set_header() {
 | 
				
			||||||
 | 
					  view=$1
 | 
				
			||||||
 | 
					  mbid=$2
 | 
				
			||||||
 | 
					  case "$view" in
 | 
				
			||||||
 | 
					  "$VIEW_SEARCH_ARTIST") header="Search artist on MusicBrainz" ;;
 | 
				
			||||||
 | 
					  "$VIEW_SEARCH_ALBUM") header="Search album on MusicBrainz" ;;
 | 
				
			||||||
 | 
					  "$VIEW_LIST_ARTISTS") header="Search locally available artist" ;;
 | 
				
			||||||
 | 
					  "$VIEW_LIST_ALBUMS") header="Search locally available album" ;;
 | 
				
			||||||
 | 
					  "$VIEW_ARTIST")
 | 
				
			||||||
 | 
					    name="$(mb_artist "$mbid" | $JQ -r '.name')"
 | 
				
			||||||
 | 
					    header=$(printf "$ARTIST_PROMPT" "$name")
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					  "$VIEW_RELEASEGROUP")
 | 
				
			||||||
 | 
					    title="$(mb_releasegroup "$mbid" |
 | 
				
			||||||
 | 
					      $JQ -r '.title')"
 | 
				
			||||||
 | 
					    artist="$(mb_releasegroup "$mbid" |
 | 
				
			||||||
 | 
					      $JQ -r '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
 | 
				
			||||||
 | 
					    header=$(printf "$FULL_PROMPT" "$artist" "$title")
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					  "$VIEW_RELEASE")
 | 
				
			||||||
 | 
					    title="$(mb_release "$mbid" |
 | 
				
			||||||
 | 
					      $JQ -r '.title')"
 | 
				
			||||||
 | 
					    artist="$(mb_release "$mbid" |
 | 
				
			||||||
 | 
					      $JQ -r '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
 | 
				
			||||||
 | 
					    header=$(printf "$FULL_PROMPT" "$artist" "$title")
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					  esac
 | 
				
			||||||
 | 
					  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
 | 
					# Set prompt of input field
 | 
				
			||||||
# @argument $1: view
 | 
					# @argument $1: view
 | 
				
			||||||
# @argument $2: mode
 | 
					# @argument $2: mode
 | 
				
			||||||
@@ -25,7 +76,7 @@ __set_prompt() {
 | 
				
			|||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
  esac
 | 
					  esac
 | 
				
			||||||
  [ "$mode" = "$MODE_INSERT" ] && PT="$PROMPT_INSERT" || PT="$PROMPT_NORMAL"
 | 
					  [ "$mode" = "$MODE_INSERT" ] && PT="$PROMPT_INSERT" || PT="$PROMPT_NORMAL"
 | 
				
			||||||
  printf "+change-prompt(%s %s)" "$PT" "${PROMPT:-"$SEARCH_PROMPT"}"
 | 
					  printf "+change-header(%s %s)" "$PT" "${PROMPT:-"$SEARCH_PROMPT"}"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Reload data for FZF
 | 
					# Reload data for FZF
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,37 +1,60 @@
 | 
				
			|||||||
# Key bindings
 | 
					# See comment in `src/main.sh` on key bindings.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Some key-bindings are used exclusively in the normal mode, others exclusively
 | 
					# Mode selection:
 | 
				
			||||||
# in the insert mode, others in both modes.
 | 
					# - $KEYS_I_NORMAL: Switch to normal mode (insert mode)
 | 
				
			||||||
# Some key-bindings are universal in the sense that they do not depend on the
 | 
					# - $KEYS_N_INSERT: Switch to insert mode (normal mode)
 | 
				
			||||||
# state of the player (view, mode, arguments), others are not universal.
 | 
					 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# For fast processing, we propose the following.
 | 
					# Vertical navigation:
 | 
				
			||||||
# The mode (normal or insert) is stored in the FZF_INPUT_STATE variable. All
 | 
					# - $KEYS_DOWN: Move cursor to the next line
 | 
				
			||||||
# key-bindings that are independent of the `view` and of the `arguments` are
 | 
					# - $KEYS_UP: Move cursor to the previous line
 | 
				
			||||||
# directly processed using a `--bind` with inline transform element. Keys that
 | 
					# - $KEYS_HALFPAGE_UP: Move cursor half a page up
 | 
				
			||||||
# depend on `view` or `arguments` are processed through `$0 --fzf-key`. In a
 | 
					# - $KEYS_HALFPAGE_DOWN: Move cursor half a page up
 | 
				
			||||||
# future step, we may also store the `view` part of the state as hidden fields
 | 
					# - $KEYS_N_DOWN: Move cursor to the next line (normal mode)
 | 
				
			||||||
# in the list (the list generator makes that). Then, it may be possible to
 | 
					# - $KEYS_N_UP: Move cursor to the previous line (normal mode)
 | 
				
			||||||
# completely get rid of the state files. Even beter, we may store the view part
 | 
					# - $KEYS_N_BOT: Move cursor to the last line (normal mode)
 | 
				
			||||||
# in FZF_HEADER_LABEL.
 | 
					# - $KEYS_N_TOP: Move cursor to the first line (normal mode)
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Switching between the modes (normal <-> insert) is done using two fzf `--bind`
 | 
					# Horizontal navigation:
 | 
				
			||||||
# arguments. We make sure that only one is active.
 | 
					# - $KEYS_IN: Enter into selected item, down the hierarchy
 | 
				
			||||||
 | 
					# - $KEYS_OUT: Leave current item, up the hierarchy
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# Filtering:
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# Playback:
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# Extras:
 | 
				
			||||||
 | 
					# - $KEYS_BROWSE: Open MusicBrainz webpage of the selected item
 | 
				
			||||||
 | 
					# - $KEYS_OPEN: Open file manager in the directory of the selected item
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# 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,/"}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Vertical navigation:
 | 
				
			||||||
 | 
					KEYS_DOWN="${KEYS_DOWN:-"ctrl-j,down"}"
 | 
				
			||||||
 | 
					KEYS_UP="${KEYS_UP:-"ctrl-k,up"}"
 | 
				
			||||||
 | 
					KEYS_HALFPAGE_DOWN="${KEYS_HALFPAGE_DOWN:-"ctrl-d"}"
 | 
				
			||||||
 | 
					KEYS_HALFPAGE_UP="${KEYS_HALFPAGE_UP:-"ctrl-u"}"
 | 
				
			||||||
 | 
					KEYS_N_DOWN="${KEYS_N_DOWN:-"j"}"
 | 
				
			||||||
 | 
					KEYS_N_UP="${KEYS_N_UP:-"k"}"
 | 
				
			||||||
 | 
					KEYS_N_BOT="${KEYS_N_BOT:-"G"}"
 | 
				
			||||||
 | 
					KEYS_N_TOP="${KEYS_N_TOP:-"1"}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Horizontal navigation:
 | 
				
			||||||
 | 
					KEYS_IN="${KEYS_IN:-"ctrl-l"}"
 | 
				
			||||||
 | 
					KEYS_OUT="${KEYS_OUT:-"ctrl-h"}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Not yet characterized
 | 
				
			||||||
 | 
					KEYS_N_QUIT="${KEYS_N_QUIT:-"q"}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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='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_SINGLE="$KEYS_INPUT_SINGLE,'"
 | 
				
			||||||
KEYS_INPUT_SPECIAL="space,backspace,delete,left,right"
 | 
					KEYS_INPUT_SPECIAL="space,backspace,delete,left,right"
 | 
				
			||||||
export KEYS_INPUT_SINGLE KEYS_INPUT_SPECIAL
 | 
					export KEYS_INPUT_SINGLE KEYS_INPUT_SPECIAL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Normal and insert mode
 | 
					# Normal and insert mode
 | 
				
			||||||
KEYS_HALFPAGE_DOWN="${KEYS_HALFPAGE_DOWN:-"ctrl-d"}"
 | 
					 | 
				
			||||||
KEYS_HALFPAGE_UP="${KEYS_HALFPAGE_UP:-"ctrl-u"}"
 | 
					 | 
				
			||||||
KEYS_BROWSE="${KEYS_BROWSE:-"alt-b"}"
 | 
					KEYS_BROWSE="${KEYS_BROWSE:-"alt-b"}"
 | 
				
			||||||
KEYS_OPEN="${KEYS_OPEN:-"alt-o"}"
 | 
					KEYS_OPEN="${KEYS_OPEN:-"alt-o"}"
 | 
				
			||||||
KEYS_OUT="${KEYS_OUT:-"ctrl-h"}"
 | 
					 | 
				
			||||||
KEYS_IN="${KEYS_IN:-"ctrl-l"}"
 | 
					 | 
				
			||||||
KEYS_SELECT_ARTIST="${KEYS_SELECT_ARTIST:-"ctrl-a"}"
 | 
					KEYS_SELECT_ARTIST="${KEYS_SELECT_ARTIST:-"ctrl-a"}"
 | 
				
			||||||
KEYS_FILTER_LOCAL="${KEYS_FILTER_LOCAL:-"alt-l"}"
 | 
					KEYS_FILTER_LOCAL="${KEYS_FILTER_LOCAL:-"alt-l"}"
 | 
				
			||||||
KEYS_FILTER_1="${KEYS_FILTER_1:-"alt-1"}"
 | 
					KEYS_FILTER_1="${KEYS_FILTER_1:-"alt-1"}"
 | 
				
			||||||
@@ -47,13 +70,8 @@ KEYS_NI="$KEYS_HALFPAGE_DOWN,$KEYS_HALFPAGE_UP,$KEYS_BROWSE,$KEYS_OPEN,$KEYS_OUT
 | 
				
			|||||||
export KEYS_NI
 | 
					export KEYS_NI
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Keys in normal mode only
 | 
					# Keys in normal mode only
 | 
				
			||||||
KEYS_N_DOWN="${KEYS_N_DOWN:-"j"}"
 | 
					 | 
				
			||||||
KEYS_N_UP="${KEYS_N_UP:-"k"}"
 | 
					 | 
				
			||||||
KEYS_N_OUT="${KEYS_N_OUT:-"h"}"
 | 
					KEYS_N_OUT="${KEYS_N_OUT:-"h"}"
 | 
				
			||||||
KEYS_N_IN="${KEYS_N_IN:-"l"}"
 | 
					KEYS_N_IN="${KEYS_N_IN:-"l"}"
 | 
				
			||||||
KEYS_N_TOP="${KEYS_N_TOP:-"1"}"
 | 
					 | 
				
			||||||
KEYS_N_BOT="${KEYS_N_BOT:-"G"}"
 | 
					 | 
				
			||||||
KEYS_N_QUIT="${KEYS_N_QUIT:-"q"}"
 | 
					 | 
				
			||||||
KEYS_N_INSERT="${KEYS_N_INSERT:-"a,i,/"}"
 | 
					KEYS_N_INSERT="${KEYS_N_INSERT:-"a,i,/"}"
 | 
				
			||||||
KEYS_N_TOGGLE_PLAY_PAUSE="${KEYS_N_TOGGLE_PLAY_PAUSE:-"space"}"
 | 
					KEYS_N_TOGGLE_PLAY_PAUSE="${KEYS_N_TOGGLE_PLAY_PAUSE:-"space"}"
 | 
				
			||||||
KEYS_N_PLAY_NEXT="${KEYS_N_PLAY_NEXT:-"right"}"
 | 
					KEYS_N_PLAY_NEXT="${KEYS_N_PLAY_NEXT:-"right"}"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,6 +14,7 @@ list_releasegroups() {
 | 
				
			|||||||
    awk \
 | 
					    awk \
 | 
				
			||||||
      -F "\t" \
 | 
					      -F "\t" \
 | 
				
			||||||
      -v artist="$name" \
 | 
					      -v artist="$name" \
 | 
				
			||||||
 | 
					      -v artistid="$1" \
 | 
				
			||||||
      -v file_local_releasegroups="${LOCALDATA_RELEASEGROUPS:-}" \
 | 
					      -v file_local_releasegroups="${LOCALDATA_RELEASEGROUPS:-}" \
 | 
				
			||||||
      -v format_release="$RGV_RELEASE" \
 | 
					      -v format_release="$RGV_RELEASE" \
 | 
				
			||||||
      -v format_release_w_artist="$RGV_RELEASE_W_ARTIST" \
 | 
					      -v format_release_w_artist="$RGV_RELEASE_W_ARTIST" \
 | 
				
			||||||
@@ -41,7 +42,7 @@ list_releasegroups() {
 | 
				
			|||||||
      "$AWK_RELEASEGROUPS" |
 | 
					      "$AWK_RELEASEGROUPS" |
 | 
				
			||||||
    sort -n -r |
 | 
					    sort -n -r |
 | 
				
			||||||
    cut -d "$(printf '\t')" -f 2- |
 | 
					    cut -d "$(printf '\t')" -f 2- |
 | 
				
			||||||
    column -t -s "$(printf '\t')" -E 0 |
 | 
					    column -t -s "$(printf '\t')" |
 | 
				
			||||||
    sed 's| \+\([0-9a-f-]\+\) \+\([0-9a-f-]\+\)$|\t\1\t\2|'
 | 
					    sed 's| \+\([0-9a-f-]\+\) \+\([0-9a-f-]\+\)$|\t\1\t\2|'
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -53,8 +54,7 @@ list_releases() {
 | 
				
			|||||||
  artist="$(mb_releasegroup "$1" |
 | 
					  artist="$(mb_releasegroup "$1" |
 | 
				
			||||||
    $JQ -r '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
 | 
					    $JQ -r '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
 | 
				
			||||||
  mb_releasegroup_releases "$1" |
 | 
					  mb_releasegroup_releases "$1" |
 | 
				
			||||||
    $JQ -r --arg rid "$1" '."releases"[] | [
 | 
					    $JQ -r '."releases"[] | [
 | 
				
			||||||
  $rid,
 | 
					 | 
				
			||||||
  .id,
 | 
					  .id,
 | 
				
			||||||
  .status,
 | 
					  .status,
 | 
				
			||||||
  .date,
 | 
					  .date,
 | 
				
			||||||
@@ -82,11 +82,12 @@ list_releases() {
 | 
				
			|||||||
      -v release_format_artist="$RV_ARTIST" \
 | 
					      -v release_format_artist="$RV_ARTIST" \
 | 
				
			||||||
      -v rg_artist="$artist" \
 | 
					      -v rg_artist="$artist" \
 | 
				
			||||||
      -v rg_title="$title" \
 | 
					      -v rg_title="$title" \
 | 
				
			||||||
 | 
					      -v rgid="$1" \
 | 
				
			||||||
      -v format_local="$FORMAT_LOCAL" \
 | 
					      -v format_local="$FORMAT_LOCAL" \
 | 
				
			||||||
      "$AWK_RELEASES" |
 | 
					      "$AWK_RELEASES" |
 | 
				
			||||||
    sort -n -r |
 | 
					    sort -n -r |
 | 
				
			||||||
    cut -d "$(printf '\t')" -f 2- |
 | 
					    cut -d "$(printf '\t')" -f 2- |
 | 
				
			||||||
    column -t -s "$(printf '\t')" -E 0 |
 | 
					    column -t -s "$(printf '\t')" |
 | 
				
			||||||
    sed 's| \+\([0-9a-f-]\+\) \+\([0-9a-f-]\+\):\(.*$\)$|\t\1\t\2\t\3|'
 | 
					    sed 's| \+\([0-9a-f-]\+\) \+\([0-9a-f-]\+\):\(.*$\)$|\t\1\t\2\t\3|'
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -123,7 +124,7 @@ list_recordings() {
 | 
				
			|||||||
      "$AWK_RECORDINGS" |
 | 
					      "$AWK_RECORDINGS" |
 | 
				
			||||||
    sort -k1,1n -k2,2g |
 | 
					    sort -k1,1n -k2,2g |
 | 
				
			||||||
    cut -d "$(printf '\t')" -f 2- |
 | 
					    cut -d "$(printf '\t')" -f 2- |
 | 
				
			||||||
    column -t -s "$(printf '\t')" -R 3,4,7 -E 0 |
 | 
					    column -t -s "$(printf '\t')" -R 3,4,7 |
 | 
				
			||||||
    sed 's| \+\([0-9a-f-]\+\) \+\([0-9a-f-]\+\):\(.*$\)$|\t\1\t\2\t\3|'
 | 
					    sed 's| \+\([0-9a-f-]\+\) \+\([0-9a-f-]\+\):\(.*$\)$|\t\1\t\2\t\3|'
 | 
				
			||||||
  if [ "${rectmp:-}" ] && [ -f "$rectmp" ]; then
 | 
					  if [ "${rectmp:-}" ] && [ -f "$rectmp" ]; then
 | 
				
			||||||
    rm -f "$rectmp"
 | 
					    rm -f "$rectmp"
 | 
				
			||||||
@@ -198,7 +199,7 @@ list_artists_from_json() {
 | 
				
			|||||||
      -v format_disambiguation="$AV_DISAMBIGUATION" \
 | 
					      -v format_disambiguation="$AV_DISAMBIGUATION" \
 | 
				
			||||||
      -v format_local="$FORMAT_LOCAL" \
 | 
					      -v format_local="$FORMAT_LOCAL" \
 | 
				
			||||||
      "$AWK_ARTISTS" |
 | 
					      "$AWK_ARTISTS" |
 | 
				
			||||||
    column -t -s "$(printf '\t')" -E 0 |
 | 
					    column -t -s "$(printf '\t')" |
 | 
				
			||||||
    sed 's| \+\([0-9a-f-]\+\) \+\([0-9a-f-]\+\)$|\t\1\t\2|'
 | 
					    sed 's| \+\([0-9a-f-]\+\) \+\([0-9a-f-]\+\)$|\t\1\t\2|'
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -228,7 +229,7 @@ list_playlist() {
 | 
				
			|||||||
      -v current_id="$current_id" \
 | 
					      -v current_id="$current_id" \
 | 
				
			||||||
      "$AWK_RECORDINGS" |
 | 
					      "$AWK_RECORDINGS" |
 | 
				
			||||||
    cut -d "$(printf '\t')" -f 2- |
 | 
					    cut -d "$(printf '\t')" -f 2- |
 | 
				
			||||||
    column -t -s "$(printf '\t')" -R 5 -E 0 |
 | 
					    column -t -s "$(printf '\t')" -R 5 |
 | 
				
			||||||
    sed 's| \+\([0-9a-f-]\+\) \+\([0-9a-f-]\+\):\(.*$\)$|\t\1\t\2\t\3|'
 | 
					    sed 's| \+\([0-9a-f-]\+\) \+\([0-9a-f-]\+\):\(.*$\)$|\t\1\t\2\t\3|'
 | 
				
			||||||
  rm -f "$rectmp" "$mpvtmp"
 | 
					  rm -f "$rectmp" "$mpvtmp"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -173,7 +173,6 @@ precompute_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 -r '[
 | 
				
			||||||
      "0",
 | 
					 | 
				
			||||||
      .id,
 | 
					      .id,
 | 
				
			||||||
      .status,
 | 
					      .status,
 | 
				
			||||||
      .date,
 | 
					      .date,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user