- 直播网速显示问题修复,默认网速显示关闭 (by okjack)

- drpy图片头适配 (by okjack)
- 搜索结果过滤逻辑更改 (by okjack)
- drpy相关优化 (by okjack)
pull/84/head
okjackcaptain 3 years ago
parent 3739c3b477
commit 710b84e407
  1. 1
      .idea/misc.xml
  2. 1
      app/src/main/java/com/github/tvbox/osc/base/App.java
  3. 15
      app/src/main/java/com/github/tvbox/osc/js/JSEngine.java
  4. 127
      app/src/main/java/com/github/tvbox/osc/picasso/MyOkhttpDownLoader.java
  5. 29
      app/src/main/java/com/github/tvbox/osc/ui/activity/FastSearchActivity.java
  6. 14
      app/src/main/java/com/github/tvbox/osc/ui/activity/SearchActivity.java
  7. 12
      app/src/main/java/com/github/tvbox/osc/util/OkGoHelper.java
  8. 3
      app/src/main/java/com/github/tvbox/osc/viewmodel/SourceViewModel.java
  9. 3
      app/src/main/res/layout/activity_live_play.xml

@ -39,6 +39,7 @@
<entry key="..\:/tvbox/TVBoxOS/app/src/main/res/layout/item_quick_search_lite.xml" value="0.3619791666666667" />
<entry key="..\:/tvbox/TVBoxOS/app/src/main/res/layout/loadsir_loading_layout.xml" value="0.3619791666666667" />
<entry key="..\:/tvbox/TVBoxOS/app/src/main/res/layout/player_vod_control_view.xml" value="0.3619791666666667" />
<entry key="app/src/main/res/layout/activity_live_play.xml" value="0.2670906200317965" />
</map>
</option>
</component>

