@ -28,28 +28,45 @@ Configuration () {
log ""
log ""
sleep 2
sleep 2
log " ############# $dockerTitle "
log " ############# $dockerTitle "
log "############# SCRIPT VERSION 1.0.000 2 "
log "############# SCRIPT VERSION 1.0.000 3 "
log " ############# DOCKER VERSION $dockerVersion "
log " ############# DOCKER VERSION $dockerVersion "
}
}
AddDeezerTopArtists ( ) {
AddDeezerTopArtists ( ) {
getDeezerArtistsIds = ( $( curl -s https://api.deezer.com/chart/0/artists | jq -r ".data[].id" ) )
getDeezerArtistsIdsCount = $( curl -s https://api.deezer.com/chart/0/artists | jq -r ".data[].id" | wc -l)
description = "Top Artists"
AddDeezerArtistToLidarr
}
AddDeezerTopAlbumArtists ( ) {
getDeezerArtistsIds = ( $( curl -s https://api.deezer.com/chart/0/albums | jq -r ".data[].artist.id" ) )
getDeezerArtistsIdsCount = $( curl -s https://api.deezer.com/chart/0/albums | jq -r ".data[].artist.id" | wc -l)
description = "Top Album Artists"
AddDeezerArtistToLidarr
}
AddDeezerTopTrackArtists ( ) {
getDeezerArtistsIds = ( $( curl -s https://api.deezer.com/chart/0/tracks | jq -r ".data[].artist.id" ) )
getDeezerArtistsIdsCount = $( curl -s https://api.deezer.com/chart/0/tracks | jq -r ".data[].artist.id" | wc -l)
description = "Top Track Artists"
}
AddDeezerArtistToLidarr ( ) {
lidarrArtistsData = " $( curl -s " $lidarrUrl /api/v1/artist?apikey= ${ lidarrApiKey } " ) "
lidarrArtistsData = " $( curl -s " $lidarrUrl /api/v1/artist?apikey= ${ lidarrApiKey } " ) "
lidarrArtistIds = " $( echo " ${ lidarrArtistsData } " | jq -r ".[].foreignArtistId" ) "
lidarrArtistIds = " $( echo " ${ lidarrArtistsData } " | jq -r ".[].foreignArtistId" ) "
deezerArtistsUrl = $( echo " ${ lidarrArtistsData } " | jq -r ".[].links | .[] | select(.name==\"deezer\") | .url" )
deezerArtistsUrl = $( echo " ${ lidarrArtistsData } " | jq -r ".[].links | .[] | select(.name==\"deezer\") | .url" )
deezeArtistIds = " $( echo " $deezerArtistsUrl " | grep -o '[[:digit:]]*' | sort -u) "
deezeArtistIds = " $( echo " $deezerArtistsUrl " | grep -o '[[:digit:]]*' | sort -u) "
getDeezerTopArtistsData = $( curl -s https://api.deezer.com/chart/0/artists | jq -r ".data[]" )
log " :: Finding $description ... "
getDeezerTopArtistsIds = ( $( curl -s https://api.deezer.com/chart/0/artists | jq -r ".data[].id" ) )
log " :: $getDeezerArtistsIdsCount $description Found... "
getDeezerTopArtistsIdsCount = $( curl -s https://api.deezer.com/chart/0/artists | jq -r ".data[].id" | wc -l)
for id in ${ !getDeezerArtistsIds[@] } ; do
log ":: Finding Top Artists..."
log " :: $getDeezerTopArtistsIdsCount Top Artists Found "
for id in ${ !getDeezerTopArtistsIds[@] } ; do
currentprocess = $(( $id + 1 ))
currentprocess = $(( $id + 1 ))
deezerArtistId = " ${ getDeezerTopArtistsIds [ $id ] } "
deezerArtistId = " ${ getDeezerArtistsIds [ $id ] } "
deezerArtistName = " $( echo $getDeezerTopArtistsData | jq -r " select(.id== $deezerArtistId ) | .name " ) "
deezerArtistName = " $( curl -s https://api.deezer.com/artist/$deezerArtistId | jq -r .name) "
log " :: $currentprocess of $getDeezerTopArtistsIdsCount :: $deezerArtistName :: Searching Musicbrainz for Deezer artist id ( $deezerArtistId ) "
log " :: $currentprocess of $getDeezer ArtistsIdsCount :: $deezerArtistName :: Searching Musicbrainz for Deezer artist id ( $deezerArtistId ) "
if echo " $deezeArtistIds " | grep " ^ ${ deezerArtistId } $" | read; then
if echo " $deezeArtistIds " | grep " ^ ${ deezerArtistId } $" | read; then
log " :: $currentprocess of $getDeezerTopArtistsIdsCount :: $deezerArtistName :: $deezerArtistId already in Lidarr... "
log " :: $currentprocess of $getDeezer ArtistsIdsCount :: $deezerArtistName :: $deezerArtistId already in Lidarr... "
continue
continue
fi
fi
@ -100,14 +117,14 @@ AddDeezerTopArtists () {
} "
} "
if echo " $lidarrArtistIds " | grep " ^ ${ musicbrainz_main_artist_id } $" | read; then
if echo " $lidarrArtistIds " | grep " ^ ${ musicbrainz_main_artist_id } $" | read; then
log " :: $currentprocess of $getDeezer Top ArtistsIdsCount :: $deezerArtistName :: Already in Lidarr ( $musicbrainz_main_artist_id ), skipping... "
log " :: $currentprocess of $getDeezer ArtistsIdsCount :: $deezerArtistName :: Already in Lidarr ( $musicbrainz_main_artist_id ), skipping... "
continue
continue
fi
fi
log " :: $currentprocess of $getDeezer Top ArtistsIdsCount :: $deezerArtistName :: Adding $artistName to Lidarr ( $musicbrainz_main_artist_id )... "
log " :: $currentprocess of $getDeezer ArtistsIdsCount :: $deezerArtistName :: Adding $artistName to Lidarr ( $musicbrainz_main_artist_id )... "
LidarrTaskStatusCheck
LidarrTaskStatusCheck
# lidarrAddArtist=$(curl -s "$lidarrUrl/api/v1/artist" -X POST -H 'Content-Type: application/json' -H "X-Api-Key: $lidarrApiKey" --data-raw "$data" )
lidarrAddArtist = $( curl -s " $lidarrUrl /api/v1/artist " -X POST -H 'Content-Type: application/json' -H " X-Api-Key: $lidarrApiKey " --data-raw " $data " )
else
else
log " :: $currentprocess of $getDeezer Top ArtistsIdsCount :: $deezerArtistName :: Artist not found in Musicbrainz, please add \"https://deezer.com/artist/ ${ deezerArtistId } \" to the correct artist on Musicbrainz "
log " :: $currentprocess of $getDeezer ArtistsIdsCount :: $deezerArtistName :: Artist not found in Musicbrainz, please add \"https://deezer.com/artist/ ${ deezerArtistId } \" to the correct artist on Musicbrainz "
fi
fi
done
done
}
}
@ -739,7 +756,7 @@ AddRelatedArtists () {
lidarrArtistList = ( $( echo " ${ lidarrArtistsData } " | jq -r ".[].foreignArtistId" ) )
lidarrArtistList = ( $( echo " ${ lidarrArtistsData } " | jq -r ".[].foreignArtistId" ) )
lidarrArtistIds = " $( echo " ${ lidarrArtistsData } " | jq -r ".[].foreignArtistId" ) "
lidarrArtistIds = " $( echo " ${ lidarrArtistsData } " | jq -r ".[].foreignArtistId" ) "
lidarrArtistLinkDeezerIds = " $( echo " ${ lidarrArtistsData } " | jq -r ".[] | .links[] | select(.name==\"deezer\") | .url" | grep -o '[[:digit:]]*' ) "
lidarrArtistLinkDeezerIds = " $( echo " ${ lidarrArtistsData } " | jq -r ".[] | .links[] | select(.name==\"deezer\") | .url" | grep -o '[[:digit:]]*' ) "
log " $lidarrArtistTotal Artists Found "
log " :: $lidarrArtistTotal Artists Found "
deezerArtistsUrl = $( echo " ${ lidarrArtistsData } " | jq -r ".[].links | .[] | select(.name==\"deezer\") | .url" )
deezerArtistsUrl = $( echo " ${ lidarrArtistsData } " | jq -r ".[].links | .[] | select(.name==\"deezer\") | .url" )
deezeArtistIds = " $( echo " $deezerArtistsUrl " | grep -o '[[:digit:]]*' | sort -u) "
deezeArtistIds = " $( echo " $deezerArtistsUrl " | grep -o '[[:digit:]]*' | sort -u) "
@ -754,80 +771,12 @@ AddRelatedArtists () {
for dId in ${ !deezerArtistIds[@] } ; do
for dId in ${ !deezerArtistIds[@] } ; do
deezerArtistId = " ${ deezerArtistIds [ $dId ] } "
deezerArtistId = " ${ deezerArtistIds [ $dId ] } "
deezerRelatedArtistData = $( curl -sL --fail " https://api.deezer.com/artist/ $deezerArtistId /related " )
deezerRelatedArtistData = $( curl -sL --fail " https://api.deezer.com/artist/ $deezerArtistId /related " )
deezerRelatedArtistIds = ( $( echo $deezerRelatedArtistData | jq -r .data[ ] .id) )
getDeezerArtistsIds = ( $( echo $deezerRelatedArtistData | jq -r .data[ ] .id) )
getDeezerArtistsIdsCount = $( echo $deezerRelatedArtistData | jq -r .data[ ] .id | wc -l)
for dRId in ${ !deezerRelatedArtistIds[@] } ; do
description = " $lidarrArtistName Related Artists "
deezerRelatedArtistId = " ${ deezerRelatedArtistIds [ $dRId ] } "
AddDeezerArtistToLidarr
if echo " $deezeArtistIds " | grep " ^ ${ deezerRelatedArtistId } $" | read; then
log " $deezerRelatedArtistId already in Lidarr... "
continue
fi
query_data = $( curl -s -A " $agent " " https://musicbrainz.org/ws/2/url?query=url:%22https://www.deezer.com/artist/ ${ deezerRelatedArtistId } %22&fmt=json " )
count = $( echo " $query_data " | jq -r ".count" )
if [ " $count " = = "0" ] ; then
sleep 1.5
query_data = $( curl -s -A " $agent " " https://musicbrainz.org/ws/2/url?query=url:%22http://www.deezer.com/artist/ ${ deezerRelatedArtistId } %22&fmt=json " )
count = $( echo " $query_data " | jq -r ".count" )
sleep 1.5
fi
if [ " $count " = = "0" ] ; then
query_data = $( curl -s -A " $agent " " https://musicbrainz.org/ws/2/url?query=url:%22http://deezer.com/artist/ ${ deezerRelatedArtistId } %22&fmt=json " )
count = $( echo " $query_data " | jq -r ".count" )
sleep 1.5
fi
if [ " $count " = = "0" ] ; then
query_data = $( curl -s -A " $agent " " https://musicbrainz.org/ws/2/url?query=url:%22https://deezer.com/artist/ ${ deezerRelatedArtistId } %22&fmt=json " )
count = $( echo " $query_data " | jq -r ".count" )
fi
if [ " $count " != "0" ] ; then
musicbrainz_main_artist_id = $( echo " $query_data " | jq -r '.urls[]."relation-list"[].relations[].artist.id' | head -n 1)
sleep 1.5
artist_data = $( curl -s -A " $agent " " https://musicbrainz.org/ws/2/artist/ $musicbrainz_main_artist_id ?fmt=json " )
artist_sort_name = " $( echo " $artist_data " | jq -r '."sort-name"' ) "
artist_formed = " $( echo " $artist_data " | jq -r '."begin-area".name' ) "
artist_born = " $( echo " $artist_data " | jq -r '."life-span".begin' ) "
gender = " $( echo " $artist_data " | jq -r ".gender" ) "
matched_id = true
data = $( curl -s " $lidarrUrl /api/v1/search?term=lidarr%3A $musicbrainz_main_artist_id " -H " X-Api-Key: $lidarrApiKey " | jq -r ".[]" )
artistName = " $( echo " $data " | jq -r ".artist.artistName" ) "
foreignId = " $( echo " $data " | jq -r ".foreignId" ) "
data = $( curl -s " $lidarrUrl /api/v1/rootFolder " -H " X-Api-Key: $lidarrApiKey " | jq -r ".[]" )
path = " $( echo " $data " | jq -r ".path" ) "
qualityProfileId = " $( echo " $data " | jq -r ".defaultQualityProfileId" ) "
metadataProfileId = " $( echo " $data " | jq -r ".defaultMetadataProfileId" ) "
data = " {
\" artistName\" : \" $artistName \" ,
\" foreignArtistId\" : \" $foreignId \" ,
\" qualityProfileId\" : $qualityProfileId ,
\" metadataProfileId\" : $metadataProfileId ,
\" monitored\" :true,
\" monitor\" :\" all\" ,
\" rootFolderPath\" : \" $path \"
} "
if echo " $lidarrArtistIds " | grep " ^ ${ musicbrainz_main_artist_id } $" | read; then
log " $artistName to already in Lidarr ( $musicbrainz_main_artist_id )... "
continue
fi
log " Adding $artistName to Lidarr ( $musicbrainz_main_artist_id )... "
LidarrTaskStatusCheck
lidarrAddArtist = $( curl -s " $lidarrUrl /api/v1/artist " -X POST -H 'Content-Type: application/json' -H " X-Api-Key: $lidarrApiKey " --data-raw " $data " )
else
matched_id = false
fi
done
done
done
done
done
}
}
LidarrTaskStatusCheck ( ) {
LidarrTaskStatusCheck ( ) {
@ -849,11 +798,22 @@ if [ "$addDeezerTopArtists" = "true" ]; then
else
else
log ":: ERROR :: addDeezerTopArtists is disabled"
log ":: ERROR :: addDeezerTopArtists is disabled"
fi
fi
if [ " $addDeezerTopAlbumArtists " = "true" ] ; then
AddDeezerTopAlbumArtists
else
log ":: ERROR :: addDeezerTopAlbumArtists is disabled"
fi
if [ " $AddRelatedArtists " = "true" ] ; then
if [ " $addDeezerTopTrackArtists " = "true" ] ; then
AddDeezerTopTrackArtists
else
log ":: ERROR :: addDeezerTopTrackArtists is disabled"
fi
if [ " $addRelatedArtists " = "true" ] ; then
AddRelatedArtists
AddRelatedArtists
else
else
log ":: ERROR :: AddRelatedArtists is disabled"
log ":: ERROR :: a ddRelatedArtists is disabled"
fi
fi
if [ " $dlClientSource " = "deezer" ] || [ " $dlClientSource " = "both" ] ; then
if [ " $dlClientSource " = "deezer" ] || [ " $dlClientSource " = "both" ] ; then