We recently upgraded the automation software at WHRB to Rivendell version 4.1.2. We copied the Spinitron API key from the old machine, but it doesn’t seem to work. My logs show “Spinitron1 returned response code 401”, which I think means the key is wrong.
My initial suspicion was that the Spinitron script in version 4.1.2 was buggy, but other users tell me that is not the case.
Have any of y’all any suggestions? I am not very familiar with Spinitron.
This can mean that the API key is wrong or that there was a protocol error in authenticating.
I’m familiar with Spinitron but not so much with Rivendell.
Looking at the logs, WHRB stopped logging to Spinitron from Rivendell at the end of January. So if only recently did the software update then these issues are likely unrelated.
NEWS on Rob’s issues since it applies to any of you using the pypad_spinitron script in Rivendell.
Rob fixed an error in the API key configured into Rivendell and the error changed from a 401 (auth fail) to 400 (bad request).
There’s another Rivendell instance at another station producing consistent 400 errors too.
These errors aren’t being logged in the station’s Automation Log in Spinitron, which probably means they aren’t coming from our application code. This suggests a lower level exception sent by the REST/JSON API framework we use so they don’t get as far as our app.
Proper solution is to fix the code that generates the JSON document string. I wouldn’t try to encode the JSON document with a sequence of string concatenations. I’d make a Python dictionary and convert that using json.dumps().
Final note: live is not a required field in the Spinitron API. Only artist and song are required. You can control playlist mode in Spinitron itself so in Rivendell it might be nice to have the option to exclude this field perhaps by allowing PlaylistMode to be omitted or have some other value. I don’t think stations need live any more as it was obsoleted by other Spinitron features a few years ago.