using Helper;
using IDAL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAL
{
    /// <summary>
    /// 伴奏中国www.banzouzhongguo.com
    /// </summary>
    public class BZZG : IMusic
    {
        public List<Music> Search(string word, int page, int num)
        {
            List<Music> list = new List<Music>();
            string src = HttpHelper.Get(string.Format(
                "http://www.banzouzhongguo.com/index.php/dance/so/key?key={0}&sort=&type=&p={1}"
                , word, page));
            string[] infos = CommonHelper.GetMiddleTextMultiple(src, "<td><div class=\"search-number\">", "<td><div class=\"search-price\">");
            foreach (string i in infos)
            {
                Music s = new Music();
                s.Artist = "伴奏中国";
                s.Name = CommonHelper.GetMiddleText(i, "target=\"p\">", "</a></span>");
                s.Id = CommonHelper.GetMiddleText(i, "<span>", "</span></div></td>");
                s.Source = "BZZG";
                list.Add(s);
            }
            return list;
        }

        public List<Music> SearchCollection(string id)
        {
            throw new NotImplementedException();
        }

        public bool GetData(Music m)
        {
            m.PicUrl = "http://www.banzouzhongguo.com/templet/skins/img/40d03c_190x190.png";
            string src = HttpHelper.Get("http://www.banzouzhongguo.com/index.php/dance/play/" + m.Id);
            m.Url = CommonHelper.GetMiddleText(src, "<audio src=\"", "\" controls=\"controls");
            return HttpHelper.CheckUri(m.Url);
        }

        public void GetLrc(Music m)
        {
            throw new NotImplementedException();
        }
    }
}
