"Official" Python 3 Access To A Beets Library #5073
Replies: 2 comments 4 replies
-
I'm having a little difficulty understanding what you're asking for. Can you elaborate? The code itself is available but we don't have any API documentation available. You can definitely use the library functions that we have. Also, all of the data is held in a sqlite database, so you can browse that with any tools that work with that kind of data. |
Beta Was this translation helpful? Give feedback.
-
Exactly as @Serene-Arc put it: Beets doesn't have an API like REST you could access (there is something in the queue somewhere but not nearly finished AFAIK). Furthermore, if I understand correctly and since I recently also had a use-case like that(simply querying a beets database to get information like path,trackname's,etc) - you don't have to fire subprocess - that is slow, errorprone and actually pretty annoying (been there, done that, in the end refactored all to Python) Accessing a beets library via it's library objects directly is the better faster and actually easier way. I don't have anything of my code in that particular project open-source'd, I'm very sorry :-( but basically start with something like that:
Querying examples with that function above:
In my use case I want to query beets library to get fully qualified paths returned. Adapt to your needs! Also, I think there are too much things imported that won't get used in those snippets. I left it, you might need them for something else... Warning: These are copy paste snippets of my commits and might not work at all. If you are a programme you will get the idea. Please ask back if something is not clear to you! I'll try to help and elaborate. It's been some time since I coded that! ;-) and then move on with reading beets' developer docs: https://beets.readthedocs.io/en/latest/dev/index.html or maybe even start with the reference: https://beets.readthedocs.io/en/latest/dev/library.html Does that help somehow? PS: Sorry for not formatting all that properly. I'm a little busy with things/educational stuff currently. HTH! |
Beta Was this translation helpful? Give feedback.
-
I'm writing a plugin for the IRC bot Limnoria that controls a LiquidSoap powered radio stream, effectively letting me override the auto DJ in specific circumstances. The specific function I'm trying to create is a song request command that doesn't require the exact path to a track.
I've chosen Beets as my media library manager for this purpose, since it does exactly what I need it to do (and more I didn't know I needed, thank you!). But in order to make calls to beet, it seems like I would need to use the subprocess module. This would certainly work, but since Limnoria is also Python 3 I would prefer to import beets and directly interface with a "search" submethod.
If I'm not missing something silly here, could I ask for this as a feature request?
Beta Was this translation helpful? Give feedback.
All reactions