Exemple #1
0
        public static void Test_MatchesAtLeastOneWord()
        {
            Release r = new Release();

            r.Artist = "Artist No. 1";
            r.Title  = "Title Of Release";

            UnitTest.Test(MultipleItemChooser.MatchesAtLeastOneWord(r, @"d:\Some Unknown Directory\") == false);
            UnitTest.Test(MultipleItemChooser.MatchesAtLeastOneWord(r, @"d:\no 1\") == false);
            UnitTest.Test(MultipleItemChooser.MatchesAtLeastOneWord(r, @"d:\artist\") == true);
        }
Exemple #2
0
        public static Release QueryRelease(
            IEnumerable <int> lengths,
            DirectoryInfo dirInfo,
            MultipleItemChooser.MultipleChoiseHeuristic heuristic)
        {
            FreedbAPI freedb = new FreedbAPI();

            IEnumerable <int> offsets = DiscID.MakeOffsets(lengths);
            uint   discid             = DiscID.DiscId(offsets);
            string freeDbQuery        = DiscID.FreedbQuery(discid, offsets);

            var result = freedb.Query(freeDbQuery);

            if (result.Code == FreedbAPI.ResponseCodes.CODE_200_ExactMatchFound ||
                result.Code == FreedbAPI.ResponseCodes.CODE_211_InexactMatchFoundListFollows ||
                result.Code == FreedbAPI.ResponseCodes.CODE_210_OkOrMultipleExactMatches)
            {
                MultipleItemChooser chooser   = new MultipleItemChooser(dirInfo.Name, discid, result.Value, heuristic);
                Release             preferred = chooser.ChooseQuery();

                bool found = !Object.ReferenceEquals(preferred, null);

                if (!found && result.Value.Count() > 0)
                {
                    LoggerWriter.WriteLine(Tokens.Info, "Multiple matches found but heuristic could not decide,");
                    LoggerWriter.WriteLine(Tokens.Info, "it might help to set the heuristic to fuzzy or rename");
                    LoggerWriter.WriteLine(Tokens.Info, "the folders so that they contain the artist name.");
                }

                if (found)
                {
                    FreedbAPI.Result <Release> disc = freedb.Read(preferred);

                    if (disc.Code == FreedbAPI.ResponseCodes.CODE_210_OkOrMultipleExactMatches)
                    {
                        return(disc.Value);
                    }
                }
            }

            return(null);
        }