2025-06-23 14:28:34 +02:00
|
|
|
|
2025-06-23 12:27:49 +00:00
|
|
|
import requests
|
2025-06-23 14:59:17 +02:00
|
|
|
from config import (
|
|
|
|
|
LIDARR_URL,
|
|
|
|
|
LIDARR_API_KEY,
|
|
|
|
|
ROOT_FOLDER_PATH,
|
|
|
|
|
QUALITY_PROFILE_ID,
|
|
|
|
|
MONITORED,
|
|
|
|
|
MONITOR_NEW_ITEMS,
|
|
|
|
|
SEARCH_FOR_MISSING_ALBUMS,
|
|
|
|
|
DEBUG_PRINT,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def lidarr_add_artist(artist):
|
|
|
|
|
payload = {
|
|
|
|
|
"artistName": artist["artistName"],
|
|
|
|
|
"foreignArtistId": artist["foreignArtistId"],
|
|
|
|
|
"rootFolderPath": ROOT_FOLDER_PATH,
|
|
|
|
|
"qualityProfileId": QUALITY_PROFILE_ID,
|
|
|
|
|
"metadataProfileId": 1,
|
|
|
|
|
"monitored": MONITORED,
|
|
|
|
|
"monitorNewItems": MONITOR_NEW_ITEMS,
|
|
|
|
|
"addOptions": {
|
|
|
|
|
"monitor": MONITOR_NEW_ITEMS,
|
|
|
|
|
"searchForMissingAlbums": SEARCH_FOR_MISSING_ALBUMS
|
|
|
|
|
},
|
|
|
|
|
"artistType": artist.get("artistType", "Group"),
|
|
|
|
|
"disambiguation": artist.get("disambiguation", ""),
|
|
|
|
|
"overview": artist.get("overview", ""),
|
|
|
|
|
"images": artist.get("images", []),
|
|
|
|
|
"links": artist.get("links", []),
|
|
|
|
|
"folder": artist["folder"]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if DEBUG_PRINT:
|
|
|
|
|
print(f"[LIDARR DEBUG] Artist hittad: {artist['artistName']} (MBID: {artist['foreignArtistId']})")
|
|
|
|
|
print(f"[LIDARR DEBUG] Payload: {payload}")
|
2025-06-23 12:27:49 +00:00
|
|
|
|
2025-06-23 14:09:29 +02:00
|
|
|
try:
|
2025-06-23 14:59:17 +02:00
|
|
|
response = requests.post(
|
|
|
|
|
f"{LIDARR_URL}/api/v1/artist",
|
|
|
|
|
headers={"X-Api-Key": LIDARR_API_KEY},
|
|
|
|
|
json=payload
|
|
|
|
|
)
|
|
|
|
|
response.raise_for_status()
|
|
|
|
|
return response.json()
|
|
|
|
|
except requests.exceptions.HTTPError as e:
|
|
|
|
|
print(f"[LIDARR ERROR] HTTP-fel vid tillägg av MBID {artist['foreignArtistId']}: {e}")
|
|
|
|
|
if e.response is not None:
|
|
|
|
|
print(f"[LIDARR ERROR] Svar från servern: {e.response.json()}")
|
|
|
|
|
return None
|