diff --git a/prowlarr_add_bulk_indexer.sh b/prowlarr_add_bulk_indexer.sh index 2071e5e..58cf3f6 100755 --- a/prowlarr_add_bulk_indexer.sh +++ b/prowlarr_add_bulk_indexer.sh @@ -3,7 +3,6 @@ # Base URL and API key BASE_URL="https://prowlarr.tryton.geeraert.eu" API_KEY="0cb77d794ab74f158daaae044ab850ee" - APP_PROFILE_ID=1 # Set this to a valid App Profile Id # Get the list of all available indexers @@ -11,21 +10,30 @@ available_indexers=$(curl -s -X GET "$BASE_URL/api/v1/indexer/schema" \ -H "accept: application/json" \ -H "X-Api-Key: $API_KEY") -# Loop through each indexer and add it to Prowlarr +# Loop through each indexer and add it to Prowlarr if it matches the criteria echo "$available_indexers" | jq -c '.[]' | while read -r indexer; do indexer_name=$(echo "$indexer" | jq -r '.name') indexer_settings=$(echo "$indexer" | jq -c '.') - # Add the AppProfileId to the indexer settings - indexer_settings=$(echo "$indexer_settings" | jq --argjson appProfileId "$APP_PROFILE_ID" '. + {AppProfileId: $appProfileId}') + # Check if the indexer supports TV or movies and uses the specified languages + supports_tv=$(echo "$indexer_settings" | jq -r 'select(.categories != null) | .categories[] | select(.name == "TV")') + supports_movies=$(echo "$indexer_settings" | jq -r 'select(.categories != null) | .categories[] | select(.name == "Movies")') + supports_languages=$(echo "$indexer_settings" | jq -r 'select(.languages != null) | .languages[] | select(. == "en-US" or . == "en-GB" or . == "fr-FR")') - echo "Adding indexer: $indexer_name" + if [[ -n "$supports_tv" || -n "$supports_movies" ]] && [[ -n "$supports_languages" ]]; then + # Add the AppProfileId to the indexer settings + indexer_settings=$(echo "$indexer_settings" | jq --argjson appProfileId "$APP_PROFILE_ID" '. + {AppProfileId: $appProfileId}') - curl -s -X POST "$BASE_URL/api/v1/indexer" \ - -H "accept: application/json" \ - -H "X-Api-Key: $API_KEY" \ - -H "Content-Type: application/json" \ - -d "$indexer_settings" + echo "Adding indexer: $indexer_name" - echo "Indexer $indexer_name added." + curl -s -X POST "$BASE_URL/api/v1/indexer" \ + -H "accept: application/json" \ + -H "X-Api-Key: $API_KEY" \ + -H "Content-Type: application/json" \ + -d "$indexer_settings" + + echo "Indexer $indexer_name added." + else + echo "Skipping indexer: $indexer_name (does not match criteria)" + fi done