debugging lidarr integration
This commit is contained in:
parent
9e9f27398c
commit
5cb14ef425
1 changed files with 56 additions and 19 deletions
|
|
@ -1,28 +1,65 @@
|
|||
from config import *
|
||||
import requests
|
||||
|
||||
# def lidarr_api_add_artist(mbid):
|
||||
# lookup_url = f"{LIDARR_URL}/api/v1/artist/lookup?term=mbid:{mbid}"
|
||||
# headers = {"X-Api-Key": LIDARR_API_KEY, "Content-Type": "application/json"}
|
||||
|
||||
# res = requests.get(lookup_url, headers=headers)
|
||||
# if not res.ok or not res.json():
|
||||
# return False
|
||||
|
||||
# artist = res.json()[0]
|
||||
# payload = {
|
||||
# "foreignArtistId": artist['foreignArtistId'],
|
||||
# "artistName": artist['artistName'],
|
||||
# "monitored": True,
|
||||
# "qualityProfileId": QUALITY_PROFILE_ID,
|
||||
# "metadataProfileId": 1,
|
||||
# "rootFolderPath": ROOT_FOLDER,
|
||||
# "addOptions": {
|
||||
# "monitor": "all",
|
||||
# "searchForMissingAlbums": True
|
||||
# }
|
||||
# }
|
||||
|
||||
# add_url = f"{LIDARR_URL}/api/v1/artist"
|
||||
# post_res = requests.post(add_url, headers=headers, json=payload)
|
||||
# return post_res.ok
|
||||
|
||||
def lidarr_api_add_artist(mbid):
|
||||
lookup_url = f"{LIDARR_URL}/api/v1/artist/lookup?term=mbid:{mbid}"
|
||||
headers = {"X-Api-Key": LIDARR_API_KEY, "Content-Type": "application/json"}
|
||||
|
||||
headers = {"X-Api-Key": LIDARR_API_KEY}
|
||||
try:
|
||||
res = requests.get(lookup_url, headers=headers)
|
||||
if not res.ok or not res.json():
|
||||
res.raise_for_status()
|
||||
data = res.json()
|
||||
|
||||
if not data:
|
||||
print(f"[LIDARR DEBUG] Ingen artist hittades för MBID {mbid}")
|
||||
return False
|
||||
|
||||
artist = res.json()[0]
|
||||
artist = data[0]
|
||||
print(f"[LIDARR DEBUG] Artist hittad: {artist['artistName']} (MBID: {mbid})")
|
||||
|
||||
payload = {
|
||||
"foreignArtistId": artist['foreignArtistId'],
|
||||
"artistName": artist['artistName'],
|
||||
"foreignArtistId": mbid,
|
||||
"monitored": True,
|
||||
"qualityProfileId": QUALITY_PROFILE_ID,
|
||||
"qualityProfileId": 1,
|
||||
"metadataProfileId": 1,
|
||||
"rootFolderPath": ROOT_FOLDER,
|
||||
"rootFolderPath": ROOT_FOLDER_PATH,
|
||||
"addOptions": {
|
||||
"monitor": "all",
|
||||
"searchForMissingAlbums": True
|
||||
}
|
||||
}
|
||||
|
||||
add_url = f"{LIDARR_URL}/api/v1/artist"
|
||||
post_res = requests.post(add_url, headers=headers, json=payload)
|
||||
return post_res.ok
|
||||
res = requests.post(add_url, headers=headers, json=payload)
|
||||
res.raise_for_status()
|
||||
|
||||
print(f"[LIDARR DEBUG] Lyckades lägga till: {artist['artistName']}")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"[LIDARR ERROR] Kunde inte lägga till MBID {mbid}: {e}")
|
||||
return False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue