Author Topic: album cover plug have some problems  (Read 6578 times)

tumuyan

  • Newbie
  • *
  • Posts: 12
I'm working on a plugin for getting album covers. Currently there are some problems.
1. The cover url is correctly. But at musicbee is showing that the search cover doesn't match the results.
I don't have experience in developing C# software, the following code to get the image and convert it to byte[] is copy from google. is there something wrong?
2. I have set the plug-in name, in the settings interface shows normal, but the search interface shows "plug" not display the correct name. Why and how to change it?
3. Is there an open source album cover plug-in I can refer to? I didn't find it on github.


Code
  

        public PluginInfo Initialise(IntPtr apiInterfacePtr)
        {
            mbApiInterface = new MusicBeeApiInterface();
            mbApiInterface.Initialise(apiInterfacePtr);
            about.PluginInfoVersion = PluginInfoVersion;
            about.Name = "Douban Music";
            about.Description = "Get information from douban music";
            about.Author = "Tumuyan";
            about.TargetApplication = "";   //  the name of a Plugin Storage device or panel header for a dockable panel
            about.Type = PluginType.ArtworkRetrieval;
            about.VersionMajor = 1;  // your plugin version
            about.VersionMinor = 0;
            about.Revision = 1;
            about.MinInterfaceVersion = MinInterfaceVersion;
            about.MinApiRevision = MinApiRevision;
            about.ReceiveNotifications = (ReceiveNotificationFlags.PlayerEvents | ReceiveNotificationFlags.TagEvents);
            about.ConfigurationPanelHeight = 0;   // height in pixels that musicbee should reserve in a panel for config settings. When set, a handle to an empty panel will be passed to the Configure function
            return about;
        }

...

        public string[] GetProviders()
        {

            string[] s = { "Douban" };
            return s;
        }

public string RetrieveArtwork(string sourceFileUrl, string albumArtist, string album, string provider){
      // url builder is removed to debug    ....

              string url = "https://img1.doubanio.com/view/subject/public/s28790429.jpg";

            var request2 = (HttpWebRequest)WebRequest.Create(url);

            byte[] bytes;
            using (Stream stream = request2.GetResponse().GetResponseStream())
            {
                using (MemoryStream mstream = new MemoryStream())
                {
                    int count = 0;
                    byte[] buffer = new byte[1024];
                    int readNum = 0;
                    while ((readNum = stream.Read(buffer, 0, 1024)) > 0)
                    {
                        count = count + readNum;
                        mstream.Write(buffer, 0, readNum);
                    }
                    mstream.Position = 0;
                    using (BinaryReader br = new BinaryReader(mstream))
                    {
                        bytes = br.ReadBytes(count);
                    }
                }
            }
            return Convert.ToBase64String(bytes);

        }

Last Edit: October 10, 2020, 09:13:51 PM by tumuyan

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 33477

tumuyan

  • Newbie
  • *
  • Posts: 12
i have upload a screenshot. it is strange. actualy the plug doesn‘t shows this image but shows not match.
and the plug name is not same as I set, only shows "plug"

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 33477
did you change your code to return the url of the artwork? - the code you provided returns the decoded bitmap data which is not what musicbee expects

tumuyan

  • Newbie
  • *
  • Posts: 12
Oh, it's working fine now.
I was misled by the comments in the sample project.
The function only need return the url, I mistakenly thought I needed to return a encode bin file.

Code

        // return Base64 string representation of the artwork binary data from the requested provider
        // only required if PluginType = ArtworkRetrieval
        // return null if no artwork is found


Now only the plug-in name shows "plugin" not defined name

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 33477

tumuyan

  • Newbie
  • *
  • Posts: 12
hi steven,
I find that the find artwork panel could only show only one  artwork plugin search result ,no matter how many plugins ars applied. and the result resource is named as plugin

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 33477
Yes thats all that is currently supported - as long as you return all the artwork sources in the GetProviders() function, then the user can prioritise the providers and the first artwork in order of that priority is displayed.

tumuyan

  • Newbie
  • *
  • Posts: 12
I don't understand the current design. They are also artwork providers, why do user-added plugins only share one position in the search panel and named as “plug-in", but the original plugins have separate position and have name?
I think that although in most cases the providers download artworks automatically,  sometimes user needs to show all the results from the providers and pick the most suitable one by himself.
Due to my somewhat poor network, I found that the search for Artwork seems to be in a single thread, with the first provide getting the image url then the latter provider starts running. Wouldn't you consider changing to a multi-threaded operation to speed up the search action?