using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IDAL;
using Model;
using Helper;
using System.Text.RegularExpressions;
//0类名;1搜索api;2-3分离信息字符串左右部分;4-8歌曲基本信息
namespace DAL
{
    /// <summary>
    /// www.dj169.com
    /// </summary>
    public class DJ169 : IMusic
    {
        public List<Music> Search(string word, int page, int num)
        {
            List<Music> list = new List<Music>();
            string src = HttpHelper.Get(string.Format("https://www.dj169.com/search/?key={0}&page={1}.html",  word,page,num));
            string[] infos = CommonHelper.GetMiddleTextMultiple(src, "<input type=\"checkbox", "</i></em></li>");
            foreach (string i in infos)
            {
                Music s = new Music();
                s.Id = CommonHelper.Extract("<a href=\"/dj/(.*?).html",i);
                s.Name = CommonHelper.Extract("</span>(.*?)</a>",i);
                s.Album = CommonHelper.Extract("",i);
                s.Artist = CommonHelper.Extract("target=\"u\">(.*?)</a></p>",i);
                s.PicId = CommonHelper.Extract("",i);
                s.Source = "DJ169";
                s.ToString();
                list.Add(s);
            }
            return list;
        }
        public List<Model.Music> SearchCollection(string id)
        {
            throw new NotImplementedException("该平台暂未支持歌单解析");
        }
        public bool GetData(Music m)
        {
            string src = HttpHelper.Get(string.Format("https://www.dj169.com/dj/{0}.html", m.Id));
            m.Url = CommonHelper.Extract("danceFilePath = \"(.*?)\",wname",src);
            return HttpHelper.CheckUri(m.Url);
        }
        public void GetLrc(Music m)
        {
            throw new NotImplementedException();
        }
    }
}