imprv: faster playlist handling and a few bugs fixed

This commit is contained in:
2025-10-13 22:07:26 +02:00
parent 3b66faed6f
commit c0463c0d5e
7 changed files with 183 additions and 82 deletions

View File

@@ -426,6 +426,12 @@ case "${1:-}" in
stored_playlists
exit 0
;;
"--print-playlist")
# Pretty print playlist
list_playlist_stored "${2:-}" |
cut -d "$(printf '\t')" -f 1
exit 0
;;
"--help")
# Print help string
cat <<EOF
@@ -442,6 +448,7 @@ GENERAL OPTIONS:
--release <mbid> Show release given by <mbid>
--playlists List stored playlists and exit
--load-playlist <playlist> Load specified playlist
--print-playlist <playlist> Print specified playlist and exit
MANAGE LOCAL MUSIC:
--decorate <path> Decorate directory containing a tagged release
@@ -541,7 +548,10 @@ export LOCKFILE RESULTS PIDFILE
mpv_start
# Playback possible now
[ "${1:-}" = "--load-playlist" ] && $0 --playlist "$PLAYLIST_CMD_LOAD" "${2:-}"
if [ "${1:-}" = "--load-playlist" ]; then
sleep 1
$0 --playlist "$PLAYLIST_CMD_LOAD" "${2:-}"
fi
# main loop
# states are stored in (in)visible labels
@@ -655,7 +665,7 @@ while true; do
sel=$(
stored_playlists | $FZF \
--border=double \
--border-label="$TITLE_PLYLST_LIST" \
--border-label="$TITLE_PLYLST_STORE" \
--margin="2%,10%" \
--bind="$KEYS_I_NORMAL:" \
--bind="$KEYS_DOWN:down" \
@@ -666,9 +676,16 @@ while true; do
--bind="$KEYS_KEYBINDINGS:preview:$0 --show-keybindings $VIEW_PLAYLIST_PLAYLISTSTORE" \
--bind="$KEYS_SCROLL_PREVIEW_DOWN:preview-down" \
--bind="$KEYS_SCROLL_PREVIEW_UP:preview-up" \
--bind="$KEYS_PREVIEW_TOGGLE_WRAP:toggle-preview-wrap" \
--bind="$KEYS_PREVIEW_TOGGLE_SIZE:change-preview-window(right,90%,border-line,nowrap|$FZF_DEFAULT_PREVIEW_WINDOW)" \
--bind="$KEYS_PREVIEW_OPEN:show-preview" \
--bind="$KEYS_PREVIEW_CLOSE:hide-preview" \
--bind="$KEYS_PLAYLISTSTORE_SELECT:transform:[ {1} ] && $0 --playlist $PLAYLIST_CMD_LOAD {1} && echo accept" \
--bind="$KEYS_PLAYLISTSTORE_DELETE:transform:[ {1} ] && rm \"$PLAYLIST_DIRECTORY/{r1}\" && echo \"reload($0 --playlists\)\"" \
--bind="$KEYS_PLAYLISTSTORE_SELECT:transform:[ {1} ] && $0 --playlist $PLAYLIST_CMD_LOAD {2} && echo accept" \
--bind="$KEYS_PLAYLISTSTORE_DELETE:transform:[ {1} ] && rm \"$PLAYLIST_DIRECTORY/{r2}\" && echo \"reload($0 --playlists\)\"" \
--preview="$0 --print-playlist {2}" \
--preview-window="$FZF_DEFAULT_PREVIEW_WINDOW" \
--with-nth="{1}" \
--delimiter="\t" \
--wrap-sign="" || true
)
VIEW="$VIEW_PLAYLIST"