A plugin is a good idea too, but you can also import beets as a library. This
tiny example might get you started:
import beets.library
import os
libpath = os.path.expanduser('~/.config/beets/library.db')
lib = beets.library.Library(libpath)
for item in lib.items('artist:muse'):
print(item.title)
No sweat!
Adrian
On Apr 9, 2017, 4:32 AM +0800, Steve Johnson <[email protected]>, wrote:
> The most useful thing would probably be for someone to write a plugin that
> accepts a query on stdin and puts JSON on stdout.
>
> From what I can tell, the 'canonical' way to get access to the beets library
> from a Python script is to implement the script as a plugin. The plugins in
> the beets source tree should provide enough examples to get started.
>
>
> On Sat, Apr 8, 2017, at 01:00 PM, Alessio Elmi wrote:
> > Hi,
> > I would like to query an existing beets library through a Python script.
> > Given the query (eg. "artist:muse") I want it to return a list of beets
> > 'items' with all the attributes with it.
> > However, I couldn't find any example to start with. I very ugly way would
> > be parsing the output of a system call and then split any substring to
> > populate a list of custom objects.
> > I suppose there is a proper way of using API to retrieve a list given the
> > query but I couldn't take a step in that direction.
> > Could you point me to some similar examples?
> > Thank you!
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "beets" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to [email protected].
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "beets" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"beets" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.