11#! /usr/bin/with-contenv bash
2- scriptVersion=" 2.1 "
2+ scriptVersion=" 2.3 "
33scriptName=" AutoArtistAdder"
44
55# ## Import Settings
@@ -32,6 +32,15 @@ verifyConfig () {
3232
3333sleepTimer=0.5
3434
35+ GetTag () {
36+ tagId=" $( curl -s " $arrUrl /api/v1/tag?apikey=${arrApiKey} " | jq -r ' .[] |select(.label=="arr-extended") | .id' ) "
37+ }
38+
39+ AddTag () {
40+ log " adding arr-extended tag"
41+ lidarrProcessIt=$( curl -s " $arrUrl /api/v1/tag" --header " X-Api-Key:" ${arrApiKey} -H " Content-Type: application/json" --data-raw ' {"label":"arr-extended"}' )
42+ }
43+
3544
3645NotifyWebhook () {
3746 if [ " $webHook " ]
@@ -109,6 +118,7 @@ AddDeezerArtistToLidarr () {
109118 qualityProfileId=$( echo $qualityProfileId | cut -d' ' -f1)
110119 metadataProfileId=" $( echo " $data " | jq -r " .defaultMetadataProfileId" ) "
111120 metadataProfileId=$( echo $metadataProfileId | cut -d' ' -f1)
121+ GetTag
112122 data=" {
113123 \" artistName\" : \" $artistName \" ,
114124 \" foreignArtistId\" : \" $foreignId \" ,
@@ -117,6 +127,7 @@ AddDeezerArtistToLidarr () {
117127 \" monitored\" :$autoArtistAdderMonitored ,
118128 \" monitor\" :\" all\" ,
119129 \" rootFolderPath\" : \" $path \" ,
130+ \" tags\" : [ $tagId ],
120131 \" addOptions\" :{\" searchForMissingAlbums\" :$lidarrSearchForMissing }
121132 }"
122133 if echo " $lidarrArtistIds " | grep " ^${foreignId} $" | read ; then
@@ -159,7 +170,14 @@ AddDeezerRelatedArtists () {
159170 log " $artistNumber of $lidarrArtistTotal :: $wantedAlbumListSource :: $lidarrArtistName :: Artist is not monitored :: skipping..."
160171 continue
161172 fi
162-
173+ if [ $preventRelatedArtistsLoop == " true" ]; then
174+ GetTag
175+ if echo " $lidarrArtistData " | jq -r .tags[] | grep " $tagId " | read ; then
176+ log " $artistNumber of $lidarrArtistTotal :: $lidarrArtistName :: This artist was added via related artist, skipping..."
177+ continue
178+ fi
179+ fi
180+
163181 for dId in ${! deezerArtistIds[@]} ; do
164182 deezerArtistId=" ${deezerArtistIds[$dId]} "
165183 deezerRelatedArtistData=$( curl -sL --fail " https://api.deezer.com/artist/$deezerArtistId /related?limit=$numberOfRelatedArtistsToAddPerArtist " | jq -r " .data | sort_by(.nb_fan) | reverse | .[]" )
@@ -211,7 +229,14 @@ AddTidalRelatedArtists () {
211229 log " $artistNumber of $lidarrArtistTotal :: $lidarrArtistName :: Artist is not monitored :: skipping..."
212230 continue
213231 fi
214-
232+ if [ $preventRelatedArtistsLoop == " true" ]; then
233+ GetTag
234+ if echo " $lidarrArtistData " | jq -r .tags[] | grep " $tagId " | read ; then
235+ log " $artistNumber of $lidarrArtistTotal :: $lidarrArtistName :: This artist was added via related artist, skipping..."
236+ continue
237+ fi
238+ fi
239+
215240 for Id in ${! serviceArtistIds[@]} ; do
216241 serviceArtistId=" ${serviceArtistIds[$Id]} "
217242 serviceRelatedArtistData=$( curl -sL --fail " https://api.tidal.com/v1/pages/single-module-page/ae223310-a4c2-4568-a770-ffef70344441/4/b4b95795-778b-49c5-a34f-59aac055b662/1?artistId=$serviceArtistId &countryCode=$tidalCountryCode &deviceType=BROWSER" -H ' x-tidal-token: CzET4vdadNUFQ5JU' | jq -r .rows[].modules[].pagedList.items[])
@@ -260,6 +285,7 @@ AddTidalArtistToLidarr () {
260285 qualityProfileId=$( echo $qualityProfileId | cut -d' ' -f1)
261286 metadataProfileId=" $( echo " $data " | jq -r " .defaultMetadataProfileId" ) "
262287 metadataProfileId=$( echo $metadataProfileId | cut -d' ' -f1)
288+ GetTag
263289 data=" {
264290 \" artistName\" : \" $artistName \" ,
265291 \" foreignArtistId\" : \" $foreignId \" ,
@@ -268,6 +294,7 @@ AddTidalArtistToLidarr () {
268294 \" monitored\" :$autoArtistAdderMonitored ,
269295 \" monitor\" :\" all\" ,
270296 \" rootFolderPath\" : \" $path \" ,
297+ \" tags\" : [ $tagId ],
271298 \" addOptions\" :{\" searchForMissingAlbums\" :$lidarrSearchForMissing }
272299 }"
273300 if echo " $lidarrArtistIds " | grep " ^${foreignId} $" | read ; then
@@ -294,6 +321,7 @@ for (( ; ; )); do
294321 verifyConfig
295322 getArrAppInfo
296323 verifyApiAccess
324+ AddTag
297325
298326 if [ -z $lidarrSearchForMissing ]; then
299327 lidarrSearchForMissing=true
0 commit comments