Subsonic API Import/Export plugin

164 views
Skip to first unread message

François-Xavier Thomas

unread,
Aug 7, 2016, 5:46:40 PM8/7/16
to beets
Hello,

I am a huge user of Subsonic (now Libresonic) in combination with Beets. The fact that its database is a huge opaque blob that can only be opened by a quite unstable and badly documented Java tool bothers me, but I haven't yet found a web interface that handles my collection and syncs with Android and iOS apps quite as well.

I'd like to at least get data out of it at some point, especially play counts and star ratings. So :

* What is the best way to store them in beets?
* There is a "Play Count" tag in ID3v2.3, can beets use that?
* Is there a similar thing for star ratings?
* If not, what do other software usually do (as in, do something that can be reused by others)

These two attributes are exposed by the Subsonic API. The plan is to match the results with :

1) Filesystem path if possible (e.g. if Subsonic and Beets share a music collection)
2) Album/Artist/Title if there is only one result in the Beets database
3) Finally, user choice if there are multiple results

What do you think?

Adrian Sampson

unread,
Aug 7, 2016, 6:48:58 PM8/7/16
to beets...@googlegroups.com
Cool! Transitioning from Subsonic to a beets library seems like a common problem.

I believe there are ID3 tags for both play count and star rating. There’s more about the rating tag in this thread:

At the moment, beets doesn’t support either, but this shouldn’t be a difficult change to make if you’re interested. In the mean time, you can use beets’s flexible attributes to store the data in the SQLite database without writing it to the files.

These two attributes are exposed by the Subsonic API. The plan is to match the results with :

1) Filesystem path if possible (e.g. if Subsonic and Beets share a music collection)
2) Album/Artist/Title if there is only one result in the Beets database
3) Finally, user choice if there are multiple results

This approach sounds great!

Adrian

François-Xavier Thomas

unread,
Aug 15, 2016, 5:01:56 PM8/15/16
to beets...@googlegroups.com
I quickly whipped together a working prototype in order to see if my idea works.

I'm unclear about one thing. I'm doing something like this to match
Subsonic media files with Beets' items :

>>> query = (
... "artist:%s" % artist,
... "title:%s" % title,
... "album:%s" % album,
... )
>>> matches = lib.items(query)

Handcrafting a string query seems inefficient ; it also returns
multiple results if a song title is a substring of another (e.g.
"Song" and "Song (Instrumental)"), which is Not Good™. I didn't find
an official way to directly query the Item model in the docs[0], is
there any?

[0] http://beets.readthedocs.io/en/latest/dev/api.html
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "beets" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/beets-users/_imCIAklSJU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> beets-users...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Adrian Sampson

unread,
Aug 16, 2016, 9:24:32 AM8/16/16
to beets...@googlegroups.com
Yes, it is possible! The `lastimport` plugin is a good example:

Basically, you can construct an object from the `dbcore.query` module and pass it to `lib.items` instead of a string.

Adrian


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.

François-Xavier Thomas

unread,
Aug 16, 2016, 6:38:08 PM8/16/16
to beets...@googlegroups.com
Thanks for the pointer! I'll add a PR to document this when I get to it.

On the ~2000 starred songs I have, less than 1% don't match correctly
now, mostly because some people put the same name on multiple songs in
a single album. I should be able to do something about that.

Adrian Sampson

unread,
Aug 16, 2016, 7:34:22 PM8/16/16
to beets...@googlegroups.com
Woohoo! I'm glad that technique seems to be working.

Andy Pastuszak

unread,
Sep 14, 2016, 8:50:53 PM9/14/16
to beets
As a side note, you should check out Ampache, another great music streaming server, written in php that uses a LAMP stack, and heavily relies on Musicbrainz tagging.  Unlike Subsonic, Ampache is open source.

Perhaps it might be worth it for the two projects to talk and find a way to share info.

Andy

François-Xavier Thomas

unread,
Sep 25, 2016, 2:44:08 PM9/25/16
to beets...@googlegroups.com
I actually have already tried Ampache ; at the moment I find the
Libresonic UI much more fluid and useable, so I'll stick with it. I
might change at some point, but then I'll need some way to export
data. This is where Beets comes in!
Reply all
Reply to author
Forward
0 new messages