public static int CalculateMatchScore(AlbumModel model, MusicBrainzAlbumsResultRow result)
        {
            int score = 0;

            if (String.Equals(model.Name, result.Name, StringComparison.OrdinalIgnoreCase))
                score += 3;

            if (String.Equals(model.Artist, result.Artist, StringComparison.OrdinalIgnoreCase))
                score += 2;

            if (result.Score > 90)
                score += 2;

            if (model.SongsCount == result.NumberOfTracks)
            {
                score += 2;
            }
            else
            {
                if (Math.Abs(model.SongsCount - result.NumberOfTracks) < 2)
                    score += 1;
                else
                    score -= 1;
            }

            return score;
        }
Пример #2
0
        public async Task<String> GetAlbumArtUrl(MusicBrainzAlbumsResultRow fromModel)
        {
            HttpClient client = new HttpClient();

            var stringBody = await client.GetStringAsync(fromModel.Url);

            client.Dispose();

            HtmlDocument document = HtmlDocumentFactory.LoadFromString(stringBody);

            string imgUrl = string.Empty;

            var coverArtDiv =
                document.DocumentNode.Descendants("div")
                    .FirstOrDefault(d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("cover-art"));

            if (coverArtDiv != null)
            {
                imgUrl = coverArtDiv.Descendants("a").First().Attributes["href"].Value;
            }

            return imgUrl;
        }
 public static int CalculateScoreFromRules(AlbumModel model, MusicBrainzAlbumsResultRow result)
 {
     return Rules.Sum(rule => rule(model, result));
 }