metadata extraction; slow
This commit is contained in:
33
fuzique
33
fuzique
@@ -4,6 +4,27 @@ set -eu
|
|||||||
|
|
||||||
APP_NAME="fuzique"
|
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 [ "${1:-}" = "--mpv-play" ]; then
|
||||||
if [ "$3" = "$MODE_PLAYLIST" ]; then
|
if [ "$3" = "$MODE_PLAYLIST" ]; then
|
||||||
echo "{ \"command\": [\"set\", \"playlist-pos-1\", \"$FZF_POS\"] }" | socat - "$MPV_SOCKET"
|
echo "{ \"command\": [\"set\", \"playlist-pos-1\", \"$FZF_POS\"] }" | socat - "$MPV_SOCKET"
|
||||||
@@ -212,7 +233,7 @@ DEPTH=$(echo "$ROOT" | awk -F'/' '{ print NF }')
|
|||||||
# Cache support
|
# Cache support
|
||||||
ROOTHASH=$(echo "$ROOT" | sha1sum | cut -d ' ' -f 1)
|
ROOTHASH=$(echo "$ROOT" | sha1sum | cut -d ' ' -f 1)
|
||||||
CACHE_DIR="$HOME/.cache/$APP_NAME"
|
CACHE_DIR="$HOME/.cache/$APP_NAME"
|
||||||
CACHE_FILE="$CACHE_DIR/$ROOTHASH"
|
CACHE_FILE="$CACHE_DIR/f-$ROOTHASH"
|
||||||
|
|
||||||
# Theme
|
# Theme
|
||||||
ARTIST_COLOR=${ARTIST_COLOR:-'\033[38;5;202m'}
|
ARTIST_COLOR=${ARTIST_COLOR:-'\033[38;5;202m'}
|
||||||
@@ -238,14 +259,10 @@ MODE_PLAYLIST="P"
|
|||||||
MPV_SOCKET="$(mktemp --suffix=.sock)"
|
MPV_SOCKET="$(mktemp --suffix=.sock)"
|
||||||
|
|
||||||
# Load
|
# Load
|
||||||
if [ "${1:-}" = "--reset-cache" ] || [ ! -f "$CACHE_FILE" ]; then
|
if [ ! -f "$CACHE_FILE" ]; then
|
||||||
rm -f "$CACHE_FILE"
|
|
||||||
[ ! -d "$CACHE_DIR" ] && mkdir -p "$CACHE_DIR"
|
[ ! -d "$CACHE_DIR" ] && mkdir -p "$CACHE_DIR"
|
||||||
{
|
$FD --exact-depth 3 --type f -i -e "mp3" -e "mp4" -e "m4a" -e "ogg" -e "flac" -e "wav" -0 . "$ROOT" |
|
||||||
$FD --max-depth 2 --type d . "$ROOT"
|
xargs -0 -P4 -I {} "$0" --get-cache-line "{}" | sort >"$CACHE_FILE"
|
||||||
$FD --exact-depth 3 --type f -i -e "mp3" -e "mp4" -e "m4a" -e "ogg" -e "flac" -e "wav" . "$ROOT"
|
|
||||||
} |
|
|
||||||
sort >"$CACHE_FILE"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Parse
|
# Parse
|
||||||
|
Reference in New Issue
Block a user