Skip to content

Commit

Permalink
修复 qq 音源 / 暂时移除 kugou 音源
Browse files Browse the repository at this point in the history
  • Loading branch information
ndroi committed Sep 15, 2020
1 parent 35bccf7 commit caf47af
Show file tree
Hide file tree
Showing 13 changed files with 195 additions and 63 deletions.
134 changes: 109 additions & 25 deletions Easy163/.idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Easy163/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions Easy163/.idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Easy163/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId "org.ndroi.easy163"
minSdkVersion 24
targetSdkVersion 28
versionCode 17
versionName "1.7.5"
versionCode 18
versionName "1.7.6"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -28,7 +28,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.alibaba:fastjson:1.1.55.android'
implementation 'com.android.support:appcompat-v7'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.1'
}
2 changes: 1 addition & 1 deletion Easy163/app/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":16,"versionName":"1.7.4","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":17,"versionName":"1.7.5","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
7 changes: 1 addition & 6 deletions Easy163/app/src/main/java/org/ndroi/easy163/core/Local.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,7 @@ public static Song get(String id)
return null;
}
EasyLog.log("本地缓存命中:" + id + " / " + item.providerName);
List<Provider> providers = Arrays.asList(
new KuwoMusic(null),
new MiguMusic(null),
new QQMusic(null),
new KugouMusic(null)
);
List<Provider> providers = Provider.getProviders(null);
Provider targetProvider = null;
for (Provider provider : providers)
{
Expand Down
7 changes: 1 addition & 6 deletions Easy163/app/src/main/java/org/ndroi/easy163/core/Search.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ public class Search
{
public static Song search(Keyword targetKeyword)
{
List<Provider> providers = Arrays.asList(
new KuwoMusic(targetKeyword),
new MiguMusic(targetKeyword),
new QQMusic(targetKeyword),
new KugouMusic(targetKeyword)
);
List<Provider> providers = Provider.getProviders(targetKeyword);
Log.d("search", "start to search: " + targetKeyword.toString());
EasyLog.log("开始全网搜索:" + targetKeyword.toString());
ConcurrencyTask concurrencyTask = new ConcurrencyTask();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,21 @@ public void collectCandidateKeywords()
JSONObject jsonObject = JSONObject.parseObject(str);
if (jsonObject.getIntValue("status") == 1)
{
JSONArray candidates = jsonObject.getJSONObject("data").getJSONArray("lists");
for (Object obj : candidates)
try
{
JSONObject songJsonObject = (JSONObject) obj;
Keyword candidateKeyword = new Keyword();
candidateKeyword.songName = songJsonObject.getString("SongName");
candidateKeyword.singers = Arrays.asList(songJsonObject.getString("SingerName").split("、"));
songJsonObjects.add(songJsonObject);
candidateKeywords.add(candidateKeyword);
JSONArray candidates = jsonObject.getJSONObject("data").getJSONArray("lists");
for (Object obj : candidates)
{
JSONObject songJsonObject = (JSONObject) obj;
Keyword candidateKeyword = new Keyword();
candidateKeyword.songName = songJsonObject.getString("SongName");
candidateKeyword.singers = Arrays.asList(songJsonObject.getString("SingerName").split("、"));
songJsonObjects.add(songJsonObject);
candidateKeywords.add(candidateKeyword);
}
}catch (Exception e)
{
e.printStackTrace();
}
}
}
Expand Down Expand Up @@ -104,7 +110,6 @@ public Song fetchSongByJson(JSONObject jsonObject)
}
String url = "http://trackercdn.kugou.com/i/v2/?key=" + key + "&hash=" + mId +
"&br=hq&appid=1005&pid=2&cmd=25&behavior=play";
//Log.d("Kugou", url);
try
{
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
Expand All @@ -115,7 +120,6 @@ public Song fetchSongByJson(JSONObject jsonObject)
{
byte[] content = ReadStream.read(connection.getInputStream());
String str = new String(content);
//Log.d("Kugou", str);
JSONObject jo = JSONObject.parseObject(str);
song = new Song();
song.url = jo.getJSONArray("url").getString(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,15 @@ static protected Song generateSong(String url)
abstract public void collectCandidateKeywords();
abstract public Song fetchSelectedSong();
abstract public Song fetchSongByJson(JSONObject jsonObject);

public static List<Provider> getProviders(Keyword targetKeyword)
{
List<Provider> providers = Arrays.asList(
new KuwoMusic(targetKeyword),
new MiguMusic(targetKeyword),
new QQMusic(targetKeyword)
//new KugouMusic(targetKeyword)
);
return providers;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public void collectCandidateKeywords()
String query = keyword2Query(targetKeyword);
String url = "https://c.y.qq.com/soso/fcgi-bin/client_search_cp?" +
"ct=24&qqmusic_ver=1298&new_json=1&remoteplace=txt.yqq.center&" +
"searchid=46804741196796149&t=0&aggr=1&cr=1&catZhida=1&lossless=0&" +
"flag_qc=0&p=1&n=20&w=" + query + "&" +
"g_tk=5381&jsonpCallback=MusicJsonCallback10005317669353331&loginUin=0&hostUin=0&" +
"format=jsonp&inCharset=utf8&outCharset=utf-8&notice=0&platform=yqq&needNewCode=0";
"searchid=46343560494538174&t=0&aggr=1&cr=1&catZhida=1&lossless=0&" +
"flag_qc=0&p=1&n=10&w=" + query + "&" +
"g_tk_new_20200303=5381&g_tk=5381&loginUin=0&hostUin=0&" +
"format=json&inCharset=utf8&outCharset=utf-8&notice=0&platform=yqq.json&needNewCode=0";
try
{
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
Expand All @@ -38,9 +38,6 @@ public void collectCandidateKeywords()
{
byte[] content = ReadStream.read(connection.getInputStream());
String str = new String(content);
int p1 = str.indexOf('(');
int p2 = str.lastIndexOf(')');
str = str.substring(p1 + 1, p2);
JSONObject jsonObject = JSONObject.parseObject(str);
if (jsonObject.getIntValue("code") == 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,10 @@ private void writeToRemote(ByteBuffer buffer) throws IOException
{
buffer = HookHttp.getInstance().checkAndHookRequest(tunnel, buffer);
}
tunnel.destSocket.write(buffer);
if(tunnel.destSocket != null) // I don't know why need this
{
tunnel.destSocket.write(buffer);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion Easy163/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:4.0.1'


// NOTE: Do not place your application dependencies here; they belong
Expand Down
3 changes: 2 additions & 1 deletion Easy163/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Tue Sep 15 22:10:41 CST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

0 comments on commit caf47af

Please sign in to comment.