using Helper;
using IDAL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;
namespace DAL
{
    /// <summary>
    /// 九酷音乐www.9ku.com
    /// </summary>
    public class _9ku : IMusic
    {
        public List<Music> Search(string word, int page, int num)
        {
            List<Music> list = new List<Music>();
            string src = HttpHelper.Get(string.Format("http://baidu.9ku.com/song/?key={0}", word));
            string[] infos = CommonHelper.GetMiddleTextMultiple(src, "<li><input  style=\"display:none", "</a></li>");
            foreach (string i in infos)
            {
                Music s = new Music();
                s.Id = CommonHelper.GetMiddleText(i, "value=\"", "@\" name");
                s.Name = CommonHelper.GetMiddleText(i, "htm\">", "</a><a href=\"http://www.9ku.com");
                s.Artist = CommonHelper.GetMiddleText(i, "singerName\" target=\"_blank\">", "</a>").Trim();
                s.Source = "_9ku";
                list.Add(s);
            }
            return list;
        }
        public List<Music> SearchCollection(string id)
        {
            throw new NotImplementedException();
        }
        public bool GetData(Music m)
        {
            m.Url = string.Format("http://mp3.9ku.com/m4a/{0}.m4a",m. Id);
            return HttpHelper.CheckUri(m.Url);
        }
        public void GetLrc(Music m)
        {
        }
    }
}

