Compare commits
3 Commits
30765b7347
...
feat/mpv
Author | SHA1 | Date | |
---|---|---|---|
f4594ca492 | |||
3395f8e068 | |||
210cfd01f7 |
24
src/main.sh
24
src/main.sh
@@ -47,10 +47,10 @@ if [ "${1:-}" = "--decorate" ]; then
|
||||
fi
|
||||
|
||||
if [ "${1:-}" = "--reload" ]; then
|
||||
[ ! "${MUSICDIR:-}" ] && err "The environment variable MUSICDIR is not set." && exit 1
|
||||
[ ! -d "${MUSICDIR:-}" ] && err "The environment variable MUSICDIR does not point to a directory." && exit 1
|
||||
info "Reloading information of local music directory $MUSICDIR"
|
||||
load_local || err "Failed to load local data"
|
||||
[ ! "${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"
|
||||
info "Done"
|
||||
exit 0
|
||||
fi
|
||||
@@ -96,9 +96,9 @@ if [ "${1:-}" = "--play-release" ]; then
|
||||
sort_by([.pos, .number]) |
|
||||
map($base + "/" + .file)[]' >"$tmplist"
|
||||
if [ "${4:-}" ]; then
|
||||
mpv_play_list "$tmplist"
|
||||
else
|
||||
mpv_queue_list "$tmplist"
|
||||
else
|
||||
mpv_play_list "$tmplist"
|
||||
fi
|
||||
rm -f "$tmplist"
|
||||
exit 0
|
||||
@@ -106,11 +106,10 @@ fi
|
||||
|
||||
if [ "${1:-}" = "--play-recording" ]; then
|
||||
echo "Playing recording $2" >>/tmp/foo
|
||||
mpv_play_file "$2"
|
||||
if [ "${3:-}" ]; then
|
||||
mpv_play_file "$2"
|
||||
else
|
||||
mpv_queue_file "$2"
|
||||
else
|
||||
mpv_play_file "$2"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
@@ -386,7 +385,7 @@ GENERAL OPTIONS:
|
||||
|
||||
MANAGE LOCAL MUSIC:
|
||||
--decorate <path> Decorate directory containing a tagged release
|
||||
--reload Populate database with decorated local music
|
||||
--reload <path> Populate database with decorated local music from <path>
|
||||
EOF
|
||||
exit 0
|
||||
fi
|
||||
@@ -542,6 +541,11 @@ while true; do
|
||||
[ "$lns" -eq 2 ] && [ "$key" = "ctrl-h" ] && set -- "--releasegroup" "$(mb_release "$2" | $JQ -r -c '."release-group".id')"
|
||||
[ "$lns" -eq 2 ] && [ "$key" = "ctrl-a" ] && set -- "--select-artist" "$(mb_release "$2" | $JQ -r -c ".media[].tracks[] | select(.id==\"$mid\") | .\"artist-credit\"")"
|
||||
;;
|
||||
"--playlist")
|
||||
count=$(mpv_playlist_count)
|
||||
echo "Playlist: count=$count" >>/tmp/foo
|
||||
set -- ""
|
||||
;;
|
||||
"--select-artist")
|
||||
tput rmcup
|
||||
sel=$(
|
||||
|
@@ -1,7 +1,4 @@
|
||||
if [ "${CONFIGFILE:-}" ]; then
|
||||
[ ! -f "$CONFIGFILE" ] && err "Configuration $CONFIGFILE not found." && exit 1
|
||||
. "$CONFIGFLIE"
|
||||
[ ! "${MUSICDIR:-}" ] && err "MUSICDIR configuration not set." && exit 1
|
||||
fi
|
||||
[ "${MUSICDIR:-}" ] && [ ! -d "${MUSICDIR:-}" ] && err "The specified path ${MUSICDIR:-} is not a directory." && exit 1
|
||||
DECORATION_FILENAME=${DECORATION_FILENAME:-"mbid.json"}
|
||||
|
@@ -101,14 +101,16 @@ LOCALDATA_RELEASES="$LOCALDATADIR/releases"
|
||||
LOCALDATA_ARTISTS_VIEW="$LOCALDATADIR/artists_view"
|
||||
LOCALDATA_RELEASEGROUPS_VIEW="$LOCALDATADIR/releasegroups_view"
|
||||
LOCALDATA_RELEASES_VIEW="$LOCALDATADIR/releases_view"
|
||||
DECORATION_FILENAME=${DECORATION_FILENAME:-"mbid.json"}
|
||||
|
||||
# Load local music
|
||||
# argument $1: path to decorated music files
|
||||
load_local() {
|
||||
[ -d "$LOCALDATADIR" ] || mkdir -p "$LOCALDATADIR"
|
||||
tmpreleases=$(mktemp)
|
||||
[ -f "$tmpreleases" ] || exit 1
|
||||
info "Locating and parsing decoration files ($DECORATION_FILENAME)"
|
||||
find "$MUSICDIR" -type f -name "$DECORATION_FILENAME" -print0 |
|
||||
find "$1" -type f -name "$DECORATION_FILENAME" -print0 |
|
||||
xargs -0 -P 4 $JQ -r '.releaseid+"\t"+input_filename' |
|
||||
tee "$LOCALDATA_RELEASES" |
|
||||
cut -d "$(printf '\t')" -f 1 >"$tmpreleases"
|
||||
|
Reference in New Issue
Block a user