Skip to content

Commit fb364cd

Browse files
committed
1.评论可选优先显示最热,且把推荐放到最后
2.优化判断歌曲音质逻辑,减少匹配错误概率
1 parent 2ade91a commit fb364cd

17 files changed

Lines changed: 217 additions & 41 deletions

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
applicationId "com.raincat.dolby_beta"
99
minSdkVersion 21
1010
targetSdkVersion 29
11-
versionCode 335
12-
versionName "3.3.5"
11+
versionCode 336
12+
versionName "3.3.6"
1313

1414
externalNativeBuild {
1515
cmake {
203 KB
Binary file not shown.

app/src/main/java/com/raincat/dolby_beta/Hook.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.raincat.dolby_beta.hook.AutoSignInHook;
1717
import com.raincat.dolby_beta.hook.BlackHook;
1818
import com.raincat.dolby_beta.hook.CdnHook;
19+
import com.raincat.dolby_beta.hook.CommentHotClickHook;
1920
import com.raincat.dolby_beta.hook.DownloadMD5Hook;
2021
import com.raincat.dolby_beta.hook.EAPIHook;
2122
import com.raincat.dolby_beta.hook.GrayHook;
@@ -98,6 +99,12 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
9899
new InternalDialogHook(context, versionCode);
99100
// new TestHook(context);
100101
ClassHelper.getCacheClassList(context, versionCode, () -> {
102+
//获取账号信息
103+
new UserProfileHook(context);
104+
//网络访问
105+
new EAPIHook(context);
106+
//下载MD5校验
107+
new DownloadMD5Hook(context);
101108
//精简tab
102109
new HideTabHook(context, versionCode);
103110
//精简侧边栏
@@ -106,12 +113,8 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
106113
new HideBannerHook(context, versionCode);
107114
//隐藏小红点
108115
new HideBubbleHook(context);
109-
//获取账号信息
110-
new UserProfileHook(context);
111-
//网络访问
112-
new EAPIHook(context);
113-
//下载MD5校验
114-
new DownloadMD5Hook(context);
116+
//打开评论后优先显示最热评论
117+
new CommentHotClickHook(context);
115118
new CdnHook(context, versionCode);
116119

117120
mainProcessInit = true;

app/src/main/java/com/raincat/dolby_beta/db/SignDao.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void saveSongList(List<Long> songIdList, String userId) {
5454
/**
5555
* 获取已打卡歌曲
5656
*/
57-
public HashMap<Long, Integer> getSong( String userId) {
57+
public HashMap<Long, Integer> getSong(String userId) {
5858
SQLiteDatabase db = dbHelper.getReadableDatabase();
5959
HashMap<Long, Integer> longMap = new HashMap<>();
6060
if (db.isOpen()) {

app/src/main/java/com/raincat/dolby_beta/helper/ClassHelper.java

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ public static Class<?> getClazz(Context context) {
287287
.filter(c -> Stream.of(c.getDeclaredFields()).anyMatch(m -> m.getType() == String.class))
288288
.filter(c -> Stream.of(c.getDeclaredFields()).anyMatch(m -> m.getType() == ArrayList.class))
289289
.filter(c -> Stream.of(c.getDeclaredFields()).anyMatch(m -> m.getType() == boolean.class))
290-
.filter(c -> Stream.of(c.getDeclaredMethods()).anyMatch(m -> m.getReturnType() == ArrayList.class))
291-
.filter(c -> Stream.of(c.getDeclaredMethods()).anyMatch(m -> m.getReturnType() == String[].class))
290+
.filter(c -> Stream.of(c.getDeclaredMethods()).anyMatch(m -> m.getReturnType() == ArrayList.class && Modifier.isFinal(m.getModifiers()) && m.getParameterTypes().length == 0))
291+
.filter(c -> Stream.of(c.getDeclaredMethods()).anyMatch(m -> m.getReturnType() == String[].class && Modifier.isFinal(m.getModifiers()) && m.getParameterTypes().length == 0))
292292
.findFirst()
293293
.get();
294294
} catch (NoSuchElementException e) {
@@ -298,20 +298,24 @@ public static Class<?> getClazz(Context context) {
298298
return clazz;
299299
}
300300

301-
public static Method getTabInitMethod() {
301+
public static Method getTabInitMethod(Context context) {
302302
if (initMethod == null) {
303303
Method[] methods = findMethodsByExactParameters(clazz, ArrayList.class);
304304
if (methods.length != 0)
305305
initMethod = methods[0];
306+
else
307+
MessageHelper.sendNotification(context, MessageHelper.tabClassNotFoundCode);
306308
}
307309
return initMethod;
308310
}
309311

310-
public static Method getTabRefreshMethod() {
312+
public static Method getTabRefreshMethod(Context context) {
311313
if (refreshMethod == null) {
312314
Method[] methods = findMethodsByExactParameters(clazz, void.class, List.class);
313315
if (methods.length != 0)
314316
refreshMethod = methods[0];
317+
else
318+
MessageHelper.sendNotification(context, MessageHelper.tabClassNotFoundCode);
315319
}
316320
return refreshMethod;
317321
}
@@ -348,6 +352,40 @@ public static Class<?> getClazz(Context context) {
348352
}
349353
}
350354

355+
/**
356+
* 评论
357+
*/
358+
public static class CommentDataClass {
359+
private static Class<?> clazz;
360+
361+
public static Class<?> getClazz(Context context) {
362+
if (clazz == null) {
363+
try {
364+
Pattern pattern = Pattern.compile("^com\\.netease\\.cloudmusic\\.module\\.comment2\\.[a-z]\\.[a-z]$");
365+
List<String> list = ClassHelper.getFilteredClasses(pattern, Collections.reverseOrder());
366+
clazz = Stream.of(list)
367+
.map(s -> findClass(s, classLoader))
368+
.filter(c -> Modifier.isPublic(c.getModifiers()))
369+
.filter(m -> !Modifier.isInterface(m.getModifiers()))
370+
.filter(m -> !Modifier.isStatic(m.getModifiers()))
371+
.filter(m -> !Modifier.isAbstract(m.getModifiers()))
372+
.filter(c -> Stream.of(c.getDeclaredFields()).anyMatch(m -> m.getType() == int.class))
373+
.filter(c -> Stream.of(c.getDeclaredFields()).anyMatch(m -> m.getType() == List.class))
374+
.filter(c -> Stream.of(c.getDeclaredFields()).anyMatch(m -> m.getType() == ArrayList.class))
375+
.filter(c -> Stream.of(c.getDeclaredFields()).anyMatch(m -> m.getType() == Intent.class))
376+
.filter(c -> Stream.of(c.getDeclaredFields()).anyMatch(m -> m.getType() == String.class))
377+
.filter(c -> Stream.of(c.getDeclaredFields()).anyMatch(m -> m.getType() == long.class))
378+
.filter(c -> Stream.of(c.getDeclaredFields()).anyMatch(m -> m.getType() == boolean.class))
379+
.findFirst()
380+
.get();
381+
} catch (NoSuchElementException e) {
382+
e.printStackTrace();
383+
}
384+
}
385+
return clazz;
386+
}
387+
}
388+
351389
public static class OKHttp3Response {
352390
private static Class<?> clazz;
353391

app/src/main/java/com/raincat/dolby_beta/helper/EAPIHelper.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ public static void uploadCloud(String data) {
139139
}
140140

141141
private static final Pattern REX_TYPE = Pattern.compile("\"type\":\\d+");
142-
private static final Pattern REX_PL = Pattern.compile("\"pl\":(?!999000)\\d+");
143-
private static final Pattern REX_DL = Pattern.compile("\"dl\":(?!999000)\\d+");
144-
private static final Pattern REX_SUBP = Pattern.compile("\"subp\":\\d+");
145142

146143
/**
147144
* 音效
@@ -151,16 +148,6 @@ public static String modifyEffect(String originalContent) {
151148
return originalContent;
152149
}
153150

154-
/**
155-
* 解除灰色歌曲无法播放及收藏
156-
*/
157-
public static String modifyByRegex(String originalContent) {
158-
originalContent = REX_PL.matcher(originalContent).replaceAll("\"pl\":320000");
159-
originalContent = REX_DL.matcher(originalContent).replaceAll("\"dl\":320000");
160-
originalContent = REX_SUBP.matcher(originalContent).replaceAll("\"subp\":1");
161-
return originalContent;
162-
}
163-
164151
public static JSONObject decrypt(String params) throws Exception {
165152
params = NeteaseAES2.Decrypt(params);
166153
if (params != null && params.length() != 0) {

app/src/main/java/com/raincat/dolby_beta/helper/ExtraHelper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public class ExtraHelper {
3030
public static final String SCRIPT_STATUS = "script_status";
3131
//脚本运行重试
3232
public static final String SCRIPT_RETRY = "script_retry";
33+
//APP版本号
34+
public static final String APP_VERSION = "app_version";
3335

3436
//初始化数据库
3537
public static void init(Context context) {

app/src/main/java/com/raincat/dolby_beta/helper/MessageHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
public class MessageHelper {
1919
public static void sendNotification(Context context, int code) {
20-
if (!SettingHelper.getInstance().getSetting(SettingHelper.warn_key))
20+
if (!SettingHelper.getInstance().isEnable(SettingHelper.warn_key))
2121
return;
2222
Intent intent = new Intent(Hook.msg_send_notification);
2323
intent.putExtra("code", cookieClassNotFoundCode);

app/src/main/java/com/raincat/dolby_beta/helper/ScriptHelper.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.content.Intent;
55
import android.text.TextUtils;
66

7+
import com.raincat.dolby_beta.BuildConfig;
78
import com.raincat.dolby_beta.Hook;
89
import com.raincat.dolby_beta.net.HTTPSTrustManager;
910
import com.raincat.dolby_beta.utils.Tools;
@@ -59,14 +60,15 @@ public class ScriptHelper {
5960
*/
6061
public static void initScript(Context context, boolean cover) {
6162
File unblockFile = new File(getScriptPath(context));
62-
if (cover || !unblockFile.exists()) {
63+
if (cover || !unblockFile.exists() || !(BuildConfig.VERSION_CODE + "").equals(ExtraHelper.getExtraDate(ExtraHelper.APP_VERSION))) {
6364
if (FileHelper.unzipFile(modulePath, getScriptPath(context), "assets", "UnblockNeteaseMusic.zip")) {
6465
FileHelper.unzipFiles(getScriptPath(context) + "/UnblockNeteaseMusic.zip", getScriptPath(context));
6566
}
6667
String bit = context.getApplicationInfo().nativeLibraryDir.endsWith("64") ? "arm64-v8a" : "armeabi-v7a";
6768
FileHelper.unzipFile(modulePath, getScriptPath(context), bit, "libc++_shared.so");
6869
FileHelper.unzipFile(modulePath, getScriptPath(context), bit, "libnative-lib.so");
6970
FileHelper.unzipFile(modulePath, getScriptPath(context), bit, "libnode.so");
71+
ExtraHelper.setExtraDate(ExtraHelper.APP_VERSION, BuildConfig.VERSION_CODE);
7072
}
7173
initNative(context);
7274
}
@@ -114,7 +116,7 @@ public static void startScript(Context context) {
114116
if (loadSuccess) {
115117
new Thread(() -> {
116118
setEnv("ENABLE_FLAC", SettingHelper.getInstance().getSetting(SettingHelper.proxy_flac_key) + "");
117-
setEnv("MIN_BR", "128000");
119+
setEnv("MIN_BR", "96000");
118120

119121
String[] origin = SettingHelper.getInstance().getProxyOriginal().split(" ");
120122
ArrayList<String> scriptList = new ArrayList<>();

app/src/main/java/com/raincat/dolby_beta/helper/SettingHelper.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ public class SettingHelper {
100100
public static final String beauty_banner_hide_key = "β_beauty_banner_hide_key";
101101
public static final String beauty_banner_hide_title = "移除发现页与歌单广场Banner";
102102

103+
public static final String beauty_comment_hot_key = "β_beauty_comment_hot_key";
104+
public static final String beauty_comment_hot_title = "评论区优先显示“最热”内容";
105+
103106
public static final String beauty_sidebar_hide_key = "β_beauty_sidebar_hide_key";
104107
public static final String beauty_sidebar_hide_title = "精简侧边栏";
105108
public static final String beauty_sidebar_hide_sub = "部分Item需配合“设置”->“侧边栏管理”开关生效";
@@ -143,6 +146,7 @@ public void refreshSetting(Context context) {
143146
settingMap.put(beauty_tab_hide_key, sharedPreferences.getBoolean(beauty_tab_hide_key, false));
144147
settingMap.put(beauty_bubble_hide_key, sharedPreferences.getBoolean(beauty_bubble_hide_key, false));
145148
settingMap.put(beauty_banner_hide_key, sharedPreferences.getBoolean(beauty_banner_hide_key, false));
149+
settingMap.put(beauty_comment_hot_key, sharedPreferences.getBoolean(beauty_comment_hot_key, false));
146150
}
147151

148152
public void setSetting(String key, boolean value) {
@@ -154,6 +158,10 @@ public boolean getSetting(String key) {
154158
return settingMap.get(key);
155159
}
156160

161+
public boolean isEnable(String key) {
162+
return settingMap.get(master_key) && settingMap.get(key);
163+
}
164+
157165
public HashMap<String, Boolean> getSidebarSetting(LinkedHashMap<String, String> map) {
158166
if (sidebarSettingMap == null) {
159167
sidebarSettingMap = new HashMap<>();
@@ -169,10 +177,6 @@ public void setSidebarSetting(String key, boolean value) {
169177
sharedPreferences.edit().putBoolean(key, value).apply();
170178
}
171179

172-
public boolean isEnable(String key) {
173-
return settingMap.get(master_key) && settingMap.get(key);
174-
}
175-
176180
public String getSignId() {
177181
return sharedPreferences.getString(SettingHelper.sign_id_key, "");
178182
}

0 commit comments

Comments
 (0)