├── .idea
├── .name
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── compiler.xml
├── gradle.xml
└── misc.xml
├── app
├── .gitignore
├── src
│ └── main
│ │ ├── assets
│ │ └── xposed_init
│ │ ├── res
│ │ ├── values-v11
│ │ │ └── styles.xml
│ │ ├── values-v21
│ │ │ └── styles.xml
│ │ ├── values
│ │ │ ├── styles.xml
│ │ │ └── strings.xml
│ │ ├── values-v14
│ │ │ └── styles.xml
│ │ ├── values-zh
│ │ │ └── strings.xml
│ │ ├── values-zh-rCN
│ │ │ └── strings.xml
│ │ └── xml
│ │ │ └── pref_general.xml
│ │ ├── java
│ │ └── bin
│ │ │ └── xposed
│ │ │ └── Unblock163MusicClient
│ │ │ ├── Settings.java
│ │ │ ├── ui
│ │ │ ├── IPv4EditTextPreference.java
│ │ │ └── SettingsActivity.java
│ │ │ ├── Main.java
│ │ │ └── Utility.java
│ │ └── AndroidManifest.xml
├── libs
│ └── XposedBridgeApi-30.jar
├── build.gradle
└── proguard-rules.pro
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── README.md
├── gradle.properties
├── FindHookPoint.py
├── gradlew.bat
└── gradlew
/.idea/.name:
--------------------------------------------------------------------------------
1 | Unlock163Music
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/src/main/assets/xposed_init:
--------------------------------------------------------------------------------
1 | bin.xposed.Unblock163MusicClient.Main
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/libs/XposedBridgeApi-30.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YiuChoi/Unlock163Music/master/app/libs/XposedBridgeApi-30.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YiuChoi/Unlock163Music/master/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | /private
--------------------------------------------------------------------------------
/app/src/main/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Unblock163MusicClient - Xposed
2 |
3 | Compatible with the v3.3.0,3.2.1,3.1.4,3.1.3 app.
4 |
5 | ## Thanks
6 |
7 | Thanks bin456789 for his source code [https://github.com/bin456789/Unblock163MusicClient-Xposed]
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 06 09:03:29 CST 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/java/bin/xposed/Unblock163MusicClient/Settings.java:
--------------------------------------------------------------------------------
1 | package bin.xposed.Unblock163MusicClient;
2 |
3 | public final class Settings {
4 | public static final String SETTING_CHANGED = "bin.xposed.Unblock163MusicClient.SETTING_CHANGED";
5 |
6 | public static final String OVERSEA_MODE_KEY = "OVERSEA_MODE";
7 | public static final boolean OVERSEA_MODE_DEFAULT = false;
8 |
9 | public static final String DNS_SERVER_KEY = "DNS_SERVER";
10 | public static final String DNS_SERVER_DEFAULT = "219.141.140.10"; // beijing telecom dns
11 |
12 | public static final String DNS_INSTRUCTION_KEY = "DNS_INSTRUCTION";
13 |
14 | public static final String DNS_TEST_KEY = "DNS_TEST";
15 | }
16 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion '24.0.0 rc2'
6 | useLibrary 'org.apache.http.legacy'
7 |
8 | defaultConfig {
9 | applicationId "name.caiyao.neteasemusic"
10 | minSdkVersion 9
11 | targetSdkVersion 23
12 | versionCode 9
13 | versionName "1.0.9"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled true
18 | shrinkResources true
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | provided files('libs/XposedBridgeApi-30.jar')
26 | compile 'dnsjava:dnsjava:2.1.7'
27 | }
28 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | ## Project-wide Gradle settings.
2 | #
3 | # For more details on how to configure your build environment visit
4 | # http://www.gradle.org/docs/current/userguide/build_environment.html
5 | #
6 | # Specifies the JVM arguments used for the daemon process.
7 | # The setting is particularly useful for tweaking memory settings.
8 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
10 | #
11 | # When configured, Gradle will run in incubating parallel mode.
12 | # This option should only be used with decoupled projects. More details, visit
13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
14 | # org.gradle.parallel=true
15 | #Thu Jan 14 01:45:37 CST 2016
16 | systemProp.https.proxyPort=1080
17 | systemProp.http.proxyHost=127.0.0.1
18 | systemProp.https.proxyHost=127.0.0.1
19 | systemProp.http.proxyPort=1080
20 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Users\Bin\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 | -dontwarn org.xbill.DNS.spi.DNSJavaNameServiceDescriptor
19 | -keep public class bin.xposed.Unblock163MusicClient.Main
20 | -keepclassmembernames class bin.xposed.Unblock163MusicClient.ui.SettingsActivity {
21 | int getActivatedModuleVersion();
22 | }
--------------------------------------------------------------------------------
/FindHookPoint.py:
--------------------------------------------------------------------------------
1 | import os
2 | def findHook(path):
3 | for i in os.walk(path+os.sep+"smali"+os.sep+"com"+os.sep+"netease"+os.sep+"cloudmusic"):
4 | if "utils" not in i[0]:
5 | for j in i[2]:
6 | def openread(path,name):
7 | fi=open(path+os.sep+name)
8 | lines=fi.readlines()
9 | if "utils" in lines[1]:
10 | nam=name[0:name.find(".")]
11 | CONS=path.split(os.sep)
12 | length=len(lines[1])
13 | HOOK=lines[1][lines[1].find("utils/")+6:length]
14 | print "HOOK_UTILS = ","com.netease.cloudmusic.utils."+HOOK+"\r"
15 | print "HOOK_CONSTRUCTOR = ","com.netease.cloudmusic."+CONS[-2]+"."+CONS[-1]+"."+nam+"\n\n"
16 | fi.close()
17 | if j.find(".")<=2:
18 | openread(i[0],j)
19 | #print "version 3.3.1\r"
20 | #findHook(r"D:\Android\output\c331")
21 | #print "version 3.2.1\r"
22 | #findHook(r"D:\Android\output\c321")
23 | #print "version 3.1.4\r"
24 | #findHook(r"D:\Android\output\c314")
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/values-zh/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 音量增强器
4 | 仅供测试
5 | 确定
6 | 取消
7 |
8 | 由于很少需要更改配置,本模块图标将从桌面上移除。\n\n下次可到 Xposed Installer 打开。
9 | 重启后生效
10 | 模块未激活,请先激活模块并重启手机
11 |
12 | 海外模式
13 | 国内用户切勿勾选,否则会降低缓冲速度
14 |
15 | DNS 服务器
16 |
17 | DNS 服务器说明
18 | 点击这里查看 DNS 列表。\n国内运营商的 DNS 才能解除播放地区限制。\n公众 DNS 则不能解除限制。
19 |
20 | DNS 测试
21 | DNS 测试中…
22 | DNS 可用,且符合要求
23 | DNS 可用,但不符合要求
24 | DNS 不可用
25 | DNS 测试中断
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/values-zh-rCN/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 音量增强器
4 | 仅供测试
5 | 确定
6 | 取消
7 |
8 | 由于很少需要更改配置,本模块图标将从桌面上移除。\n\n下次可到 Xposed Installer 打开。
9 | 重启后生效
10 | 模块未激活,请先激活模块并重启手机
11 |
12 | 海外模式
13 | 国内用户切勿勾选,否则会降低缓冲速度
14 |
15 | DNS 服务器
16 |
17 | DNS 服务器说明
18 | 点击这里查看 DNS 列表。\n国内运营商的 DNS 才能解除播放地区限制。\n公众 DNS 则不能解除限制。
19 |
20 | DNS 测试
21 | DNS 测试中…
22 | DNS 可用,且符合要求
23 | DNS 可用,但不符合要求
24 | DNS 不可用
25 | DNS 测试中断
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_general.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
21 |
24 |
25 |
26 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Volume Booster
4 | Just for test
5 | OK
6 | Cancel
7 |
8 | Because rarely need to change the configuration, I\'m going to disappear from your launcher.\n\nFind me in \"Xposed Installer\" next time.
9 | Reboot needed to take effect
10 | Module not activated. Please enable this module and reboot your phone.
11 |
12 | Oversea mode
13 | Don\'t enable if you\'re in the wall. Otherwise streaming will get slow.
14 |
15 | DNS server
16 |
17 | DNS instruction
18 | Click here to find out DNS list.\nTo unblock music, the DNS server should be a China ISP DNS server.\nPublic DNS doesn\'t help for unblocking.
19 |
20 | DNS test
21 | DNS testing…
22 | DNS available. And works for unblocking
23 | DNS available. But doesn\'t work for unblocking
24 | DNS unavailable
25 | DNS test interrupted
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
36 |
40 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/bin/xposed/Unblock163MusicClient/ui/IPv4EditTextPreference.java:
--------------------------------------------------------------------------------
1 | package bin.xposed.Unblock163MusicClient.ui;
2 |
3 | import android.app.AlertDialog;
4 | import android.app.Dialog;
5 | import android.content.Context;
6 | import android.os.Bundle;
7 | import android.preference.EditTextPreference;
8 | import android.text.Editable;
9 | import android.text.TextWatcher;
10 | import android.util.AttributeSet;
11 | import android.util.Patterns;
12 | import android.view.View;
13 | import android.widget.Button;
14 | import android.widget.EditText;
15 |
16 | // copy and modify from http://stackoverflow.com/questions/4762027/edittextpreference-disable-buttons
17 |
18 | public class IPv4EditTextPreference extends EditTextPreference {
19 |
20 | EditTextWatcher m_watcher = new EditTextWatcher();
21 |
22 | public IPv4EditTextPreference(Context context, AttributeSet attrs, int defStyleAttr) {
23 | super(context, attrs, defStyleAttr);
24 | }
25 |
26 | public IPv4EditTextPreference(Context context, AttributeSet attrs) {
27 | super(context, attrs);
28 | }
29 |
30 | public IPv4EditTextPreference(Context context) {
31 | super(context);
32 | }
33 |
34 | protected boolean onCheckValue(String value) {
35 | return Patterns.IP_ADDRESS.matcher(value).matches();
36 | }
37 |
38 | protected void onEditTextChanged() {
39 | boolean enable = onCheckValue(getEditText().getText().toString());
40 | Dialog dlg = getDialog();
41 | if (dlg instanceof AlertDialog) {
42 | AlertDialog alertDlg = (AlertDialog) dlg;
43 | Button btn = alertDlg.getButton(AlertDialog.BUTTON_POSITIVE);
44 | btn.setEnabled(enable);
45 | }
46 | }
47 |
48 | @Override
49 | protected void showDialog(Bundle state) {
50 | super.showDialog(state);
51 |
52 | this.getEditText().setOnFocusChangeListener(new View.OnFocusChangeListener() {
53 | @Override
54 | public void onFocusChange(View v, boolean hasFocus) {
55 | EditText editText = (EditText) v;
56 | editText.setSelection(editText.getText().length());
57 | }
58 | });
59 |
60 | getEditText().removeTextChangedListener(m_watcher);
61 | getEditText().addTextChangedListener(m_watcher);
62 | onEditTextChanged();
63 | }
64 |
65 | @Override
66 | protected void onDialogClosed(boolean positiveResult) {
67 | super.onDialogClosed(positiveResult);
68 | setSummary(getSummary());
69 | }
70 |
71 | @Override
72 | public CharSequence getSummary() {
73 | return this.getText();
74 | }
75 |
76 | private class EditTextWatcher implements TextWatcher {
77 | @Override
78 | public void onTextChanged(CharSequence s, int start, int before, int count) {
79 | }
80 |
81 | @Override
82 | public void beforeTextChanged(CharSequence s, int start, int before, int count) {
83 | }
84 |
85 | @Override
86 | public void afterTextChanged(Editable s) {
87 | onEditTextChanged();
88 | }
89 | }
90 | }
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/java/bin/xposed/Unblock163MusicClient/ui/SettingsActivity.java:
--------------------------------------------------------------------------------
1 | package bin.xposed.Unblock163MusicClient.ui;
2 |
3 | import android.app.AlertDialog;
4 | import android.content.ComponentName;
5 | import android.content.DialogInterface;
6 | import android.content.Intent;
7 | import android.content.SharedPreferences;
8 | import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
9 | import android.content.pm.PackageManager;
10 | import android.os.AsyncTask;
11 | import android.os.Bundle;
12 | import android.preference.Preference;
13 | import android.preference.PreferenceActivity;
14 | import android.preference.PreferenceManager;
15 | import android.preference.PreferenceScreen;
16 | import android.widget.Toast;
17 |
18 | import org.json.JSONException;
19 | import org.json.JSONObject;
20 |
21 | import java.io.IOException;
22 | import java.net.UnknownHostException;
23 |
24 | import bin.xposed.Unblock163MusicClient.R;
25 | import bin.xposed.Unblock163MusicClient.Settings;
26 | import bin.xposed.Unblock163MusicClient.Utility;
27 |
28 | import static bin.xposed.Unblock163MusicClient.Utility.getIpByHostForDnsTest;
29 |
30 |
31 | public class SettingsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
32 |
33 | private Preference dnsTestPreference;
34 | private DnsTestTask dnsTestTask;
35 |
36 | private int getActivatedModuleVersion() {
37 | return -1;
38 | }
39 |
40 | @SuppressWarnings("deprecation")
41 | @Override
42 | protected void onCreate(Bundle savedInstanceState) {
43 | super.onCreate(savedInstanceState);
44 | getPreferenceManager().setSharedPreferencesMode(MODE_WORLD_READABLE);
45 | addPreferencesFromResource(R.xml.pref_general);
46 |
47 | dnsTestPreference = findPreference(Settings.DNS_TEST_KEY);
48 | dnsTestPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
49 | @Override
50 | public boolean onPreferenceClick(final Preference preference) {
51 | if (dnsTestTask == null) {
52 | dnsTestTask = new DnsTestTask();
53 | dnsTestTask.execute();
54 | }
55 | return false;
56 | }
57 | });
58 |
59 | checkState();
60 | checkIcon();
61 |
62 | // unnecessary for now, hide temporarily
63 | PreferenceScreen preferenceScreen = getPreferenceScreen();
64 | preferenceScreen.removePreference(findPreference(Settings.DNS_SERVER_KEY));
65 | preferenceScreen.removePreference(findPreference(Settings.DNS_TEST_KEY));
66 | preferenceScreen.removePreference(findPreference(Settings.DNS_INSTRUCTION_KEY));
67 | }
68 |
69 |
70 | private void checkState() {
71 | if (getActivatedModuleVersion() == -1)
72 | showNotActive();
73 | }
74 |
75 |
76 | private void showNotActive() {
77 | new AlertDialog.Builder(this)
78 | .setMessage(R.string.pref_hint_reboot_not_active)
79 | .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
80 | public void onClick(DialogInterface dialog, int id) {
81 | openXposed();
82 | }
83 | })
84 | .setNegativeButton(R.string.cancel, null)
85 | .show();
86 | }
87 |
88 | private void openXposed() {
89 | Intent intent = new Intent()
90 | .setPackage("de.robv.android.xposed.installer")
91 | .putExtra("section", "modules");
92 | startActivity(intent);
93 | }
94 |
95 | private void checkIcon() {
96 | final ComponentName aliasName = new ComponentName(this, SettingsActivity.this.getClass().getName() + "-Alias");
97 | final PackageManager packageManager = getPackageManager();
98 | if (packageManager.getComponentEnabledSetting(aliasName) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
99 | new AlertDialog.Builder(this)
100 | .setMessage(R.string.pref_hint_hide_icon)
101 | .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
102 | public void onClick(DialogInterface dialog, int id) {
103 | packageManager.setComponentEnabledSetting(
104 | aliasName,
105 | PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
106 | PackageManager.DONT_KILL_APP);
107 | }
108 | }).show();
109 | }
110 | }
111 |
112 | @Override
113 | protected void onResume() {
114 | super.onResume();
115 | PreferenceManager.getDefaultSharedPreferences(this)
116 | .registerOnSharedPreferenceChangeListener(this);
117 | }
118 |
119 | @Override
120 | protected void onPause() {
121 | super.onPause();
122 | PreferenceManager.getDefaultSharedPreferences(this)
123 | .unregisterOnSharedPreferenceChangeListener(this);
124 | }
125 |
126 | @Override
127 | public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
128 | if (Settings.OVERSEA_MODE_KEY.equals(key)) {
129 | Toast.makeText(this, R.string.pref_hint_reboot_setting_changed, Toast.LENGTH_SHORT).show();
130 | } else if (Settings.DNS_SERVER_KEY.equals(key)) {
131 | String dns = sharedPreferences.getString(key, Settings.DNS_SERVER_DEFAULT);
132 | Intent intent = new Intent(Settings.SETTING_CHANGED)
133 | .putExtra(key, dns);
134 | sendBroadcast(intent);
135 | }
136 | }
137 |
138 | private class DnsTestTask extends AsyncTask {
139 | @Override
140 | protected void onPreExecute() {
141 | dnsTestPreference.setSummary(R.string.dns_testing);
142 | }
143 |
144 | @Override
145 | protected String doInBackground(String... params) {
146 | try {
147 | String dns = PreferenceManager.getDefaultSharedPreferences(SettingsActivity.this).getString(Settings.DNS_SERVER_KEY, Settings.DNS_SERVER_DEFAULT);
148 | String neteaseIp = getIpByHostForDnsTest("m1.music.126.net", dns);
149 | String page = Utility.getPage("http://ip.taobao.com/service/getIpInfo.php?ip=" + neteaseIp);
150 | String countryId = new JSONObject(page).getJSONObject("data").getString("country_id");
151 | if ("CN".equals(countryId))
152 | return getString(R.string.dns_pass);
153 | else
154 | return getString(R.string.dns_fail);
155 | } catch (UnknownHostException e) {
156 | return getString(R.string.dns_unavailable);
157 | } catch (JSONException | IOException e) {
158 | return getString(R.string.dns_test_interrupted);
159 | }
160 | }
161 |
162 | @Override
163 | protected void onPostExecute(String result) {
164 | dnsTestPreference.setSummary(result);
165 | dnsTestTask = null;
166 | }
167 | }
168 | }
169 |
--------------------------------------------------------------------------------
/app/src/main/java/bin/xposed/Unblock163MusicClient/Main.java:
--------------------------------------------------------------------------------
1 | package bin.xposed.Unblock163MusicClient;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.IntentFilter;
7 |
8 | import org.apache.http.client.methods.HttpGet;
9 | import org.apache.http.client.methods.HttpUriRequest;
10 | import org.apache.http.impl.client.AbstractHttpClient;
11 | import org.xbill.DNS.TextParseException;
12 |
13 | import java.net.URI;
14 | import java.net.URISyntaxException;
15 |
16 | import de.robv.android.xposed.IXposedHookLoadPackage;
17 | import de.robv.android.xposed.XC_MethodHook;
18 | import de.robv.android.xposed.XC_MethodReplacement;
19 | import de.robv.android.xposed.XSharedPreferences;
20 | import de.robv.android.xposed.XposedBridge;
21 | import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
22 |
23 | import static de.robv.android.xposed.XposedHelpers.callMethod;
24 | import static de.robv.android.xposed.XposedHelpers.callStaticMethod;
25 | import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
26 | import static de.robv.android.xposed.XposedHelpers.findClass;
27 |
28 | public class Main implements IXposedHookLoadPackage {
29 | public static String HOOK_UTILS;
30 | public static boolean OPEN = false;
31 | public static String HOOK_CONSTRUCTOR;
32 | public static final String VERSION_2_9_3 = "2.9.3";
33 | public static final String VERSION_3_2_1 = "3.2.1";
34 | public static final String VERSION_3_3_0 = "3.3.0";
35 | public static final String VERSION_3_3_1 = "3.3.1";
36 | public static final String VERSION_3_3_2 = "3.3.2";
37 | public static final String VERSION_3_4_0 = "3.4.0";
38 | public static final String VERSION_3_4_1 = "3.4.1";
39 | public static String VERSION;
40 |
41 | public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
42 | if (lpparam.packageName.equals(BuildConfig.APPLICATION_ID)) {
43 | // make current module activated
44 | findAndHookMethod("bin.xposed.Unblock163MusicClient.ui.SettingsActivity", lpparam.classLoader,
45 | "getActivatedModuleVersion", XC_MethodReplacement.returnConstant(BuildConfig.VERSION_CODE));
46 | }
47 |
48 | if (lpparam.packageName.equals("com.netease.cloudmusic")) {
49 | final Object activityThread = callStaticMethod(findClass("android.app.ActivityThread", null), "currentActivityThread");
50 | final Context systemContext = (Context) callMethod(activityThread, "getSystemContext");
51 | VERSION = systemContext.getPackageManager().getPackageInfo(lpparam.packageName, 0).versionName;
52 | switch (VERSION) {
53 | case VERSION_3_4_1:
54 | case VERSION_3_4_0:
55 | HOOK_UTILS = "com.netease.cloudmusic.utils.x";
56 | HOOK_CONSTRUCTOR = "com.netease.cloudmusic.i.f";
57 | break;
58 | case VERSION_3_3_2:
59 | case VERSION_3_3_1:
60 | case VERSION_3_3_0:
61 | HOOK_UTILS = "com.netease.cloudmusic.utils.w";
62 | HOOK_CONSTRUCTOR = "com.netease.cloudmusic.i.f";
63 | break;
64 | case VERSION_3_2_1:
65 | HOOK_UTILS = "com.netease.cloudmusic.utils.n";
66 | HOOK_CONSTRUCTOR = "com.netease.cloudmusic.i.b";
67 | break;
68 | case VERSION_2_9_3:
69 | HOOK_UTILS = "com.netease.cloudmusic.utils.af";
70 | HOOK_CONSTRUCTOR = "com.netease.cloudmusic.h.h";
71 | break;
72 | default:
73 | HOOK_UTILS = "com.netease.cloudmusic.utils.u";
74 | HOOK_CONSTRUCTOR = "com.netease.cloudmusic.i.f";
75 | break;
76 | }
77 |
78 | Utility.init(lpparam.classLoader);
79 | findAndHookMethod(HOOK_UTILS, lpparam.classLoader, "i", new XC_MethodHook() { //3.1.4
80 |
81 | @Override
82 | protected void afterHookedMethod(MethodHookParam param) throws Exception {
83 | String url = (String) Utility.FIELD_utils_c.get(param.thisObject);
84 | XposedBridge.log(url);
85 | if (url.startsWith("http://music.163.com/eapi/")) {
86 | String path = url.replace("http://music.163.com", "");
87 | //XposedBridge.log("修改前" + param.getResult());
88 | if (path.startsWith("/eapi/batch")
89 | || path.startsWith("/eapi/song/enhance/privilege")
90 | || path.startsWith("/eapi/v1/artist")
91 | || path.startsWith("/eapi/v1/album")
92 | || path.startsWith("/eapi/v1/discovery/new/songs")
93 | || path.startsWith("/eapi/v1/play/record")
94 | || path.startsWith("/eapi/v1/search/get")
95 | || path.startsWith("/eapi/v3/playlist/detail")
96 | || path.startsWith("/eapi/v3/song/detail")) {
97 | String modified = Utility.modifyDetailApi((String) param.getResult());
98 | XposedBridge.log("修改后:" + modified);
99 | param.setResult(modified);
100 |
101 | } else if (path.startsWith("/eapi/song/enhance/player/url")) {
102 | String modified = Utility.modifyPlayerApi(path, (String) param.getResult());
103 | //XposedBridge.log("play修改后:" + modified);
104 | param.setResult(modified);
105 | } else if (path.startsWith("/eapi/song/enhance/download/url")) {
106 | String modified = Utility.modifyDownloadApi(path, (String) param.getResult());
107 | //XposedBridge.log("down修改后:" + modified);
108 | param.setResult(modified);
109 | }
110 | }
111 | }
112 | }
113 | );
114 | //参数1:storage/sdcard1/netease/cloudmusic/Cache/Download/a1a16b9e8709767b9c9f5bc6a6a089cc
115 | //期待的返回值:a1a16b9e8709767b9c9f5bc6a6a089cc
116 | findAndHookMethod(Utility.CLASS_utils_NeteaseMusicUtils, "a", String.class, new XC_MethodHook() {
117 | @Override
118 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
119 | String path = ((String) param.args[0]);
120 | if (path.contains("/netease/cloudmusic/Cache/Download/")) {
121 | String md5 = Utility.getLastPartOfString(path, "/");
122 | param.setResult(md5);
123 | }
124 | }
125 | });
126 |
127 |
128 | XSharedPreferences xSharedPreferences = new XSharedPreferences(BuildConfig.APPLICATION_ID);
129 | Utility.OVERSEA_MODE_ENABLED = xSharedPreferences.getBoolean(Settings.OVERSEA_MODE_KEY, Settings.OVERSEA_MODE_DEFAULT);
130 |
131 | if (Utility.OVERSEA_MODE_ENABLED) {
132 | Utility.setDnsServer(xSharedPreferences.getString(Settings.DNS_SERVER_KEY, Settings.DNS_SERVER_DEFAULT));
133 |
134 | findAndHookMethod("com.netease.cloudmusic.NeteaseMusicApplication", lpparam.classLoader,
135 | "onCreate", new XC_MethodHook() {
136 | @Override
137 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
138 | Context context = (Context) param.thisObject;
139 | BroadcastReceiver settingChangedReceiver = new BroadcastReceiver() {
140 | @Override
141 | public void onReceive(Context context, Intent intent) {
142 | Utility.setDnsServer(intent.getStringExtra(Settings.DNS_SERVER_KEY));
143 | }
144 | };
145 | IntentFilter settingChangedFilter = new IntentFilter(Settings.SETTING_CHANGED);
146 | context.registerReceiver(settingChangedReceiver, settingChangedFilter);
147 | }
148 | });
149 |
150 | findAndHookMethod(AbstractHttpClient.class, "execute", HttpUriRequest.class, new XC_MethodHook() {
151 | @SuppressWarnings("deprecation")
152 | @Override
153 | protected void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws URISyntaxException, TextParseException {
154 | if (param.args[0] instanceof HttpGet) {
155 | HttpGet httpGet = (HttpGet) param.args[0];
156 | URI uri = httpGet.getURI();
157 | String path = uri.getPath();
158 |
159 | // only process self-generate url
160 | // original music url contains ymusic string, while self-generate url not contain.
161 | if (path.endsWith(".mp3") && !path.contains("/ymusic/")) {
162 | String host = uri.getHost();
163 | String ip = Utility.getIpByHost(host);
164 | if (ip != null) {
165 | httpGet.setURI(new URI("http://" + ip + path));
166 | httpGet.setHeader("Host", host);
167 | param.args[0] = httpGet;
168 | }
169 | }
170 | }
171 | }
172 | }
173 | );
174 | }
175 | }
176 | }
177 | }
178 |
--------------------------------------------------------------------------------
/app/src/main/java/bin/xposed/Unblock163MusicClient/Utility.java:
--------------------------------------------------------------------------------
1 | package bin.xposed.Unblock163MusicClient;
2 |
3 | import android.net.Uri;
4 |
5 | import org.json.JSONArray;
6 | import org.json.JSONException;
7 | import org.json.JSONObject;
8 | import org.xbill.DNS.Lookup;
9 | import org.xbill.DNS.Record;
10 | import org.xbill.DNS.SimpleResolver;
11 | import org.xbill.DNS.TextParseException;
12 | import org.xbill.DNS.Type;
13 |
14 | import java.io.BufferedReader;
15 | import java.io.IOException;
16 | import java.io.InputStreamReader;
17 | import java.lang.reflect.Constructor;
18 | import java.lang.reflect.Field;
19 | import java.lang.reflect.InvocationTargetException;
20 | import java.net.HttpURLConnection;
21 | import java.net.MalformedURLException;
22 | import java.net.URL;
23 | import java.net.UnknownHostException;
24 | import java.util.ArrayList;
25 | import java.util.HashMap;
26 | import java.util.LinkedHashMap;
27 | import java.util.List;
28 | import java.util.Locale;
29 | import java.util.Map;
30 | import java.util.regex.Pattern;
31 |
32 | import de.robv.android.xposed.XposedHelpers;
33 |
34 | import static de.robv.android.xposed.XposedHelpers.findClass;
35 | import static de.robv.android.xposed.XposedHelpers.findConstructorExact;
36 |
37 |
38 | final public class Utility {
39 | final private static Map QUALITY_MAP = new LinkedHashMap() {
40 | {
41 | put("h", 320000);
42 | put("m", 160000);
43 | put("l", 96000);
44 | put("a", 64000);
45 | }
46 | };
47 | final private static Pattern REX_ST = Pattern.compile("\"st\":-?\\d+");
48 | final private static Pattern REX_PL = Pattern.compile("\"pl\":\\d+");
49 | final private static Pattern REX_DL = Pattern.compile("\"dl\":\\d+");
50 | final private static Pattern REX_SUBP = Pattern.compile("\"subp\":\\d+");
51 | final private static Pattern REX_FEE = Pattern.compile("\"fee\":\\d+");
52 |
53 | protected static boolean OVERSEA_MODE_ENABLED;
54 | protected static Field FIELD_utils_c;
55 | private static SimpleResolver CN_DNS_RESOVLER;
56 | private static boolean NEED_TO_CLEAN_DNS_CACHE;
57 | public static Class CLASS_utils_NeteaseMusicUtils;
58 | private static Constructor CONSTRUCTOR_i_f;
59 | private static Constructor CONSTRUCTOR_i_f1;
60 |
61 | protected static boolean init(ClassLoader classLoader) throws NoSuchFieldException {
62 | CLASS_utils_NeteaseMusicUtils = XposedHelpers.findClass("com.netease.cloudmusic.utils.NeteaseMusicUtils", classLoader);
63 | CONSTRUCTOR_i_f = findConstructorExact(findClass(Main.HOOK_CONSTRUCTOR, classLoader), String.class, Map.class);
64 | CONSTRUCTOR_i_f1 = findConstructorExact(findClass(Main.HOOK_CONSTRUCTOR, classLoader), String.class);
65 | FIELD_utils_c = findClass(Main.HOOK_UTILS, classLoader).getDeclaredField("c");//3.1.4
66 | FIELD_utils_c.setAccessible(true);
67 | return true;
68 | }
69 |
70 | protected static String modifyDetailApi(String originalContent) {
71 | String modified = originalContent;
72 | modified = REX_ST.matcher(modified).replaceAll("\"st\":0");
73 | modified = REX_PL.matcher(modified).replaceAll("\"pl\":320000");
74 | modified = REX_DL.matcher(modified).replaceAll("\"dl\":320000");
75 | modified = REX_SUBP.matcher(modified).replaceAll("\"subp\":1");
76 | modified = REX_FEE.matcher(modified).replaceAll("\"fee\":0");
77 | return modified;
78 | }
79 |
80 | protected static String modifyPlayerApi(String url, String originalContent) throws JSONException, IllegalAccessException, InstantiationException, InvocationTargetException, MalformedURLException {
81 | JSONObject originalJson = new JSONObject(originalContent);
82 | JSONArray originalSongArray = originalJson.getJSONArray("data");
83 |
84 | List blockedSongIdList = new ArrayList<>();
85 |
86 | for (int i = 0; i < originalSongArray.length(); i++) {
87 | if (originalSongArray.getJSONObject(i).isNull("url") && originalSongArray.getJSONObject(i).getInt("fee") == 0) {
88 | Long songId = originalSongArray.getJSONObject(i).getLong("id");
89 | blockedSongIdList.add(songId);
90 | }
91 | }
92 |
93 | if (blockedSongIdList.size() > 0) {
94 | int expectBitrate = Integer.parseInt(Uri.parse(url).getQueryParameter("br"));
95 | JSONObject[] newSongJson = getOneQualityFromSongId(blockedSongIdList, expectBitrate);
96 | for (int i = 0; i < originalSongArray.length(); i++) {
97 | if (originalSongArray.getJSONObject(i).isNull("url")) {
98 | String returnUrl;
99 | if (newSongJson[i].getLong("fid") == 0) {
100 | returnUrl = generateUrlByDownload(expectBitrate, blockedSongIdList.get(i));
101 | } else {
102 | returnUrl = generateUrl(newSongJson[i].getLong("fid"));
103 | }
104 | originalSongArray.getJSONObject(i)
105 | .put("url", returnUrl)
106 | .put("br", newSongJson[i].getInt("br"))
107 | .put("size", newSongJson[i].getString("size"))
108 | .put("code", 200)
109 | .put("type", "mp3")
110 | .put("gain", newSongJson[i].getString("vd"));
111 | }
112 | }
113 | return originalJson.toString();
114 | } else
115 | return originalContent;
116 | }
117 |
118 | protected static String modifyDownloadApi(String url, String originalContent) throws JSONException, IllegalAccessException, InstantiationException, InvocationTargetException, MalformedURLException {
119 | JSONObject originalJson = new JSONObject(originalContent);
120 | JSONObject originalSong = originalJson.getJSONObject("data");
121 |
122 | int expectBitrate = Integer.parseInt(Uri.parse(url).getQueryParameter("br"));
123 | if (!originalSong.isNull("url")) {
124 | return originalContent;
125 | }
126 | if (originalSong.getInt("code") == -105 && !Main.OPEN) {
127 | return originalContent;
128 | }
129 | // 收费歌曲返回-105,下架歌曲只能下载128k
130 | if (originalSong.getInt("code") == -105
131 | || originalSong.getInt("br") != expectBitrate) {
132 |
133 | long songId = originalSong.getLong("id");
134 | List list = new ArrayList<>();
135 | list.add(songId);
136 | JSONObject newSong = getOneQualityFromSongId(list, expectBitrate)[0];
137 | String newMd5 = String.format(Locale.getDefault(), "%32d", newSong.getLong("fid")).replace(" ", "0"); // 使用fid避免重复
138 | String newUrl = generateUrl(newSong.getLong("fid"));
139 | originalSong
140 | .put("br", newSong.getInt("br"))
141 | .put("code", 200)
142 | .put("fee", 0)
143 | .put("gain", newSong.getDouble("vd"))
144 | .put("md5", newMd5)
145 | .put("size", newSong.getLong("size"))
146 | .put("type", "mp3")
147 | .put("url", newUrl);
148 |
149 | return originalJson.toString();
150 | }
151 | return originalContent;
152 | }
153 |
154 | private static JSONObject[] getOneQualityFromSongId(List songIds, int expectBitrate) throws JSONException, IllegalAccessException, InstantiationException, InvocationTargetException {
155 | JSONArray c = new JSONArray();
156 | for (long songId : songIds) {
157 | c.put(new JSONObject().put("id", songId).put("v", 0));
158 | }
159 |
160 | Map map = new HashMap<>();
161 | map.put("c", c.toString());
162 |
163 | String page = (String) XposedHelpers.callMethod(XposedHelpers.callMethod(CONSTRUCTOR_i_f.newInstance("v3/song/detail", map), "c"), "i");
164 | JSONObject root = new JSONObject(page);
165 |
166 | return getOneQualityFromJson(root, expectBitrate);
167 | }
168 |
169 | private static JSONObject[] getOneQualityFromJson(JSONObject root, int expectBitrate) throws JSONException {
170 | JSONArray jsonArraySong = root.getJSONArray("songs");
171 | JSONObject[] returnObjects = new JSONObject[jsonArraySong.length()];
172 |
173 | for (int i = 0; i < jsonArraySong.length(); i++) {
174 | JSONObject songObject = (JSONObject) jsonArraySong.get(i);
175 | for (String quality : QUALITY_MAP.keySet()) {
176 | if (songObject.has(quality) && !songObject.isNull(quality)
177 | && expectBitrate >= songObject.getJSONObject(quality).getInt("br")) {
178 | returnObjects[i] = songObject.getJSONObject(quality);
179 | break;
180 | }
181 | }
182 | }
183 |
184 | return returnObjects;
185 | }
186 |
187 | private static String generateUrl(long fid) {
188 | return (String) XposedHelpers.callStaticMethod(CLASS_utils_NeteaseMusicUtils, "a", fid);
189 | }
190 |
191 | private static String generateUrlByDownload(int br, long id) throws IllegalAccessException, InvocationTargetException, InstantiationException, JSONException {
192 | String page = (String) XposedHelpers.callMethod(XposedHelpers.callMethod(CONSTRUCTOR_i_f1.newInstance("song/enhance/download/url?br=" + br + "&id=" + id + "_0"), "c"), "i");
193 | JSONObject jsonObject = new JSONObject(page);
194 | return jsonObject.getJSONObject("data").getString("url");
195 | }
196 |
197 | protected static boolean setDnsServer(String server) {
198 | try {
199 | CN_DNS_RESOVLER = new SimpleResolver(server);
200 | NEED_TO_CLEAN_DNS_CACHE = true;
201 | } catch (UnknownHostException e) {
202 | return false;
203 | }
204 | return true;
205 | }
206 |
207 | protected static String getIpByHost(String domain) throws TextParseException {
208 | // caches mechanism built-in, just look it up
209 | Lookup lookup = new Lookup(domain, Type.A);
210 | lookup.setResolver(CN_DNS_RESOVLER);
211 | if (NEED_TO_CLEAN_DNS_CACHE) {
212 | lookup.setCache(null);
213 | NEED_TO_CLEAN_DNS_CACHE = false;
214 | }
215 | Record[] records = lookup.run();
216 | if (lookup.getResult() == Lookup.SUCCESSFUL) {
217 | // already random, just pick index 0
218 | return records[0].rdataToString();
219 | }
220 | return null;
221 | }
222 |
223 | public static String getPage(String urlString) throws IOException {
224 | URL url = new URL(urlString);
225 | HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
226 |
227 | BufferedReader br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
228 | StringBuilder sb = new StringBuilder();
229 | String line;
230 | while ((line = br.readLine()) != null) {
231 | sb.append(line).append("\n");
232 | }
233 | br.close();
234 | urlConnection.disconnect();
235 | return sb.toString();
236 | }
237 |
238 |
239 | public static String getIpByHostForDnsTest(String domain, String dns) throws TextParseException, UnknownHostException {
240 | Lookup lookup = new Lookup(domain, Type.A);
241 | lookup.setResolver(new SimpleResolver(dns));
242 | lookup.setCache(null);
243 | Record[] records = lookup.run();
244 | if (lookup.getResult() == Lookup.SUCCESSFUL) {
245 | return records[0].rdataToString();
246 | } else
247 | throw new UnknownHostException();
248 | }
249 |
250 | public static String getLastPartOfString(String path, String s) {
251 | int lastIndex = path.lastIndexOf(s);
252 | return path.substring(lastIndex + 1);
253 | }
254 | }
255 |
256 |
257 |
258 |
259 |
--------------------------------------------------------------------------------