How to get information from musicbrainz music file

Can someone tell me how to get track information from MusicBrainz from an audio file (mp3, wav, wma, ogg, etc.) using an audio fingerprint. I use the MusicBrainz Sharp library, but any other library is fine.

I saw that you should use the libofa library so that you cannot use MusicBrainz Sharp to get puid from the audio file, but I cannot figure out how to use libofa with C #.

Please show some examples and code snippets to help me, because I cannot find them anywhere.

Thanks in advance!

+3
source share
2 answers

, libofa, , PUID, - genpuid, AmpliFIND , PUID.

, - , , IDv3, . Bitbucket.

libofa DllImport, wrapped genpuid (.. XML), , libofa. , MusicBrainz, MusicBrainz Sharp.

, , , , .:) , , .

: , , , decoder, , , SO. , genpuid fingerprinter, / guid, libofa fingerprinter .

+1

genpuid, .

    private string GetPUID(string fileName)
    {

        Process p;
        ProcessStartInfo si;
        string outRow;
        string puidReturned;

        string gendPuidPath = @"C:\Program Files\genpuid\genpuid.exe";
        string gendPuidKey = "your key here";
        System.Text.RegularExpressions.Regex puidRex = new System.Text.RegularExpressions.Regex( @"puid: (\S+)" ); // sample:  puid: 3c62e009-ec93-1c0f-e078-8829e885df67
        System.Text.RegularExpressions.Match m;

        if (File.Exists(gendPuidPath))
        {
            try
            {
                si = new ProcessStartInfo(gendPuidPath, gendPuidKey + " \"" + fileName + "\"");
                si.RedirectStandardOutput = true;
                si.UseShellExecute = false;

                p = new Process();
                p.StartInfo = si;
                p.Start();

                puidReturned = "";
                while ((outRow = p.StandardOutput.ReadLine()) != null)
                {
                    m = puidRex.Match(outRow);
                    if (m.Success)
                        puidReturned = m.Groups[1].Value;
                    Debug.WriteLine(outRow);
                }
                p.WaitForExit();
                p.Close();

                return puidReturned;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                Debug.WriteLine(ex.StackTrace);
                throw new Exception("Unexpexted Error obtaining PUID for file: " + fileName, ex);
            }
        }
        else
        {
            Debug.WriteLine("genpuid.exe not found");
            return "";
        }
    }
0

Source: https://habr.com/ru/post/1783079/


All Articles