From 1b1e0476b65fab1674474c5580e9fd8eb33029fd Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Fri, 27 Jan 2023 08:56:19 -0500 Subject: [PATCH] v1.0.5 - Add chapter title fallback --- root/scripts/readarr-pp.bash | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/root/scripts/readarr-pp.bash b/root/scripts/readarr-pp.bash index 746f759..737b5e6 100644 --- a/root/scripts/readarr-pp.bash +++ b/root/scripts/readarr-pp.bash @@ -2,7 +2,7 @@ export LC_ALL=C.UTF-8 export LANG=C.UTF-8 TITLESHORT="APP" -ScriptVersion="1.04" +ScriptVersion="1.05" SECONDS=0 set -e @@ -40,6 +40,7 @@ if [ $(find "$1" -type f -iname "*.mp3" | wc -l) -gt 0 ]; then fileList="$1/list.txt" for i in $(echo "$files"); do chapterNumber=$(( $chapterNumber + 1)) + chapterTitle="" if [ -z "$ffmpegMetadata" ]; then ffmpegMetadata=$(ffmpeg -i "$i" -f ffmetadata -v quiet -) echo "$ffmpegMetadata" >> "$chapterFile" @@ -52,11 +53,15 @@ if [ $(find "$1" -type f -iname "*.mp3" | wc -l) -gt 0 ]; then seconds=$(ffprobe -i "$i" -show_format -v quiet | sed -n 's/duration=//p' | cut -d "." -f1) seconds=$(( $seconds * 1000 )) end=$(( $start + $seconds - 1 )) - title=$(ffprobe -i "$i" -show_format -v quiet | sed -n 's/TAG:title=//p' | cut -d "." -f1) + chapterTitle=$(ffprobe -i "$i" -show_format -v quiet | sed -n 's/TAG:title=//p' | cut -d "." -f1) #echo "seconds :: $seconds" #echo "end :: $end" echo "END=$end" >> "$chapterFile" - echo "title=$title" >> "$chapterFile" + if [ ! -z "$chatperTitle" ]; then + echo "title=$chapterTitle" >> "$chapterFile" + else + echo "title=Part \#$chapterNumber" >> "$chapterFile" + fi echo "" >> "$chapterFile" start=$(( $end + 1 )) echo "file '$i'" >> "$fileList"