Skip to content

Commit

Permalink
1.适配网易云8.1.60
Browse files Browse the repository at this point in the history
2.尝试增强异常捕获,增加异常提醒
3.修复注册时拿不到cookie的虫子
  • Loading branch information
nining377 committed Mar 16, 2021
1 parent f703698 commit 790834f
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.os.Bundle;
import android.widget.Toast;

import com.raincat.dolby_beta.db.ExtraDao;
import com.raincat.dolby_beta.utils.Setting;
Expand Down Expand Up @@ -38,19 +39,19 @@ public class UnblockMusicHook {
private static String dataPath;

private final String classMainActivity = "com.netease.cloudmusic.activity.MainActivity";
private String classRealCall = "okhttp3.RealCall";
private String classRealCall ;
private String fieldHttpUrl = "url";
private String fieldProxy = "proxy";

public UnblockMusicHook(Context context, int versionCode, boolean isPlayProcess) {
if (versionCode == 110) {
classRealCall = "okhttp3.z";
fieldHttpUrl = "a";
fieldProxy = "d";
} else if (versionCode >= 7001080) {
if (versionCode >= 7001080) {
classRealCall = "okhttp3.internal.connection.RealCall";
} else if (versionCode >= 138) {
classRealCall = "okhttp3.RealCall";
} else {
classRealCall = "okhttp3.z";
fieldHttpUrl = "a";
fieldProxy = "d";
}

final Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 23338));
Expand All @@ -68,7 +69,10 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

Object urlObj = urlField.get(request);
if (urlObj.toString().contains("song/enhance/player/url") || urlObj.toString().contains("song/enhance/download/url")) {
proxyField.set(client, proxy);
if (ExtraDao.getInstance(context).getExtra("ScriptRunning").equals("0")) {
Tools.showToastOnLooper(context, "node未运行,请保证脚本与Node文件路径正确!");
} else
proxyField.set(client, proxy);
} else {
proxyField.set(client, null);
}
Expand All @@ -82,6 +86,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
findAndHookMethod(classMainActivity, context.getClassLoader(), "onCreate", Bundle.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) {
ExtraDao.getInstance(context).saveExtra("ScriptRunning", "0");
initScript(context);
}
});
Expand Down Expand Up @@ -137,6 +142,7 @@ public void commandOutput(int id, String line) {
Tools.showToastOnLooper(c, "运行失败,错误为:" + line);
} else if (line.contains("HTTP Server running")) {
Tools.showToastOnLooper(c, "UnblockNeteaseMusic运行成功");
ExtraDao.getInstance(context).saveExtra("ScriptRunning", "1");
}
}
};
Expand Down

0 comments on commit 790834f

Please sign in to comment.