I see this:
./add_albums_from_list.py 1001_albums_to_listen_to_before_you_die.csv
Traceback (most recent call last):
File "/home/chronos/user/lidarrtools/./add_albums_from_list.py", line 156, in <module>
artists = lookup_artist(album['artist'])
File "/home/chronos/user/lidarrtools/./add_albums_from_list.py", line 23, in lookup_artist
return json.loads(text)
~~~~~~~~~~^^^^^^
File "/usr/local/lib64/python3.13/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
~~~~~~~~~~~~~~~~~~~~~~~^^^
File "/usr/local/lib64/python3.13/json/decoder.py", line 345, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib64/python3.13/json/decoder.py", line 363, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
However, doing this works, as per API info at https://lidarr.audio/docs/api/#/ArtistLookup/get_api_v1_artist_lookup :
curl -X 'GET' 'http://localhost:8686/api/v1/artist/lookup?term=Frank%20Sinatra' -H 'accept: application/json' -H "X-Api-Key: $X_API_KEY"
[
{
"status": "ended",
"ended": true,
"artistName": "Frank Sinatra",
"foreignArtistId": "197450cd-0124-4164-b723-3c22dd16494d",
"tadbId": 0,
"discogsId": 0,
"overview": "Francis Albert Sinatra
...
Doing some debugging I'm seeing content from lookup_artist gets this from urllib.request.urlopen(req):
b'<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#3a3f51"/><meta name="msapplication-navbutton-color" content="#3a3f51"/><meta name="mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/><meta name="format-detection" content="telephone=no"><meta name="description" content="Lidarr"><link rel="apple-touch-icon" sizes="180x180" href="/Content/Images/Icons/apple-touch-icon.png?h=2zTH0oj90pRp7h1h0tgC0g"/><link rel="icon" type="image/png" sizes="32x32" href="/Content/Images/Icons/favicon-32x32.png?h=A4Puz/BOMl/J488czqfgOQ"/><link rel="icon" type="image/png" sizes="16x16" href="/Content/Images/Icons/favicon-16x16.png?h=fo3jAxKiN1Nh18+aHXRozQ"/><link rel="manifest" href="/Content/manifest.json?h=9rX1zcejLhv6e5hZHkCydQ" crossorigin="use-credentials"/><link rel="mask-icon" href="/Content/Images/Icons/safari-pinned-tab.svg?h=LLFuxx74TMIn3Vx2ai6a1A" color="#00ccff"/><link rel="shortcut icon" type="image/ico" href="/favicon.ico"/><meta name="msapplication-config" content="/Content/browserconfig.xml"/><link rel="stylesheet" href="/Content/Fonts/fonts.css?h=ZYP7+3tB+/eme7MGOlDOLg"><script>window.Lidarr = {\r\n urlBase: \'\'\r\n };</script><script src="/index-c6f7935d311318ef5a6a.js"></script><link href="/Content/styles.css?h=VAwjWra8YBWH8JiyE7JFDA" rel="stylesheet"><title>Lidarr</title><style>.root {\r\n overflow: hidden;\r\n height: 100%; /* needed for proper layout */\r\n }\r\n\r\n @media only screen and (max-width: 768px) {\r\n .root {\r\n display: flex;\r\n flex-direction: column;\r\n min-height: 100%;\r\n height: auto;\r\n }\r\n }</style></head><body><div id="portal-root"></div><div id="root" class="root"></div></body></html>'
So the headers aren't being sent properly maybe?
I have tried using url = "http://localhost:8686/lidarr/api/v1/artist/lookup?term={0}&apikey={1}".format(urllib.parse.quote(artist), X_API_KEY) but that does not help either.
I see this:
However, doing this works, as per API info at https://lidarr.audio/docs/api/#/ArtistLookup/get_api_v1_artist_lookup :
Doing some debugging I'm seeing
contentfromlookup_artistgets this fromurllib.request.urlopen(req):So the headers aren't being sent properly maybe?
I have tried using
url = "http://localhost:8686/lidarr/api/v1/artist/lookup?term={0}&apikey={1}".format(urllib.parse.quote(artist), X_API_KEY)but that does not help either.