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>
    /// 5nd www.5nd.com
    /// </summary>
    public class _5nd : IMusic
    {
        public bool GetData(Music m)
        {
            string src = HttpHelper.Get(string.Format("http://www.5nd.com/ting/{0}.html", m.Id), Encoding.Default);
            m.PicUrl = CommonHelper.GetMiddleText(src, "_album\"><img src=\"", "\" width");
            m.Url = "http://mpge.5nd.com/" + CommonHelper.GetMiddleText(src, "var urlht = \"", "\";</script></div>");
            return HttpHelper.CheckUri(m.Url);
        }
        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public List<Music> Search(string word, int page, int num)
        {
            List<Music> list = new List<Music>();
            string src = HttpHelper.Get(string.Format("http://so.5nd.com/s_{0}_{1}", word, page), Encoding.Default);
            string[] infos = CommonHelper.GetMiddleTextMultiple(src, "<i><input", "加入到我的歌单");
            foreach (string i in infos)
            {
                Music s = new Music();
                s.Id = CommonHelper.GetMiddleText(i, "data-id=\"", "\" type=\"checkbox");
                s.Artist = CommonHelper.GetMiddleText(i, ".htm\">", "</a></p>");
                s.Name = CommonHelper.GetMiddleText(i, ".html\">", "</a></p>");
                s.Source = "_5nd";
                s.ToString();
                list.Add(s);
            }
            return list;
        }
        public List<Music> SearchCollection(string id)
        {
            throw new NotImplementedException();
        }
        public void GetLrc(Music m)
        {
        }
    }
}
