/// <summary> /// 根据解析出来的模型进行下载 /// </summary> /// <param name="basicModel"></param> /// <returns></returns> public async Task <bool> DownloadAsync(BasicMusicInfoModel basicModel) { return(await Task.Run(async() => { var obj = (QqMusicInfoModel)basicModel; try { OnBeforeDownload?.Invoke($"{basicModel.SongName}_{basicModel.SingerName}"); var vkeyInfo = await GetVkeyInfo(obj.SongId, obj.MediaMid); var url = new Uri(string.Format(_downloadUrl, obj.MediaMid, vkeyInfo.data.items[0].vkey)); var saveName = $"{obj.SongName}_{obj.SingerName}"; await _requests.SaveFileAsync(url, $"{saveName}.m4a"); OnAfterDownload?.Invoke($"{basicModel.SongName}_{basicModel.SingerName}"); return true; } catch (Exception e) { OnDownloadError?.Invoke(e, $"{basicModel.SongName}_{basicModel.SingerName}"); return false; } })); }