Esempio n. 1
0
 /// <summary>
 /// 异步返回lrcinfo集合
 /// </summary>
 /// <param name="artist"></param>
 /// <param name="title"></param>
 /// <param name="filesavepath"></param>
 /// <param name="misicid"></param>
 /// <returns></returns>
 public ObservableCollection <ILrcSercherInfoItem> GetLrcInfoSercherList(string artist, string title, string filesavepath, string misicid = null)
 {
     SercherResultList.Clear();
     SercherName = title;
     if (misicid != null)
     {
         SercherResultList.Add(
             new LrcSercher.NetCloudLrcInfoz()
         {
             Id       = misicid,
             Title    = title,
             LrcUri   = GetLrcUri(misicid),
             Artist   = artist,
             FilePath = filesavepath
         });
     }
     else
     {
         try
         {
             GetMusicIds(artist + " - " + title);
         }
         catch (WebException ex) {
             MessageBox.Show(ex.Message);
         }
     }
     return(SercherResultList);
 }
Esempio n. 2
0
        /// <summary>
        /// 获取网易云音乐的歌曲Id集合,并返回到SercherResultList集合中
        /// </summary>
        /// <param name="SercherKeys">通过歌曲名在网络上搜索Id</param>
        /// <param name="Id">如果已经拥有歌曲ID</param>
        /// <returns></returns>
        private void GetMusicIds(string SercherKeys, string Id = null)
        {
            var CloudMusicApi = new NeteaseMusicAPI();
            var res           = CloudMusicApi.Search(SercherKeys, type: NeteaseMusicAPI.SearchType.Song).Result;

            if (res.Songs == null)
            {
                return;
            }
            var songs = res.Songs.Select(x => {
                return(new NetCloudLrcInfoz
                {
                    Artist = string.Join(",", x.Ar.Select(y => y.Name)),
                    Id = x.Id.ToString(),
                    Title = x.Name,
                    LrcUri = GetLrcUri(x.Id.ToString())
                });
            });

            foreach (var i in songs)
            {
                SercherResultList.Add(i);
            }
        }