[Solved] Error when using web API

Hi there,

Since it is my first post here, hello to all.

I have a strange issue: I installed beets a while ago and imported all my music in it. All went fine and well.
But now I’m looking into having Beets as a back-end to an Ampache streaming webserver.
So Activated the web plugin and configured it it the config file.

Beets web runs, but retrieving any ID throws an error.
Issuing something like:
$ curl http://beets-server:8337/item/4
returns:
500 Internal Server Error

(Omitting rest of HTML text)

Beets itself is run as beet web, of course shows this:

[2020-09-17 21:43:27,216] ERROR in app: Exception on /item/4 [GET]
Traceback (most recent call last):
File “/usr/lib/python3.8/site-packages/flask/app.py”, line 2446, in wsgi_app
ctx.push()
File “/usr/lib/python3.8/site-packages/flask/ctx.py”, line 396, in push
self.match_request()
File “/usr/lib/python3.8/site-packages/flask/ctx.py”, line 350, in match_request
result = self.url_adapter.match(return_rule=True)
File “/usr/lib/python3.8/site-packages/werkzeug/routing.py”, line 1873, in match
rv = rule.match(path, method)
File “/usr/lib/python3.8/site-packages/werkzeug/routing.py”, line 902, in match
new_path = “|”.join(self.build(result, False))
File “/usr/lib/python3.8/site-packages/werkzeug/routing.py”, line 1040, in build
return self._build(**values)
File “”, line 1, in <builder:’/item/idlist:ids’>
File “/usr/lib/python3.8/site-packages/beetsplug/web/init.py”, line 172, in to_url
return ‘,’.join(value)
TypeError: sequence item 0: expected str instance, int found

With my minimal knowledge of Python, I assume something in the URL is incorrect, but I don’t know what.

Has someone else had tis issue, and how can I resolve or debug it?

Versions:

beets version 1.4.9
Python version 3.8.5
plugins: acousticbrainz, badfiles, chroma, convert, discogs, edit, embedart, fetchart, fromfilename, ftintitle, fuzzy, info, inline, lastgenre, mbsync, permissions, replaygain, rewrite, scrub, the, web, zero

Running on Archlinux with beets from archlinux repository, as all the supporting packages for plugins. e.g. no pip is used.

Thanx!

It looks like this may have been fixed on master in d43d54e, but there isn’t yet a release containing this change.

You could try running the latest source version of beets and seeing if that helps.

1 Like

Nailed it!

It sure is fixed in the latest source branch.
Thank you for your suggestion. I can continue now connecting Ampache to Beets.

Hello, I don’t know anything about Ampache or what exactly you’re doing (it sounds interesting), but I’d just like to mention AURA, which will in the (hopefully near) future provide an alternative to the web API. Beets doesn’t currently have AURA support, and the specification isn’t stable yet, but I’ve very nearly finished writing a new plugin that adds it.

Just thought you might like to know in case you want to switch to it in the future. It provides more information and options than the web plugin API, although at the moment the query syntax is nowhere near as powerful as beets’.

1 Like

Hmm, AURA sounds interesting. I will keep an eye on it. And will inform the Ampache devs when it’s ready.

For Ampache, that is an audio streaming server. It has stable APIs for integration with desktop and mobile apps. Even a full-blown Subsonic API is available, out of the box.
Now, there are a few backends for Ampache, where the music is stored. For example DAAP, Files and Beets. Ampache fetches the Beets catalog and when playing, it forwards the audio stream from Beets to the client, optionally with transcoding.
Running Ampache with a Beets backend is very simple. Just configure a catalog as beets, or beetsremote. Supply IP and port and you’re done, apart from fetching the catalog data from Beets.

Hope this clarifies Ampache a bit. When you want to stream audio/music over the web, or through a LAN, it is definitely wordt checking out.

:slight_smile:

1 Like

Cool! I’ll have a look into it.