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

namespace DAL
{
   public class Yinyueke:IMusic
    {
        public List<Model.Music> Search(string word, int page, int num)
        {
            List<Music> list = new List<Music>();
            string src = HttpHelper.Get(string.Format("http://www.yinyueke.net/?keyword={0}&page={1}", word, page));
            string[] infos = CommonHelper.GetMiddleTextMultiple(src, "手机浏览器扫描下载", "</a></span></div>");
            foreach (string info in infos)
            {
                Music s = new Music();
                s.Id = CommonHelper.GetMiddleText(info, "<div class=\"thumb_t\"><a href=\"", "html") + "html";
                string[] temp=CommonHelper.GetMiddleText(info, "html\">", "</a></div>").Split('-');
                s.Artist = temp[0].Trim();
                s.Name = temp[1].Trim();
                //s.Album = CommonHelper.GetMiddleText(info, "album\":\"", "\",\"pic_id");
                s.PicId = CommonHelper.GetMiddleText(info, "<img src=\"", "\"  /></a>");
                s.Source = "Yinyueke";
                s.ToString();
                list.Add(s);
            }
            return list;
        }
        public List<Model.Music> SearchCollection(string id)
        {
            List<Music> list = new List<Music>();
            return list;
        }
        public bool GetData(Model.Music m)
        {
            string src = HttpHelper.Get( m.Id);
            m.PicUrl = m.PicId;
            m.Url = CommonHelper.GetMiddleText(src, "qr.liantu.com/api.php?text=", "?attname");
            return HttpHelper.CheckUri(m.Url);
        }
        public void GetLrc(Model.Music m)
        {
        }

    }
}
