Last active
July 19, 2025 23:07
-
-
Save jackskhakis/711b54352a5ee9d1ae9778f2060ce444 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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