diff --git a/root/scripts/ERA.sh b/root/scripts/ERA.sh index 2a0124c..fd07873 100644 --- a/root/scripts/ERA.sh +++ b/root/scripts/ERA.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -scriptVersion="1.0.2" +scriptVersion="1.0.3" agent="ERA ( https://github.com/Makario1337/ExtendedReleaseAdder )" ArtistsJSON=$(jq '.artists[]' /config/artists.json) @@ -20,7 +20,7 @@ if [ -z "$lidarrUrl" ] || [ -z "$lidarrApiKey" ]; then lidarrUrl="http://127.0.0.1:${lidarrPort}${lidarrUrlBase}" fi -LidarrAudiobookRootFolder=$(curl -s GET "$lidarrUrl/api/v1/rootFolder" -H "X-Api-Key: ${lidarrApiKey}" | grep '\/audiobooks\/') + log "-----------------------------------------------------------------------------" log " |\/| _ | _ ._o _ '|~/~/~/" log " | |(_||<(_|| |(_) |_)_)/ " @@ -44,33 +44,35 @@ log "3"; sleep 1 log "2"; sleep 1 log "1"; sleep 1 -if [ -z "$LidarrAudiobookRootFolder" ]; then - log "ERROR :: Audiobooks folder doesn't exist... " +if [ ! -d "$lidarrAudiobookRootFolder" ]; then + log "ERROR :: Audiobooks \"$lidarrAudiobookRootFolder\" folder doesn't exist... " log "ERROR :: Check your Docker path mappings..." log "ERROR :: Exiting ERA..." exit fi -if [ ! -d "/audiobooks" ]; then - log "ERROR :: Audiobooks folder doesn't exist... " - log "ERROR :: Check your Docker path mappings..." +lidarrAudiobookRootFolderCheck=$(curl -s GET "$lidarrUrl/api/v1/rootFolder" -H "X-Api-Key: ${lidarrApiKey}" | grep "$lidarrAudiobookRootFolder") + +if [ -z "$lidarrAudiobookRootFolderCheck" ]; then + log "ERROR :: Audiobooks \"$lidarrAudiobookRootFolder\" is not added to Lidarr as a root folder... " + log "ERROR :: Add \"$lidarrAudiobookRootFolder\" to Lidarr as a root folder" log "ERROR :: Exiting ERA..." exit fi AddReleaseToLidarr() { -lidarrAlbumSearch=$(curl -X GET "$lidarrUrl/api/v1/album/lookup?term="lidarr%3A%20$1"" -H "accept: */*" -H "X-Api-Key: "$lidarrApiKey"" | jq '.') -lidarrAlbumSearch=$(echo $lidarrAlbumSearch | -sed 's/"monitored": false/"monitored": true/g'| -sed 's/"qualityProfileId": 0/"qualityProfileId": 1/g' | -sed 's/"metadataProfileId": 0/"metadataProfileId": 2/g' | -sed 's/"metadataProfileId": 2/"metadataProfileId": 2,\"rootFolderPath": "\/audiobooks\/" /g'| -sed 's/"metadataProfileId": 2/"metadataProfileId": 2,\"addOptions": {"monitor": "all","searchForMissingAlbums": false}/g' | -sed 's/"grabbed": false/"grabbed": false,\"addOptions": {"searchForNewAlbum": false}/g'| -jq '.' | -cut -c 2- | -head -c -2) -curl -X POST "$lidarrUrl/api/v1/album?apikey="$lidarrApiKey"" -H "accept: text/plain" -H "Content-Type: application/json" -d "$lidarrAlbumSearch" + lidarrAlbumSearch=$(curl -X GET "$lidarrUrl/api/v1/album/lookup?term="lidarr%3A%20$1"" -H "accept: */*" -H "X-Api-Key: "$lidarrApiKey"" | jq '.') + lidarrAlbumSearch=$(echo $lidarrAlbumSearch | + sed 's/"monitored": false/"monitored": true/g'| + sed 's/"qualityProfileId": 0/"qualityProfileId": 1/g' | + sed 's/"metadataProfileId": 0/"metadataProfileId": 2/g' | + sed 's/"metadataProfileId": 2/"metadataProfileId": 2,\"rootFolderPath": "\/audiobooks\/" /g'| + sed 's/"metadataProfileId": 2/"metadataProfileId": 2,\"addOptions": {"monitor": "all","searchForMissingAlbums": false}/g' | + sed 's/"grabbed": false/"grabbed": false,\"addOptions": {"searchForNewAlbum": false}/g'| + jq '.' | + cut -c 2- | + head -c -2) + curl -X POST "$lidarrUrl/api/v1/album?apikey="$lidarrApiKey"" -H "accept: text/plain" -H "Content-Type: application/json" -d "$lidarrAlbumSearch" } SearchRelease(){ ReleaseName=$(wget -U "$agent" --timeout=0 -q -O - "https://musicbrainz.org/ws/2/release-group/$1" | grep -o "