@ -1,5 +1,5 @@
#!/usr/bin/env bash
#!/usr/bin/env bash
scriptVersion = "1.0.27 8 "
scriptVersion = "1.0.27 9 "
if [ -z " $lidarrUrl " ] || [ -z " $lidarrApiKey " ] ; then
if [ -z " $lidarrUrl " ] || [ -z " $lidarrApiKey " ] ; then
lidarrUrlBase = " $( cat /config/config.xml | xq | jq -r .Config.UrlBase) "
lidarrUrlBase = " $( cat /config/config.xml | xq | jq -r .Config.UrlBase) "
if [ " $lidarrUrlBase " = = "null" ] ; then
if [ " $lidarrUrlBase " = = "null" ] ; then
@ -667,8 +667,15 @@ DownloadProcess () {
# Tag with beets
# Tag with beets
if [ " $enableBeetsTagging " = = "true" ] ; then
if [ " $enableBeetsTagging " = = "true" ] ; then
if [ -f /config/extended/beets-error ] ; then
rm /config/extended/beets-error
fi
log " $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Processing files with beets... "
log " $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Processing files with beets... "
ProcessWithBeets " $downloadPath /incomplete "
ProcessWithBeets " $downloadPath /incomplete "
if [ -f /config/extended/beets-error ] ; then
return
fi
fi
fi
# Embed Lyrics into Flac files
# Embed Lyrics into Flac files
@ -800,12 +807,53 @@ ProcessWithBeets () {
done
done
else
else
log " $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Unable to match using beets to a musicbrainz release... "
log " $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Unable to match using beets to a musicbrainz release... "
return
fi
fi
if [ -f "/config/beets-match" ] ; then
if [ -f "/config/beets-match" ] ; then
rm "/config/beets-match"
rm "/config/beets-match"
sleep 0.1
sleep 0.1
fi
fi
# get file extension
find " $downloadPath /incomplete " -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" -print0 | while IFS = read -r -d '' audio; do
file = " ${ audio } "
filenoext = " ${ file %.* } "
filename = " $( basename " $audio " ) "
extension = " ${ filename ##*. } "
breaK
done
# Get file metadata
GetFile = $( find " $downloadPath /incomplete " -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" | head -n1)
if [ " $extension " = = "opus" ] ; then
matchedTags = $( ffprobe -hide_banner -loglevel fatal -show_error -show_format -show_streams -show_programs -show_chapters -show_private_data -print_format json " $GetFile " | jq -r ".streams[].tags" )
else
matchedTags = $( ffprobe -hide_banner -loglevel fatal -show_error -show_format -show_streams -show_programs -show_chapters -show_private_data -print_format json " $GetFile " | jq -r ".format.tags" )
fi
# Get Musicbrainz Release Group ID and Album Artist ID from tagged file
if [ " $extension " = = "flac" ] || [ " $extension " = = "opus" ] ; then
matchedTagsAlbumReleaseGroupId = " $( echo $matchedTags | jq -r ".MUSICBRAINZ_RELEASEGROUPID" ) "
matchedTagsAlbumArtistId = " $( echo $matchedTags | jq -r ".MUSICBRAINZ_ALBUMARTISTID" ) "
elif [ " $extension " = = "mp3" ] || [ " $extension " = = "m4a" ] ; then
matchedTagsAlbumReleaseGroupId = " $( echo $matchedTags | jq -r '."MusicBrainz Release Group Id"' ) "
matchedLidarrAlbumArtistId = " $( echo $matchedTags | jq -r '."MusicBrainz Ablum Artist Id"' ) "
fi
if [ ! -d "/config/extended/logs/downloaded/musicbrainz_matched" ] ; then
mkdir -p "/config/extended/logs/downloaded/musicbrainz_matched"
chmod 777 "/config/extended/logs/downloaded/musicbrainz_matched"
fi
if [ ! -f " /config/extended/logs/downloaded/musicbrainz_matched/ $matchedTagsAlbumReleaseGroupId " ] ; then
touch " /config/extended/logs/downloaded/musicbrainz_matched/ $matchedTagsAlbumReleaseGroupId "
else
log " $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: MusicBrainz Release Group previously Downloaded ( $matchedTagsAlbumReleaseGroupId ) :: Removing and skipping to prevent duplicate import... "
rm -rf " $downloadPath /incomplete " /*
touch /config/extended/beets-error
fi
}
}
DownloadQualityCheck ( ) {
DownloadQualityCheck ( ) {