now works
This commit is contained in:
parent
5cb14ef425
commit
51afbf5627
2 changed files with 30 additions and 15 deletions
|
|
@ -4,12 +4,12 @@ try:
|
|||
except ImportError:
|
||||
print("⚠️ Du måste skapa en config_local.py med dina API-nycklar.")
|
||||
|
||||
ROOT_FOLDER = "/media/music2"
|
||||
ROOT_FOLDER_PATH = "/data/media/music2"
|
||||
QUALITY_PROFILE_ID = 1
|
||||
|
||||
MIN_PLAYS = 15
|
||||
MIN_PLAYS = 3
|
||||
RECENT_MONTHS = 3
|
||||
MAX_SIMILAR_PER_ART = 20
|
||||
SIMILAR_MATCH_MIN = 0.5
|
||||
CACHE_TTL_HOURS = 24
|
||||
DEBUG_PRINT = True
|
||||
DEBUG_PRINT = True
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from config import *
|
||||
import requests
|
||||
import json
|
||||
|
||||
# def lidarr_api_add_artist(mbid):
|
||||
# lookup_url = f"{LIDARR_URL}/api/v1/artist/lookup?term=mbid:{mbid}"
|
||||
|
|
@ -27,39 +28,53 @@ import requests
|
|||
# post_res = requests.post(add_url, headers=headers, json=payload)
|
||||
# return post_res.ok
|
||||
|
||||
import requests
|
||||
import json
|
||||
from config import *
|
||||
|
||||
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}
|
||||
headers = {"X-Api-Key": LIDARR_API_KEY, "Content-Type": "application/json"}
|
||||
|
||||
try:
|
||||
res = requests.get(lookup_url, headers=headers)
|
||||
res.raise_for_status()
|
||||
data = res.json()
|
||||
artists = res.json()
|
||||
|
||||
if not data:
|
||||
if not artists:
|
||||
print(f"[LIDARR DEBUG] Ingen artist hittades för MBID {mbid}")
|
||||
return False
|
||||
|
||||
artist = data[0]
|
||||
artist = artists[0]
|
||||
print(f"[LIDARR DEBUG] Artist hittad: {artist['artistName']} (MBID: {mbid})")
|
||||
|
||||
payload = {
|
||||
"foreignArtistId": mbid,
|
||||
# Bygg payload från lookup-objektet
|
||||
payload = artist.copy()
|
||||
payload.update({
|
||||
"monitored": True,
|
||||
"qualityProfileId": 1,
|
||||
"qualityProfileId": QUALITY_PROFILE_ID,
|
||||
"metadataProfileId": 1,
|
||||
"rootFolderPath": ROOT_FOLDER_PATH,
|
||||
"addOptions": {
|
||||
"monitor": "all", # Bevakning av alla album
|
||||
"searchForMissingAlbums": True
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
add_url = f"{LIDARR_URL}/api/v1/artist"
|
||||
res = requests.post(add_url, headers=headers, json=payload)
|
||||
res.raise_for_status()
|
||||
print(f"[LIDARR DEBUG] Payload: {json.dumps(payload, indent=2)}")
|
||||
post_res = requests.post(add_url, headers=headers, json=payload)
|
||||
post_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}")
|
||||
except requests.exceptions.HTTPError as http_err:
|
||||
print(f"[LIDARR ERROR] HTTP-fel vid tillägg av MBID {mbid}: {http_err}")
|
||||
if http_err.response is not None:
|
||||
print(f"[LIDARR ERROR] Svar från servern: {http_err.response.text}")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"[LIDARR ERROR] Annat fel vid tillägg av MBID {mbid}: {e}")
|
||||
return False
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue