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

ili_ili_ili

  • Newbie
  • *
  • Posts: 6
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

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

ili_ili_ili

  • Newbie
  • *
  • Posts: 6
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
  • Hero Member
  • *****
  • Posts: 29631
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: 6
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
  • Hero Member
  • *****
  • Posts: 29631
I dont have any experience with ASP.net - maybe using sockets and memory mapped files

boroda

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

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 29631
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

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

ili_ili_ili

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

ili_ili_ili

  • Newbie
  • *
  • Posts: 6
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
  • Hero Member
  • *****
  • Posts: 29631
try Library_QueryLookupTable("Artist", "count", null)

ili_ili_ili

  • Newbie
  • *
  • Posts: 6