diff --git a/DGJv3/DGJv3.csproj b/DGJv3/DGJv3.csproj
index 4e767d9..0455251 100644
--- a/DGJv3/DGJv3.csproj
+++ b/DGJv3/DGJv3.csproj
@@ -9,9 +9,10 @@
Properties
DGJv3
DGJv3
- v4.6.2
+ v4.6.1
512
{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+
true
@@ -69,7 +70,7 @@
..\packages\NAudio.1.8.4\lib\net35\NAudio.dll
- ..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll
+ ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll
@@ -77,7 +78,20 @@
..\packages\Scriban.Signed.1.2.5\lib\net40\Scriban.dll
+
+ ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll
+
+
+ ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll
+
+
+
+ ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll
+
+
+ ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll
+
diff --git a/DGJv3/InternalModule/LwlApiBaseModule.cs b/DGJv3/InternalModule/LwlApiBaseModule.cs
index 0d4930e..827f1fd 100644
--- a/DGJv3/InternalModule/LwlApiBaseModule.cs
+++ b/DGJv3/InternalModule/LwlApiBaseModule.cs
@@ -16,8 +16,8 @@ internal class LwlApiBaseModule : SearchModule
protected void SetServiceName(string name) => ServiceName = name;
private const string API_PROTOCOL = "https://";
- private const string API_HOST = "api.lwl12.com";
- private const string API_PATH = "/music/";
+ private const string API_HOST = "v1.itooi.cn";
+ private const string API_PATH = "/";
protected const string INFO_PREFIX = "";
protected const string INFO_AUTHOR = "Genteure & LWL12";
@@ -44,15 +44,7 @@ protected override string GetDownloadUrl(SongItem songInfo)
if (dlurlobj["code"].ToString() == "200")
{
- if (dlurlobj["result"] is JObject)
- {
- dlurlobj = (JObject)dlurlobj["result"];
- }
- else
- {
- dlurlobj = JObject.Parse(dlurlobj["result"].Value());
- }
- return dlurlobj["url"].ToString();
+ return $"{API_PROTOCOL}{API_HOST}{API_PATH}{ServiceName}/url?id={songInfo.SongId}";
}
else
{
@@ -71,29 +63,7 @@ protected override string GetLyricById(string Id)
{
try
{
- JObject lobj = JObject.Parse(Fetch(API_PROTOCOL, API_HOST, API_PATH + ServiceName + $"/lyric?id={Id}"));
- if (lobj["result"] is JObject)
- {
- lobj = (JObject)lobj["result"];
- }
- else
- {
- lobj = JObject.Parse(lobj["result"].Value());
- }
- if (lobj["lwlyric"] != null)
- {
- return lobj["lwlyric"].ToString();
- }
- else if (lobj["tlyric"] != null)
- {
- return lobj["tlyric"].ToString();
- }
- else if (lobj["lyric"] != null)
- {
- return lobj["lyric"].ToString();
- }
- else
- { Log("歌词获取错误(id:" + Id + ")"); }
+ return Fetch(API_PROTOCOL, API_HOST, API_PATH + ServiceName + $"/lrc?id={Id}");
}
catch (Exception ex)
@@ -108,11 +78,11 @@ protected override List GetPlaylist(string keyword)
{
List songInfos = new List();
- JObject playlist = JObject.Parse(Fetch(API_PROTOCOL, API_HOST, API_PATH + ServiceName + $"/playlist?id={HttpUtility.UrlEncode(keyword)}"));
+ JObject playlist = JObject.Parse(Fetch(API_PROTOCOL, API_HOST, API_PATH + ServiceName + $"/search?id={HttpUtility.UrlEncode(keyword)}&type=songList&pageSize=5&page=0"));
if (playlist["code"]?.ToObject() == 200)
{
- List result = (playlist["result"] as JArray).ToList();
+ List result = (playlist["data"]["playlists"] as JArray).ToList();
//if (result.Count() > 50)
// result = result.Take(50).ToList();
@@ -124,7 +94,7 @@ protected override List GetPlaylist(string keyword)
var songInfo = new SongInfo(this,
song["id"].ToString(),
song["name"].ToString(),
- (song["artist"] as JArray).Select(x => x.ToString()).ToArray());
+ (song["ar"] as JArray).Select(x => x["name"].ToString()).ToArray());
songInfo.Lyric = null;//在之后再获取Lyric
@@ -153,7 +123,7 @@ protected override SongInfo Search(string keyword)
string result_str;
try
{
- result_str = Fetch(API_PROTOCOL, API_HOST, API_PATH + ServiceName + $"/search?keyword={HttpUtility.UrlEncode(keyword)}");
+ result_str = Fetch(API_PROTOCOL, API_HOST, API_PATH + ServiceName + $"/search?keyword={HttpUtility.UrlEncode(keyword)}&type=song&pageSize=5&page=0");
}
catch (Exception ex)
{
@@ -167,7 +137,7 @@ protected override SongInfo Search(string keyword)
JObject info = JObject.Parse(result_str);
if (info["code"].ToString() == "200")
{
- song = (info["result"] as JArray)?[0] as JObject;
+ song = (info["data"]["songs"] as JArray)?[0] as JObject;
}
}
catch (Exception ex)
@@ -185,7 +155,7 @@ protected override SongInfo Search(string keyword)
this,
song["id"].ToString(),
song["name"].ToString(),
- (song["artist"] as JArray).Select(x => x.ToString()).ToArray()
+ (song["ar"] as JArray).Select(x => x["name"].ToString()).ToArray()
);
}
catch (Exception ex)
@@ -196,7 +166,7 @@ protected override SongInfo Search(string keyword)
return songInfo;
}
- private static string Fetch(string prot, string host, string path, string data = null, string referer = null)
+ protected static string Fetch(string prot, string host, string path, string data = null, string referer = null)
{
for (int retryCount = 0; retryCount < 4; retryCount++)
{
diff --git a/DGJv3/InternalModule/LwlApiNetease.cs b/DGJv3/InternalModule/LwlApiNetease.cs
index 1ce2ff6..76326b7 100644
--- a/DGJv3/InternalModule/LwlApiNetease.cs
+++ b/DGJv3/InternalModule/LwlApiNetease.cs
@@ -1,11 +1,142 @@
-namespace DGJv3.InternalModule
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Newtonsoft.Json.Linq;
+
+namespace DGJv3.InternalModule
{
sealed class LwlApiNetease : LwlApiBaseModule
{
+ private const string API_PROTOCOL = "http://";
+ // private const string API_HOST = "v1.itooi.cn";
+ private const string API_HOST = "music.163.com";
+ private const string API_PATH = "/api";
+
internal LwlApiNetease()
{
SetServiceName("netease");
SetInfo("网易云音乐", INFO_AUTHOR, INFO_EMAIL, INFO_VERSION, "搜索网易云音乐的歌曲");
}
+
+ protected override string GetDownloadUrl(SongItem songInfo)
+ {
+ try
+ {
+ // api.Request(CloudMusicApiProviders.SongUrl,
+ // new Dictionary { { "id", songInfo.SongId } }, out var response);
+ return $"https://music.163.com/song/media/outer/url?id={songInfo.SongId}.mp3";
+ }
+ catch (Exception ex)
+ {
+ Log($"歌曲 {songInfo.SongName} 疑似版权不能下载(ex:{ex.Message})");
+ return null;
+ }
+ }
+
+ protected override string GetLyricById(string Id)
+ {
+ try
+ {
+ var response = Fetch(API_PROTOCOL, API_HOST,
+ API_PATH +
+ $"/song/lyric?id={Id}&lv=1&kv=1&tv=-1");
+ var json = JObject.Parse(response);
+
+ return json["lrc"]["lyric"].ToString();
+ }
+ catch (Exception ex)
+ {
+ Log($"歌曲 {Id} 歌词下载错误(ex:{ex.Message})");
+ return null;
+ }
+ }
+
+ protected override List GetPlaylist(string keyword)
+ {
+ var Id = 0;
+ try
+ {
+ var response = Fetch(API_PROTOCOL, API_HOST,
+ API_PATH +
+ $"/search/get/web?csrf_token=hlpretag=&hlposttag=&s={keyword}&type=1000&offset=0&total=true&limit=3");
+ var json = JObject.Parse(response);
+ var playlist = (json["result"]["playlists"] as JArray)?[0] as JObject;
+ Id = playlist.Value("id");
+ }
+ catch (Exception ex)
+ {
+ Log($"歌单下载错误(ex:{ex.Message})");
+ return null;
+ }
+
+ try
+ {
+ var response = Fetch(API_PROTOCOL, API_HOST,
+ API_PATH +
+ $"/search/get/web?csrf_token=hlpretag=&hlposttag=&s={keyword}&type=1&offset=0&total=true&limit=3");
+ var json = JObject.Parse(response);
+ return (json["result"]["tracks"] as JArray)?.Select(song =>
+ {
+ SongInfo songInfo;
+
+ try
+ {
+ songInfo = new SongInfo(
+ this,
+ song["id"].ToString(),
+ song["name"].ToString(),
+ (song["artists"] as JArray).Select(x => x["name"].ToString()).ToArray()
+ );
+ }
+ catch (Exception ex)
+ { Log("歌曲信息获取结果错误:" + ex.Message); return null; }
+
+ songInfo.Lyric = GetLyricById(songInfo.Id);
+ return songInfo;
+ }).ToList();
+
+ }
+ catch (Exception ex)
+ {
+ Log($"歌单下载错误(ex:{ex.Message})");
+ return null;
+ }
+ }
+
+ protected override SongInfo Search(string keyword)
+ {
+ try
+ {
+ var response = Fetch(API_PROTOCOL, API_HOST,
+ API_PATH +
+ $"/search/get/web?csrf_token=hlpretag=&hlposttag=&s={keyword}&type=1&offset=0&total=true&limit=3");
+ var json = JObject.Parse(response);
+ var song = (json["result"]["songs"] as JArray)?[0] as JObject;
+
+ SongInfo songInfo;
+
+ try
+ {
+ songInfo = new SongInfo(
+ this,
+ song["id"].ToString(),
+ song["name"].ToString(),
+ (song["artists"] as JArray).Select(x => x["name"].ToString()).ToArray()
+ );
+ }
+ catch (Exception ex)
+ { Log("歌曲信息获取结果错误:" + ex.Message); return null; }
+
+ songInfo.Lyric = GetLyricById(songInfo.Id);
+
+ return songInfo;
+ }
+ catch (Exception ex)
+ {
+ Log(ex.Message);
+ return null;
+ }
+ }
+
}
}
diff --git a/DGJv3/packages.config b/DGJv3/packages.config
index 3de27a1..f37e081 100644
--- a/DGJv3/packages.config
+++ b/DGJv3/packages.config
@@ -3,6 +3,10 @@
-
+
+
+
+
+
\ No newline at end of file