using System.Collections.Generic;
using System.Linq;
using MusicMetaTagger.Client.AllMusicGuide.RemoteDataAccess.Client;
using MusicMetaTagger.Client.AllMusicGuide.RemoteDataAccess.Parser;
using MusicMetaTagger.Core.Model;

namespace MusicMetaTagger.Client.AllMusicGuide.RemoteDataAccess.Scraper
{
	public class ArtistDiscographyScraper : IScraper<List<ArtistDiscography>>
	{
		public List<ArtistDiscography> Scrape(string artistId)
		{
			var parser = new ArtistDiscographyPageParser();
			var xmlClients =
				new IXmlClientBase[]
					{
						new ArtistDiscographyAlbumPageClient(),
						new ArtistDiscographyCompilationPageClient(),
						new ArtistDiscographyEpSinglesPageClient()
					};
			return xmlClients.Select(c => c.Read(artistId)).SelectMany(parser.Parse).ToList();
		}
	}
}