Exemplo n.º 1
0
        private async void doSearch(string query, SearchResultType searchType)
        {
            Dispatcher.BeginInvoke(new Action(() =>
            {
                _grid_cover.Visibility = Visibility.Visible;
            })).Wait();

            AllMusicApiAgent            agent = new AllMusicApiAgent();
            IEnumerable <ISearchResult> results;

            if (searchType == SearchResultType.Artist)
            {
                results = await agent.Search <ArtistResult>(query, -1);
            }
            else
            {
                results = await agent.Search <AlbumResult>(query, -1);
            }

            Dispatcher.BeginInvoke(new Action(() =>
            {
                var viewStyleName = searchType == SearchResultType.Artist ?
                                    "GridViewArtists" : "GridViewAlbums";

                _listView_results.View        = (ViewBase)Resources[viewStyleName];
                _listView_results.ItemsSource = results;
                _grid_cover.Visibility        = Visibility.Hidden;
            }));
        }
Exemplo n.º 2
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));
            }
        }
Exemplo n.º 3
0
        public async Task TestSearchSong()
        {
            var api    = new AllMusicApiAgent();
            var result = await api.Search <SongResult>("the Great gig in the sky", 10);

            Assert.AreEqual(10, result.Count);

            var r = result[1];

            Assert.AreEqual("The Great Gig in the Sky", r.Title);
            Assert.AreEqual("http://www.allmusic.com/song/the-great-gig-in-the-sky-mt0036036156", r.Url);
            Assert.AreEqual("the-great-gig-in-the-sky-mt0036036156", r.ID);

            Assert.AreEqual(3, r.Performers.Count);
            var p = r.Performers[0];

            Assert.AreEqual("The Flaming Lips", p.Name);
            Assert.AreEqual("http://www.allmusic.com/artist/the-flaming-lips-mn0000065590", p.Url);
            Assert.AreEqual("the-flaming-lips-mn0000065590", p.ID);

            Assert.AreEqual(2, r.Composers.Count);
            var c = r.Composers[0];

            Assert.AreEqual("Roger Waters", c.Name);
            Assert.AreEqual("http://www.allmusic.com/artist/roger-waters-mn0000254556", c.Url);
            Assert.AreEqual("roger-waters-mn0000254556", c.ID);
        }
Exemplo n.º 4
0
        public async Task TestSearchAlbum()
        {
            var api    = new AllMusicApiAgent();
            var result = await api.Search <AlbumResult>("nevermind", 10);

            Assert.AreEqual(10, result.Count);

            var r = result[0];

            Assert.AreEqual("Nevermind", r.Title);
            Assert.AreEqual("http://www.allmusic.com/album/nevermind-mw0000185616", r.Url);
            Assert.AreEqual("nevermind-mw0000185616", r.ID);
            Assert.AreEqual("Nirvana", r.Artist);
            Assert.AreEqual("http://www.allmusic.com/artist/nirvana-mn0000357406", r.ArtistUrl);
            Assert.AreEqual("nirvana-mn0000357406", r.ArtistId);
            Assert.AreEqual("1991", r.Year);
            Assert.AreEqual("Pop/Rock", r.Genre);
        }
Exemplo n.º 5
0
        public async Task TestSearchArtist()
        {
            var api    = new AllMusicApiAgent();
            var result = await api.Search <ArtistResult>("dido", 30);

            Assert.AreEqual(30, result.Count);

            var r0  = result[0];
            var r20 = result[19];

            Assert.AreEqual("Dido", r0.Artist);
            Assert.AreEqual("http://www.allmusic.com/artist/dido-mn0000217344", r0.Url);
            Assert.AreEqual("dido-mn0000217344", r0.ID);
            Assert.AreEqual("Pop/Rock", r0.Genre);
            Assert.AreEqual("1990s - 2010s", r0.Decades);

            Assert.AreEqual("Irocc & Dido Brown", r20.Artist);
            Assert.AreEqual("http://www.allmusic.com/artist/irocc-dido-brown-mn0002503861", r20.Url);
            Assert.AreEqual("irocc-dido-brown-mn0002503861", r20.ID);
            Assert.AreEqual("Reggae", r20.Genre);
            Assert.AreEqual("Unknown Decade", r20.Decades);
        }