improved speed, added local data lists, some cleaning
This commit is contained in:
64
src/main.sh
64
src/main.sh
@@ -3,10 +3,10 @@
|
||||
set -eu
|
||||
|
||||
# The user interface of this application is composed out of the following
|
||||
# views.
|
||||
# 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_RELEASE: Show track list of a 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
|
||||
@@ -16,7 +16,7 @@ set -eu
|
||||
# - 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
|
||||
# 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.
|
||||
#
|
||||
@@ -26,7 +26,7 @@ set -eu
|
||||
# the query string can be written.
|
||||
#
|
||||
# All views and modes are referred to by the following constants. The values
|
||||
# are arbitrary but distinct.
|
||||
# are arbitrary but must be distinct.
|
||||
VIEW_ARTIST="artist"
|
||||
VIEW_RELEASEGROUP="rg"
|
||||
VIEW_RELEASE="release"
|
||||
@@ -56,7 +56,7 @@ MODE_INSERT="show"
|
||||
# Load playlist tools
|
||||
. "sh/playlist.sh"
|
||||
|
||||
# Load MusicBrainz and Discogs methods
|
||||
# Load MusicBrainz, Discogs, and wiki methods
|
||||
. "sh/api.sh"
|
||||
|
||||
# Load mpv methods
|
||||
@@ -313,6 +313,18 @@ case "${1:-}" in
|
||||
;;
|
||||
esac
|
||||
|
||||
# Load configuration
|
||||
. "sh/config.sh"
|
||||
|
||||
# Load theme
|
||||
. "sh/theme.sh"
|
||||
|
||||
# Load tools
|
||||
. "sh/tools.sh"
|
||||
|
||||
# Load AWK scripts
|
||||
. "sh/awk.sh"
|
||||
|
||||
# Non-interactive user commands intended to the user. These commands do not
|
||||
# require temporary files, fzf, nor the mpv instance.
|
||||
case "${1:-}" in
|
||||
@@ -332,7 +344,7 @@ case "${1:-}" in
|
||||
fi
|
||||
exit 0
|
||||
;;
|
||||
"--reload")
|
||||
"--reload-database")
|
||||
# Reload database of local music
|
||||
#
|
||||
# @argument $2: path
|
||||
@@ -343,7 +355,7 @@ case "${1:-}" in
|
||||
[ ! "${2:-}" ] && err "Path to decorated music is missing." && exit 1
|
||||
[ ! -d "$2" ] && err "Path does not point to a directory." && exit 1
|
||||
info "Reloading information of local music directory $2"
|
||||
load_local "$2" || err "Failed to load local data"
|
||||
reloaddb "$2" || err "Failed to load local data"
|
||||
info "Done"
|
||||
exit 0
|
||||
;;
|
||||
@@ -356,27 +368,18 @@ GENERAL OPTIONS:
|
||||
--help Show this help and exit.
|
||||
--artists Default options, list artists of local music
|
||||
--albums List albums of local music
|
||||
--search-artist [<query>] Search artist on MusicBrainz
|
||||
--search-album [<query>] Search album on MusicBrainz
|
||||
--search-artist Search artist on MusicBrainz
|
||||
--search-album Search album on MusicBrainz
|
||||
--artist <mbid> List release groups of given artist <mbid>
|
||||
--releasegroup <mbid> List releases in given release group <mbid>
|
||||
--release <mbid> Show release given by <mbid>
|
||||
--ni-search-artist [<query>] Non-interactive search on MusicBrainz
|
||||
--ni-search-album [<query>] Non-interactive search on MusicBrainz
|
||||
|
||||
MANAGE LOCAL MUSIC:
|
||||
--decorate <path> Decorate directory containing a tagged release
|
||||
--reload <path> Populate database with decorated local music from <path>
|
||||
--reload-database <path> Populate database with decorated local music from <path>
|
||||
EOF
|
||||
exit 0
|
||||
;;
|
||||
"--refresh-view")
|
||||
# Recompute main views
|
||||
#
|
||||
# With this method, the content for the views VIEW_LIST_ARTISTS and VIEW_LIST_ALBUMS are recomputed.
|
||||
precompute_view
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
# Interactive user commands
|
||||
@@ -428,38 +431,29 @@ case "${1:-}" in
|
||||
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
|
||||
# - check for missing data from MusicBrainz
|
||||
# - precompute main views
|
||||
# - 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"
|
||||
|
||||
# Check if the required json files are present
|
||||
local_files_present || load_missing_files
|
||||
# Generate views
|
||||
precompute_views
|
||||
|
||||
# Generate filenames for temporary files
|
||||
tmpdir=$(mktemp -d)
|
||||
LOCKFILE="$tmpdir/lock"
|
||||
|
Reference in New Issue
Block a user