Exemple #1
0
        private async Task <IGmtMedia> GetTags(TrackFile file, SearchResultType type)
        {
            AllMusicApiAgent agent = new AllMusicApiAgent();

            IEnumerable <ISearchResult> results;

            if (type == SearchResultType.Album)
            {
                results = await agent.Search <AlbumResult>(file.Album, 100);
            }
            else
            {
                results = await agent.Search <ArtistResult>(file.Artist, 100);
            }

            ISearchResult mainResult = results.GetBestResult(file, Options.AlgorithmTolerance);

            if (mainResult == null)
            {
                return(null);
            }

            if (mainResult.ResultType == SearchResultType.Artist)
            {
                return(await agent.GetArtist(mainResult.ID));
            }
            else
            {
                return(await agent.GetAlbum(mainResult.ID));
            }
        }
Exemple #2
0
        private async void getMediaData(ISearchResult result)
        {
            Dispatcher.BeginInvoke(new Action(() =>
            {
                _grid_cover.Visibility = Visibility.Visible;
            })).Wait();


            AllMusicApiAgent agent = new AllMusicApiAgent();

            IGmtMedia mediaData;

            if (result.ResultType == SearchResultType.Album)
            {
                mediaData = await agent.GetAlbum(result.ID);
            }
            else
            {
                mediaData = await agent.GetArtist(result.ID);
            }

            Dispatcher.BeginInvoke(new Action(() =>
            {
                _grid_cover.Visibility = Visibility.Hidden;
                OnImport?.Invoke(this, mediaData);
            }));
        }
Exemple #3
0
        public async Task TestGetArtist()
        {
            var agent  = new AllMusicApiAgent();
            var artist = await agent.GetArtist("pink-floyd-mn0000346336");

            Assert.IsNotNull(artist);

            Assert.AreEqual("Pink Floyd", artist.Name);

            string bio = "One of the most predominant and celebrated rock" +
                         " bands of all time, prog- and space-rock legends, known " +
                         "for superlative musicianship.";

            Assert.AreEqual(bio, artist.Tagline);
            Assert.AreEqual(1965, artist.Birth);

            Assert.AreEqual(6, artist.Members.Count);
            Assert.AreEqual(0, artist.MemberOf.Count);

            var m = artist.Members[0];

            Assert.AreEqual("http://www.allmusic.com/artist/david-gilmour-mn0000582930", m.Url);
            Assert.AreEqual("david-gilmour-mn0000582930", m.ID);
            Assert.AreEqual("David Gilmour", m.Name);

            Assert.AreEqual(9, artist.Genres.Count);
            Assert.AreEqual("Avant-Garde", artist.Genres[1]);
            Assert.AreEqual("Prog-Rock", artist.Genres[5]);

            Assert.AreEqual(44, artist.Moods.Count);
            Assert.IsTrue(artist.Moods.Contains("Enigmatic"));
            Assert.IsTrue(artist.Moods.Contains("Angst-Ridden"));
            Assert.IsTrue(artist.Moods.Contains("Sad"));
            Assert.IsTrue(artist.Moods.Contains("Bleak"));

            Assert.AreEqual(17, artist.Themes.Count);
            Assert.IsTrue(artist.Themes.Contains("Myths & Legends"));
            Assert.IsTrue(artist.Themes.Contains("Starry Sky"));
            Assert.IsTrue(artist.Themes.Contains("Open Road"));
            Assert.IsTrue(artist.Themes.Contains("Politics/Society"));

            Assert.AreEqual(18, artist.Albums.Count);

            var album = artist.Albums.Last();

            Assert.AreEqual(2014, album.Year);
            Assert.AreEqual("The Endless River", album.Title);
            Assert.AreEqual("http://www.allmusic.com/album/the-endless-river-mw0002758626", album.Url);
            Assert.AreEqual("the-endless-river-mw0002758626", album.ID);

            Assert.AreEqual(42, artist.SimiliarTo.Count);
            Assert.AreEqual(20, artist.InfluencedBy.Count);
            Assert.AreEqual(142, artist.FollowedBy.Count);
            Assert.AreEqual(4, artist.AssociatedWith.Count);
        }