@ -49,6 +49,7 @@ public class App extends MultiDexApplication {
.setSupportSP(false)
.setSupportSubunits(Subunits.MM);
PlayerHelper.init();
JSEngine.getInstance().init();
}
private void initParams() {

@ -44,7 +44,7 @@ public class JSEngine {
return instance;
}
private void init() {
public void init() {
try {
quickJS = QuickJS.createRuntimeWithEventQueue();
module = new ES6Module(quickJS);
@ -60,7 +60,6 @@ public class JSEngine {
public Spider getSpider(SourceBean sourceBean) {
if (sourceBean.getExt().length() == 0) return new SpiderNull();
if (quickJS == null) init();
if (spiders.containsKey(sourceBean.getKey())) return spiders.get(sourceBean.getKey());
String key = "J" + MD5.string2MD5(sourceBean.getKey() + System.currentTimeMillis());
String moduleJsStr = "";
@ -165,17 +164,21 @@ public class JSEngine {
public void stopAll() {
OkGo.getInstance().cancelTag("js_okhttp_tag");
clear();
clearAll();
}
public void clear() {
public void clearAll() {
if (quickJS == null) return;
spiders.clear();
clear();
module.close();
quickJS.close();
jsCache.clear();
module = null;
quickJS = null;
}
public void clear() {
spiders.clear();
jsCache.clear();
}
}

@ -0,0 +1,127 @@
/*
* Copyright (C) 2013 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.tvbox.osc.picasso;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import com.squareup.picasso.Downloader;
import java.io.IOException;
import okhttp3.Cache;
import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
/**
* A {@link Downloader} which uses OkHttp to download images.
*/
public final class MyOkhttpDownLoader implements Downloader {
@VisibleForTesting
final Call.Factory client;
private final Cache cache;
private boolean sharedClient = true;
/**
* Create a new downloader that uses the specified OkHttp instance. A response cache will not be
* automatically configured.
*/
public MyOkhttpDownLoader(OkHttpClient client) {
this.client = client;
this.cache = client.cache();
}
/**
* Create a new downloader that uses the specified {@link Call.Factory} instance.
*/
public MyOkhttpDownLoader(Call.Factory client) {
this.client = client;
this.cache = null;
}
@NonNull
@Override
public Response load(@NonNull Request request) throws IOException {
String url = request.url().toString();
String refer = null;
String ua = null;
String cookie = null;
//检查链接里面是否有自定义cookie
String[] cookieUrl = url.split("@Cookie=");
if (cookieUrl.length > 1) {
url = cookieUrl[0];
cookie = cookieUrl[1];
}
//检查链接里面是否有自定义UA和referer
String[] s = url.split("@Referer=");
if (s.length > 1) {
if (s[0].contains("@User-Agent=")) {
refer = s[1];
url = s[0].split("@User-Agent=")[0];
ua = s[0].split("@User-Agent=")[1];
} else if (s[1].contains("@User-Agent=")) {
refer = s[1].split("@User-Agent=")[0];
url = s[0];
ua = s[1].split("@User-Agent=")[1];
} else {
refer = s[1];
url = s[0];
}
} else {
if (url.contains("@Referer=")) {
url = url.replace("@Referer=", "");
refer = "";
}
if (url.contains("@User-Agent=")) {
ua = url.split("@User-Agent=")[1];
url = url.split("@User-Agent=")[0];
}
}
Request.Builder mRequestBuilder = new Request.Builder().url(url);
if (!TextUtils.isEmpty(cookie)) {
mRequestBuilder.addHeader("cookie", cookieUrl[1]);
}
if (!TextUtils.isEmpty(ua)) {
if (TextUtils.isEmpty(refer)) {
mRequestBuilder.addHeader("user-agent", ua);
} else {
mRequestBuilder.addHeader("user-agent", ua).addHeader("referer", refer);
}
} else {
if (!TextUtils.isEmpty(refer)) {
mRequestBuilder.addHeader("referer", refer);
}
}
return client.newCall(mRequestBuilder.build()).execute();
}
@Override
public void shutdown() {
if (!sharedClient && cache != null) {
try {
cache.close();
} catch (IOException ignored) {
}
}
}
}

@ -2,6 +2,7 @@ package com.github.tvbox.osc.ui.activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -450,21 +451,31 @@ public class FastSearchActivity extends BaseActivity {
}
}
private boolean matchSearchResult(String name, String searchTitle) {
if (TextUtils.isEmpty(name) || TextUtils.isEmpty(searchTitle)) return false;
searchTitle = searchTitle.trim();
String[] arr = searchTitle.split("\\s+");
int matchNum = 0;
for(String one : arr) {
if (name.contains(one)) matchNum++;
}
return matchNum == arr.length ? true : false;
}
private void searchData(AbsXml absXml) {
String lastSourceKey = "";
if (absXml != null && absXml.movie != null && absXml.movie.videoList != null && absXml.movie.videoList.size() > 0) {
List<Movie.Video> data = new ArrayList<>();
for (Movie.Video video : absXml.movie.videoList) {
if (video.name.contains(searchTitle)) {
data.add(video);
if (!resultVods.containsKey(video.sourceKey)) {
resultVods.put(video.sourceKey, new ArrayList<Movie.Video>());
}
resultVods.get(video.sourceKey).add(video);
if (video.sourceKey != lastSourceKey) {
lastSourceKey = this.addWordAdapterIfNeed(video.sourceKey);
}
if (!matchSearchResult(video.name, searchTitle)) continue;
data.add(video);
if (!resultVods.containsKey(video.sourceKey)) {
resultVods.put(video.sourceKey, new ArrayList<Movie.Video>());
}
resultVods.get(video.sourceKey).add(video);
if (video.sourceKey != lastSourceKey) {
lastSourceKey = this.addWordAdapterIfNeed(video.sourceKey);
}
}

@ -482,12 +482,22 @@ public class SearchActivity extends BaseActivity {
}
}
private boolean matchSearchResult(String name, String searchTitle) {
if (TextUtils.isEmpty(name) || TextUtils.isEmpty(searchTitle)) return false;
searchTitle = searchTitle.trim();
String[] arr = searchTitle.split("\\s+");
int matchNum = 0;
for(String one : arr) {
if (name.contains(one)) matchNum++;
}
return matchNum == arr.length ? true : false;
}
private void searchData(AbsXml absXml) {
if (absXml != null && absXml.movie != null && absXml.movie.videoList != null && absXml.movie.videoList.size() > 0) {
List<Movie.Video> data = new ArrayList<>();
for (Movie.Video video : absXml.movie.videoList) {
if (video.name.contains(searchTitle))
data.add(video);
if (matchSearchResult(video.name, searchTitle)) data.add(video);
}
if (searchAdapter.getData().size() > 0) {
searchAdapter.addData(data);

@ -1,13 +1,15 @@
package com.github.tvbox.osc.util;
import android.graphics.Bitmap;
import com.github.tvbox.osc.base.App;
import com.github.tvbox.osc.picasso.MyOkhttpDownLoader;
import com.github.tvbox.osc.util.SSL.SSLSocketFactoryCompat;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.https.HttpsUtils;
import com.lzy.okgo.interceptor.HttpLoggingInterceptor;
import com.lzy.okgo.model.HttpHeaders;
import com.orhanobut.hawk.Hawk;
import com.squareup.picasso.OkHttp3Downloader;
import com.squareup.picasso.Picasso;
import java.io.File;
@ -160,8 +162,12 @@ public class OkGoHelper {
}
static void initPicasso(OkHttpClient client) {
OkHttp3Downloader downloader = new OkHttp3Downloader(client);
Picasso picasso = new Picasso.Builder(App.getInstance()).downloader(downloader).build();
client.dispatcher().setMaxRequestsPerHost(10);
MyOkhttpDownLoader downloader = new MyOkhttpDownLoader(client);
Picasso picasso = new Picasso.Builder(App.getInstance())
.downloader(downloader)
.defaultBitmapConfig(Bitmap.Config.RGB_565)
.build();
Picasso.setSingletonInstance(picasso);
}

@ -485,9 +485,12 @@ public class SourceViewModel extends ViewModel {
String search = sp.searchContent(wd, false);
if(!TextUtils.isEmpty(search)){
json(searchResult, search, sourceBean.getKey());
} else {
json(searchResult, "", sourceBean.getKey());
}
} catch (Throwable th) {
th.printStackTrace();
json(searchResult, "", sourceBean.getKey());
}
} else if (type == 0 || type == 1) {
OkGo.<String>get(sourceBean.getApi())

@ -770,7 +770,8 @@
android:layout_toLeftOf="@+id/iv_circle_bg"
android:gravity="center"
android:singleLine="true"
android:text="11Kb/s"
android:text=""
tools:text="0Kb/s"
android:textColor="#FFFCFFFF"
android:textSize="@dimen/vs_20" />
</RelativeLayout>

Loading…
Cancel
Save