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

namespace DAL
{

    /// <summary>
    /// 好听轻音乐网www.htqyy.com
    /// </summary>
   public class Htqyy: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.htqyy.com/home/search?wd=a"
                , word));
            string[] infos = CommonHelper.GetMiddleTextMultiple(src, "<li class=\"musicItem\">", "加入列表</a>");
            foreach (string info in infos)
            {
                Music s = new Music();
                s.Id = CommonHelper.GetMiddleText(info, "<a href=\"", "\" target=\"play");
                s.Artist = CommonHelper.Extract("<a href=\"/artist/\\d\" title=\"(.*?)\" target=\"_blank\">",info);
                s.Name = CommonHelper.GetMiddleText(info, "target=\"play\" title=\"", "\" sid");
                s.Album = CommonHelper.Extract("<a href=\"/album/\\d\" title=\"(.*?)\" target=\"_blank\">", info);
                s.PicId = CommonHelper.GetMiddleText(info, "<a href=\"https://www.itingwa.com/u/", "\" >");
                s.Source = "Htqyy";
                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 picsrc = HttpHelper.Get("https://www.itingwa.com/u/" + m.PicId);
            m.PicUrl = CommonHelper.GetMiddleText(picsrc, "<img src=\"", "\" width=");
            string src = HttpHelper.Get("https://www.itingwa.com/listen/" + m.Id);
            m.Url = CommonHelper.GetMiddleText(src, "init-data=\"", "\">");
            return HttpHelper.CheckUri(m.Url);
        }
        public void GetLrc(Model.Music m)
        {
        }
    }
}
