Re: [beets] Query beets library through external python script
Thank you! Very nice tip. Il giorno domenica 9 aprile 2017 11:25:09 UTC+2, Adrian Sampson ha scritto: > > 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>, 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 beets-users...@googlegroups.com . > 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 beets-users...@googlegroups.com . > 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 beets-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [beets] Query beets library through external python script
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, 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 beets-users+unsubscr...@googlegroups.com. > > 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 beets-users+unsubscr...@googlegroups.com. > 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 beets-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [beets] Query beets library through external python script
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 beets-users+unsubscr...@googlegroups.com. > 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 beets-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.