Skip to content

Instantly share code, notes, and snippets.

@bonelifer
Forked from jackskhakis/add_artist_list.sh
Created July 19, 2025 23:07
Show Gist options
  • Save bonelifer/2fb259a920f05a1e6da3e8997e3dde7c to your computer and use it in GitHub Desktop.
Save bonelifer/2fb259a920f05a1e6da3e8997e3dde7c to your computer and use it in GitHub Desktop.
Script to add list of artists (in a text file) to lidarr, this method bypasses the difficulties that are currently present in lidarr with relation to searching and adding new artists
#!/bin/bash
# Path to the text file with artist names (one per line)
artist_list_file="./artist_list.txt"
# Where Lidarr should create new artist folders
# This must match a configured Root Folder in Lidarr
lidarr_root="/music/"
# Lidarr API details
lidarr_url="http://localhost:8686"
api_key="YOUR_API_KEY_HERE"
# Delay between adding each artist
delay_between_adds=120
# Profile IDs (see below for how to fetch)
quality_profile_id=1
metadata_profile_id=1
# --- HOW TO FETCH PROFILE IDs ---
# curl -s "$lidarr_url/api/v1/qualityprofile" -H "X-Api-Key: $api_key" | jq
# curl -s "$lidarr_url/api/v1/metadataprofile" -H "X-Api-Key: $api_key" | jq
# --- FETCH EXISTING ARTISTS ---
echo "πŸ“₯ Fetching list of existing artists from Lidarr..."
existing_ids=$(curl -s "$lidarr_url/api/v1/artist" \
-H "X-Api-Key: $api_key" | jq -r '.[].foreignArtistId')
# --- PROCESS ARTISTS FROM LIST ---
while IFS= read -r artist_name || [[ -n "$artist_name" ]]; do
# Skip empty lines
[[ -z "$artist_name" ]] && continue
echo "πŸ” Searching for: $artist_name"
search_result=$(curl -s -G "$lidarr_url/api/v1/artist/lookup" \
--data-urlencode "term=$artist_name" \
-H "X-Api-Key: $api_key")
artist_json=$(echo "$search_result" | jq '.[0]')
if [ "$artist_json" == "null" ] || [ -z "$artist_json" ]; then
echo "❌ Not found in lookup: $artist_name"
continue
fi
foreign_id=$(echo "$artist_json" | jq -r '.foreignArtistId')
if echo "$existing_ids" | grep -q "$foreign_id"; then
echo "⏩ Already exists in Lidarr: $artist_name"
continue
fi
target_path="$lidarr_root"
payload=$(jq -n \
--argjson artist "$artist_json" \
--arg path "$target_path" \
--argjson qualityProfileId "$quality_profile_id" \
--argjson metadataProfileId "$metadata_profile_id" \
'{
artistMetadataId: $artist.artistMetadataId,
qualityProfileId: $qualityProfileId,
metadataProfileId: $metadataProfileId,
rootFolderPath: $path,
monitored: true,
foreignArtistId: $artist.foreignArtistId,
artistName: $artist.artistName,
addOptions: {
monitor: "all",
searchForMissingAlbums: true
}
}')
echo "βž• Adding to Lidarr: $artist_name β†’ $target_path"
curl -s -X POST "$lidarr_url/api/v1/artist" \
-H "Content-Type: application/json" \
-H "X-Api-Key: $api_key" \
-d "$payload"
echo "βœ… Done: $artist_name"
echo "⏳ Waiting $delay_between_adds seconds before next artist..."
sleep $delay_between_adds
done < "$artist_list_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment