Skip to content

Commit

Permalink
add cookie options for netease
Browse files Browse the repository at this point in the history
  • Loading branch information
khjxiaogu committed Nov 7, 2024
1 parent b34d9d4 commit f55b71f
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 69 deletions.
40 changes: 0 additions & 40 deletions .classpath

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/target/
/.settings/
/.classpath
5 changes: 0 additions & 5 deletions .settings/org.eclipse.core.resources.prefs

This file was deleted.

15 changes: 0 additions & 15 deletions .settings/org.eclipse.jdt.core.prefs

This file was deleted.

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.khjxiaogu</groupId>
<artifactId>MiraiSongPlugin</artifactId>
<version>1.2.1</version>
<version>1.2.2</version>
<name>MiraiSongPlugin</name>
<description>使用“#音乐 关键词”、“#QQ 关键词”、“#网易 关键词”等方式进行点歌的插件。</description>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,10 @@ public void reload() {
YamlMap excs = (YamlMap) cfg.get(new YamlLiteral("extracommands"));
YamlMap exps = (YamlMap) cfg.get(new YamlLiteral("extraparsers"));
String addDefault = cfg.getStringOrNull("adddefault");
String neteaseCookie=cfg.getStringOrNull("neteasecookies");
NetEaseCrypto.cookie=neteaseCookie;
commands.clear();



if (addDefault == null || addDefault.equals("true")) {
urlMatchers.add(makeMatcher("music\\.163\\.com.*/song.*\\?.*id=([0-9]+)","网易","Mirai"));
urlMatchers.add(makeMatcher("i\\.y\\.qq\\.com/v8/playsong\\.html\\?.*songid=([0-9]+)","QQ音乐","Mirai"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static String getUserAgent() {
* 输入向量.
*/
private static String iv = "0102030405060708";

public static String cookie="";
/**
* Create a AES secret key.<br>
* 生成AES密钥
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public String queryRealUrl(String id) throws Exception {
.url("/weapi/song/enhance/player/url?csrf_token=")
.contenttype("application/x-www-form-urlencoded")
.referer("https://music.163.com")
.cookie(NetEaseCrypto.cookie)
.ua(NetEaseCrypto.getUserAgent())
.post()
.send(NetEaseCrypto.weapiEncryptParam(JsonBuilder.object().add("ids","[" + id + "]").add("br",999000).toString()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@ public String queryRealUrl(String id) throws Exception {
@Override
public MusicInfo get(String keyword) throws Exception {
String murl;
JsonArray ja=HttpRequestBuilder.create("music.163.com")
JsonObject jom=HttpRequestBuilder.create("music.163.com")
.url("/weapi/cloudsearch/get/web?csrf_token=")
.referer("http://music.163.com/")
.cookie("appver=1.5.0.75771;")
.cookie("appver=1.5.0.75771;"+NetEaseCrypto.cookie)
.contenttype("application/x-www-form-urlencoded")
.post()
.send(NetEaseCrypto.weapiEncryptParam(JsonBuilder.object().add("s", keyword).add("type", 1).add("offset", 0).add("limit", 3).toString()))
.readJson().get("result").getAsJsonObject().get("songs").getAsJsonArray();
.readJson();
System.out.println(jom);
JsonArray ja=jom
.get("result").getAsJsonObject().get("songs").getAsJsonArray();
JsonObject jo = ja.get(0).getAsJsonObject();
murl = queryRealUrl(jo.get("id").getAsString());
int i = 0;
Expand All @@ -66,7 +69,7 @@ public MusicInfo getId(String id) throws Exception {
JsonObject jo =HttpRequestBuilder.create("music.163.com")
.url("/weapi/song/detail?csrf_token=")
.referer("http://music.163.com/")
.cookie("appver=1.5.0.75771;")
.cookie("appver=1.5.0.75771;"+NetEaseCrypto.cookie)
.contenttype("application/x-www-form-urlencoded")
.post()
.send(NetEaseCrypto.weapiEncryptParam(JsonBuilder.object().array("ids").add(id).end().toString()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ protected JsonObject getSlice(String id,int offset,int limit) throws IOException
return HttpRequestBuilder.create("music.163.com")
.url("/weapi/dj/program/byradio?csrf_token=")
.defUA()
.cookie(NetEaseCrypto.cookie)
.contenttype("application/x-www-form-urlencoded")
.referer("https://music.163.com")
.ua(NetEaseCrypto.getUserAgent())
Expand All @@ -57,6 +58,7 @@ protected JsonObject getProgramSong(String id) throws IOException {
JsonObject main=HttpRequestBuilder.create("music.163.com")
.url("/weapi/dj/program/detail?csrf_token=")
.defUA()
.cookie(NetEaseCrypto.cookie)
.contenttype("application/x-www-form-urlencoded")
.referer("https://music.163.com")
.ua(NetEaseCrypto.getUserAgent())
Expand Down Expand Up @@ -122,7 +124,7 @@ public MusicInfo get(String keyword, String songname) throws Exception {
JsonArray ja=HttpRequestBuilder.create("music.163.com")
.url("/weapi/cloudsearch/get/web?csrf_token=")
.ua(NetEaseCrypto.getUserAgent())
.cookie("appver=1.5.0.75771;")
.cookie("appver=1.5.0.75771;"+NetEaseCrypto.cookie)
.referer("http://music.163.com/")
.contenttype("application/x-www-form-urlencoded")
.post()
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ hintsourcenotfound: "无法找到来源。"
enableParser: 1
admins:
- 0
neteasecookies: MUSIC_U=<YourLoginToken>;
extracommands:
"#分享":
source: all
Expand Down

0 comments on commit f55b71f

Please sign in to comment.