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

namespace DAL
{
    /// <summary>
    /// 贝瓦儿歌www.beva.com
    /// </summary>
   public class Beiwa: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.beva.com/newApi/searchItemList?&callback=jQuery19101301397098509094_1606226312613&name={0}&_=1606226312618"
                , word)).Replace("\\","");
            string[] infos = CommonHelper.GetMiddleTextMultiple(src, "{\"i", "\"}");
            foreach (string info in infos)
            {
                if (info.Contains("vip\":\"Y")||!info.Contains("kan"))
                { continue; }
                Music s = new Music();
                s.Id = CommonHelper.GetMiddleText(info, "link\":\"", "\",\"vip");
                s.Artist = "贝瓦儿歌";
                s.Name = CommonHelper.GetMiddleText(info, "title\":\"", "\",\"tag");
                s.Album = CommonHelper.GetMiddleText(info, "album\":\"", "\",\"url_id");
                s.PicId = CommonHelper.GetMiddleText(info, "img_url\":\"", "\",\"img_murl");
                s.Source = "Beiwa";
                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("http://www.beva.com" + m.Id);
            string vid = CommonHelper.GetMiddleText(src,"vid\":\"","\"},");
            string json = HttpHelper.Get(string.Format(
                "http://www.beva.com/newApi/ergeAuthInfo?vid={0}&client=pc&callback=jQuery191002740938870906562_1606226477013&_=1606226477015"
                , vid)).Replace("\\", "");
            m.PicUrl = m.PicId;
            m.Url = CommonHelper.GetMiddleText(json, "high\":\"", "\"}})");
            return HttpHelper.CheckUri(m.Url);
        }
        public void GetLrc(Model.Music m)
        {
        }
    }
}
