List of existing artists in library

16 views
Skip to first unread message

Sebastián Villamonte

unread,
Jun 25, 2011, 8:02:13 PM6/25/11
to exaile-devel
Hi!
I'm trying to make a plugin in order to get an idea of all existing
artists (and their respective albums) from my collection. Is there a
way to get a list of, say, existing artists in the music library? I
don't know if there's an "artist" object, but a simple list with
artist's names strings will be enough to do the trick (very much like
a SELECT query does). As long as I know, the only path to knowing
something about Exaile's music library using the API, is through the
"trax" object, but it would be very unperforming to scan all existing
tracks in order to build the list of artists, don't you think?
Hope to hear from you! Thanks in advance...

Sebastián

Aren Olson

unread,
Jun 25, 2011, 11:23:26 PM6/25/11
to exaile...@googlegroups.com
It's not nearly as slow as you'd think to scan through them all - the collection panel does it all the time.  If all you want is a list of all artist strings, I'd suggest something like this (untested):

artists = set()
for track in exaile.collection.get_tracks():
   artists.update(track.get_tag_raw("artist") or [])

That should get you a set object containing all the unique artist tag strings in the db, running in roughly O(number of tracks).  This is unsorted obviously, but you can easily turn it into a list and sort it afterwards if necessary.

HTH

-Aren


--
You received this message because you are subscribed to the Google Groups "exaile-devel" group.
To post to this group, send email to exaile...@googlegroups.com.
To unsubscribe from this group, send email to exaile-devel...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/exaile-devel?hl=en.


Sebastián Villamonte

unread,
Jun 26, 2011, 8:58:34 PM6/26/11
to exaile-devel
Wow! You've almost written my plugin! Thanks dude, I will give it a
try, at least as a first approach.
See you around.

Sebastián

On 26 jun, 00:23, Aren Olson <reacoc...@gmail.com> wrote:
> It's not nearly as slow as you'd think to scan through them all - the
> collection panel does it all the time.  If all you want is a list of all
> artist strings, I'd suggest something like this (untested):
>
> artists = set()
> for track in exaile.collection.get_tracks():
>    artists.update(track.get_tag_raw("artist") or [])
>
> That should get you a set object containing all the unique artist tag
> strings in the db, running in roughly O(number of tracks).  This is
> unsorted obviously, but you can easily turn it into a list and sort it
> afterwards if necessary.
>
> HTH
>
> -Aren
>
Reply all
Reply to author
Forward
0 new messages