From 1b1f2a0a8bbe997f3fc9a875ea9dddbe33db9751 Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Fri, 28 Oct 2022 09:27:30 -0400 Subject: [PATCH] 1.0.005 - Improved Lyric extraction, add support for OPUS --- root/scripts/MetadataPostProcess.bash | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/root/scripts/MetadataPostProcess.bash b/root/scripts/MetadataPostProcess.bash index da1d222..305c44f 100644 --- a/root/scripts/MetadataPostProcess.bash +++ b/root/scripts/MetadataPostProcess.bash @@ -1,5 +1,5 @@ #!/usr/bin/env bash -version=1.0.004 +version=1.0.005 if [ -z "$lidarr_artist_path" ]; then lidarr_artist_path="$1" notfidedBy=Extended_Script @@ -44,13 +44,23 @@ lrcFile="${lidarr_trackfile_path%.*}.lrc" if [ -f "$lrcFile" ]; then rm "$lrcFile" fi -getLyrics="$(ffprobe -loglevel 0 -print_format json -show_format -show_streams "$lidarr_trackfile_path" | jq -r ".format.tags.LYRICS")" -if [ "$getLyrics" != "null" ]; then +fileName=$(basename -- "$lidarr_trackfile_path") +fileExt="${fileName##*.}" + +if [ "$fileExt" == "flac" ]; then + getLyrics="$(ffprobe -loglevel 0 -print_format json -show_format -show_streams "$lidarr_trackfile_path" | jq -r ".format.tags.LYRICS" | sed "s/null//g" | sed "/^$/d")" + processLyrics=true +fi + +if [ "$fileExt" == "opus" ]; then + getLyrics="$(ffprobe -loglevel 0 -print_format json -show_format -show_streams "$lidarr_trackfile_path" | jq -r ".streams[].tags.LYRICS" | sed "s/null//g" | sed "/^$/d")" +fi + +if [ ! -z "$getLyrics" ]; then log "Processing :: $lidarr_trackfile_path :: Extracting Lyrics..." - ffprobe -loglevel 0 -print_format json -show_format -show_streams "$lidarr_trackfile_path" | jq -r ".format.tags.LYRICS" > "$lrcFile" + echo -n "$getLyrics" > "$lrcFile" log "Processing :: $lidarr_trackfile_path :: Lyrics extracted to: $lrcFile" chmod 666 "$lrcFile" - chown abc:abc "$lrcFile" fi exit