Author Topic: How can I get distinct album artists?  (Read 4717 times)

ili_ili_ili

  • Newbie
  • *
  • Posts: 7
Hi Steven,
I want to retrieve all album artists from the MB library. I tried to do it by first querying all files, then for each file getting the album artist file tag into a list and finally making the list distinct. The second step is rather time consuming and I wonder if there is another more efficient way to do it. Also, I would like your opinion about how to accomplish communication between a Asp.Net web application and MusicBee running on the same machine.
Thanks.

boroda

  • Sr. Member
  • ****
  • Posts: 4595
use SortedDictionary to store retrieved album artist, it will make things much faster.

ili_ili_ili

  • Newbie
  • *
  • Posts: 7
The slow part is the thousands calls to the Library_GetFileTagDelegate; not adding items to a List. Even if I just call the Library_GetFileTagDelegate and not at all use the returned values the time consumed is very long. So i'm thinking that if there was a single API call to get all distinct values of some tag it would be much more efficient than to have to read the tag for every file one by one.

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
there isnt an optimised way, and you could get all values yourself and use a dictionary or hashset as boroda suggests or
you can use:
Library_QueryLookupTable("Artist", "", null)
or
Library_QueryLookupTable("AlbumArtist", "", null)

and to get the values
Library_QueryGetLookupTableValue(null)

which returns a string formatted as:
artist1\0count1\0\0artist2\0\0etc

ili_ili_ili

  • Newbie
  • *
  • Posts: 7
Thanks guys. I was not aware of the functionality of QueryLookupTable. I'll try it soon. About the second part of my initial post, do you recommend a particular way of establishing communication between an ASP.NET app and a MB plugin running on the same PC?

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
I dont have any experience with ASP.net - maybe using sockets and memory mapped files

boroda

  • Sr. Member
  • ****
  • Posts: 4595
memory mapped files are not supported by .Net at all (unfortunately).

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
i cant comment on ASP.net, but for the desktop .net, its under IO.MemoryMappedFiles - i did experiment with using that and it works fine.

boroda

  • Sr. Member
  • ****
  • Posts: 4595
this means that my info is outdated :) sorry. will look at it.

ili_ili_ili

  • Newbie
  • *
  • Posts: 7
Thanks a lot. You've been very helpful and quick to response.

ili_ili_ili

  • Newbie
  • *
  • Posts: 7
I tried calling Library_QueryLookupTable("Artist", "", null) with various argument values but it always returns false and the subsequent call to Library_QueryGetLookupTableValue(null) returns an empty string. I also tried to call Library_QueryFiles("") before the other calls. This one returns true but Library_QueryLookupTable still returned false. Am I missing something? MusicBee is version 3.3.7115 Portable
Last Edit: August 11, 2019, 09:53:18 PM by ili_ili_ili

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
try Library_QueryLookupTable("Artist", "count", null)

ili_ili_ili

  • Newbie
  • *
  • Posts: 7