NeteaseCloudMusicApi 3.21.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package NeteaseCloudMusicApi --version 3.21.0                
NuGet\Install-Package NeteaseCloudMusicApi -Version 3.21.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NeteaseCloudMusicApi" Version="3.21.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NeteaseCloudMusicApi --version 3.21.0                
#r "nuget: NeteaseCloudMusicApi, 3.21.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NeteaseCloudMusicApi as a Cake Addin
#addin nuget:?package=NeteaseCloudMusicApi&version=3.21.0

// Install NeteaseCloudMusicApi as a Cake Tool
#tool nuget:?package=NeteaseCloudMusicApi&version=3.21.0                

NeteaseCloudMusicApi

C#版 网易云音乐 API

简介

本项目翻译自Node.js项目Binaryify/NeteaseCloudMusicApi

更新与原项目同步

使用方式请参考原项目文档,参数与返回结果与原项目完全一致

本项目需要 .NET Standard 2.0 (.NET Framework 4.6.1+ / .NET Core 2.0+) ,可跨平台使用

样例

实例化API

using (CloudMusicApi api = new CloudMusicApi()) {
	// code here
}

完整样例-显示"我喜欢的音乐"

using (CloudMusicApi api = new CloudMusicApi()) {
	try {
		bool isOk;
		JObject json;
		int uid;
		int[] trackIds;

		/******************** 登录 ********************/

		do {
			Dictionary<string, string> queries;
			string account;
			bool isPhone;

			queries = new Dictionary<string, string>();
			Console.WriteLine("请输入账号(邮箱或手机)");
			account = Console.ReadLine();
			isPhone = Regex.Match(account, "^[0-9]+$").Success;
			queries[isPhone ? "phone" : "email"] = account;
			Console.WriteLine("请输入密码");
			queries["password"] = Console.ReadLine();
			(isOk, json) = await api.RequestAsync(isPhone ? CloudMusicApiProviders.LoginCellphone : CloudMusicApiProviders.Login, queries);
			if (!isOk)
				Console.WriteLine("登录失败,账号或密码错误");
		} while (!isOk);
		Console.WriteLine("登录成功");
		Console.WriteLine();

		/******************** 登录 ********************/

		/******************** 获取账号信息 ********************/

		(isOk, json) = await api.RequestAsync(CloudMusicApiProviders.LoginStatus, CloudMusicApi.EmptyQueries);
		if (!isOk)
			throw new ApplicationException($"获取账号信息失败: {json}");
		uid = (int)json["profile"]["userId"];
		Console.WriteLine($"账号ID: {uid}");
		Console.WriteLine($"账号昵称: {json["profile"]["nickname"]}");
		Console.WriteLine();

		/******************** 获取账号信息 ********************/

		/******************** 获取我喜欢的音乐 ********************/

		(isOk, json) = await api.RequestAsync(CloudMusicApiProviders.UserPlaylist, new Dictionary<string, string> { { "uid", uid.ToString() } });
		if (!isOk)
			throw new ApplicationException($"获取用户歌单失败: {json}");
		(isOk, json) = await api.RequestAsync(CloudMusicApiProviders.PlaylistDetail, new Dictionary<string, string> { { "id", json["playlist"][0]["id"].ToString() } });
		if (!isOk)
			throw new ApplicationException($"获取歌单详情失败: {json}");
		trackIds = json["playlist"]["trackIds"].Select(t => (int)t["id"]).ToArray();
		(isOk, json) = await api.RequestAsync(CloudMusicApiProviders.SongDetail, new Dictionary<string, string> { { "ids", string.Join(",", trackIds) } });
		if (!isOk)
			throw new ApplicationException($"获取歌曲详情失败: {json}");
		Console.WriteLine($"我喜欢的音乐 ({trackIds.Length} 首):");
		foreach (JObject song in json["songs"])
			Console.WriteLine($"{string.Join(",", song["ar"].Select(t => t["name"]))} - {song["name"]}");
		Console.WriteLine();

		/******************** 获取我喜欢的音乐 ********************/

		/******************** 退出登录 ********************/

		(isOk, json) = await api.RequestAsync(CloudMusicApiProviders.Logout, CloudMusicApi.EmptyQueries);
		if (!isOk)
			throw new ApplicationException($"退出登录失败: {json}");
		Console.WriteLine("退出登录成功");
		Console.WriteLine();

		/******************** 退出登录 ********************/
	}
	catch (Exception ex) {
		Console.WriteLine(ex);
	}
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on NeteaseCloudMusicApi:

Repository Stars
wwh1004/NLyric
网易云音乐歌词自动搜索下载
Version Downloads Last updated
3.25.3.10000 1,314 2/22/2021
3.25.3.9999 453 2/20/2021
3.25.3 737 2/8/2020
3.22.4 586 10/3/2019
3.22.0 700 8/28/2019
3.21.1 533 8/21/2019
3.21.0 519 8/21/2019