Compare commits

1 Commits

Author SHA1 Message Date
919d89bc48 metadata extraction; slow 2025-07-18 15:21:50 +02:00

33
fuzique
View File

@@ -4,6 +4,27 @@ set -eu
APP_NAME="fuzique"
if [ "${1:-}" = "--get-cache-line" ]; then
# Format: filename albumartist album year track artist tracknumber
shift
#ffprobe -v quiet -show_entries format -of json "$1" | jq -C '.format.tags'
tags="$(ffprobe -v quiet -show_entries format -of json "$1" |
jq -r '.format.tags |
[
[.album_artist, ."ALBUM ARTIST", ."album artist"],
[.album, .ALBUM],
[.originalyear, .ORIGINALYEAR, ."original year", ."ORIGINAL YEAR", .year, .YEAR, .date, .DATE],
[.title, .TITLE],
[.artist_credit, .ARTIST_CREDIT, .artist, .ARTIST],
[.track, .TRACK]
] | map(map(select(. != null))[0]) | join("\t")')"
printf "%s\t%s\n" "$1" "$tags"
echo "$1" >>/tmp/cacheupd
exit 0
#sh -c 'printf "%s\t%s" "{}" "$(ffprobe -v quiet -show_entries format -of json "{}" | jq -r ".format.tags" | [ [.album_artist, .\"ALBUM ARTIST\", .\"album artist\"])"'
#jq -r '.format.tags | [ [.artist, .ARTIST], [.album, .ALBUM], [.title, .TITLE] ] | map(map(select(. != null))) | map(.[0]) | join("|")'
fi
if [ "${1:-}" = "--mpv-play" ]; then
if [ "$3" = "$MODE_PLAYLIST" ]; then
echo "{ \"command\": [\"set\", \"playlist-pos-1\", \"$FZF_POS\"] }" | socat - "$MPV_SOCKET"
@@ -212,7 +233,7 @@ DEPTH=$(echo "$ROOT" | awk -F'/' '{ print NF }')
# Cache support
ROOTHASH=$(echo "$ROOT" | sha1sum | cut -d ' ' -f 1)
CACHE_DIR="$HOME/.cache/$APP_NAME"
CACHE_FILE="$CACHE_DIR/$ROOTHASH"
CACHE_FILE="$CACHE_DIR/f-$ROOTHASH"
# Theme
ARTIST_COLOR=${ARTIST_COLOR:-'\033[38;5;202m'}
@@ -238,14 +259,10 @@ MODE_PLAYLIST="P"
MPV_SOCKET="$(mktemp --suffix=.sock)"
# Load
if [ "${1:-}" = "--reset-cache" ] || [ ! -f "$CACHE_FILE" ]; then
rm -f "$CACHE_FILE"
if [ ! -f "$CACHE_FILE" ]; then
[ ! -d "$CACHE_DIR" ] && mkdir -p "$CACHE_DIR"
{
$FD --max-depth 2 --type d . "$ROOT"
$FD --exact-depth 3 --type f -i -e "mp3" -e "mp4" -e "m4a" -e "ogg" -e "flac" -e "wav" . "$ROOT"
} |
sort >"$CACHE_FILE"
$FD --exact-depth 3 --type f -i -e "mp3" -e "mp4" -e "m4a" -e "ogg" -e "flac" -e "wav" -0 . "$ROOT" |
xargs -0 -P4 -I {} "$0" --get-cache-line "{}" | sort >"$CACHE_FILE"
fi
# Parse