Skip to content

Commit

Permalink
再次优化嗅探 解决收藏夹闪退
Browse files Browse the repository at this point in the history
  • Loading branch information
q215613905 committed Sep 29, 2022
1 parent 146944f commit 259a56e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,6 @@ WebResourceResponse checkIsVideo(String url, HashMap<String, String> headers) {
} else {
playUrl(url, null);
}
mController.setUrlTitle("视频地址:"+url);
stopLoadWebView(false);
}
}
Expand All @@ -1390,9 +1389,9 @@ WebResourceResponse checkIsVideo(String url, HashMap<String, String> headers) {
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
WebResourceResponse response = checkIsVideo(url, null);
if (response == null)
return super.shouldInterceptRequest(view, url);
else
// if (response == null)
// return super.shouldInterceptRequest(view, url);
// else
return response;
}

Expand Down Expand Up @@ -1420,9 +1419,9 @@ public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceReque

}
WebResourceResponse response = checkIsVideo(url, webHeaders);
if (response == null)
return super.shouldInterceptRequest(view, request);
else
// if (response == null)
// return super.shouldInterceptRequest(view, request);
// else
return response;
}

Expand Down Expand Up @@ -1562,7 +1561,6 @@ public XWalkWebResourceResponse shouldInterceptLoadRequest(XWalkView view, XWalk
} else {
playUrl(url, null);
}
mController.setUrlTitle("视频地址:"+url);
stopLoadWebView(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.tvbox.osc.ui.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

Expand Down Expand Up @@ -29,7 +30,12 @@ protected void convert(BaseViewHolder helper, VodCollect item) {
helper.setVisible(R.id.tvArea, false);
helper.setVisible(R.id.tvNote, false);
TextView tvYear = helper.getView(R.id.tvYear);
tvYear.setText(ApiConfig.get().getSource(item.sourceKey).getName());
if (ApiConfig.get().getSource(item.sourceKey)!=null) {
tvYear.setText(ApiConfig.get().getSource(item.sourceKey).getName());
tvYear.setVisibility(View.VISIBLE);
} else {
tvYear.setVisibility(View.GONE);
}
helper.setText(R.id.tvName, item.name);
ImageView ivThumb = helper.getView(R.id.ivThumb);
//由于部分电视机使用glide报错
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1177,9 +1177,9 @@ public void run() {
// webUserAgent = "Mozilla/5.0 (Linux; Android 6.0.1; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Mobile Safari/537.36";
if (mXwalkWebView != null) {
mXwalkWebView.stopLoading();
if(webUserAgent != null) {
mXwalkWebView.getSettings().setUserAgentString(webUserAgent);
}
// if(webUserAgent != null) {
// mXwalkWebView.getSettings().setUserAgentString(webUserAgent);
// }
//mXwalkWebView.clearCache(true);
if(webHeaderMap != null){
mXwalkWebView.loadUrl(url,webHeaderMap);
Expand All @@ -1189,9 +1189,9 @@ public void run() {
}
if (mSysWebView != null) {
mSysWebView.stopLoading();
if(webUserAgent != null) {
mSysWebView.getSettings().setUserAgentString(webUserAgent);
}
// if(webUserAgent != null) {
// mSysWebView.getSettings().setUserAgentString(webUserAgent);
// }
//mSysWebView.clearCache(true);
if(webHeaderMap != null){
mSysWebView.loadUrl(url,webHeaderMap);
Expand Down Expand Up @@ -1394,7 +1394,6 @@ WebResourceResponse checkIsVideo(String url, HashMap<String, String> headers) {
} else {
playUrl(url, null);
}
mController.setUrlTitle("视频地址:"+url);
stopLoadWebView(false);
}
}
Expand All @@ -1408,9 +1407,9 @@ WebResourceResponse checkIsVideo(String url, HashMap<String, String> headers) {
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
WebResourceResponse response = checkIsVideo(url, null);
if (response == null)
return super.shouldInterceptRequest(view, url);
else
// if (response == null)
// return super.shouldInterceptRequest(view, url);
// else
return response;
}

Expand Down Expand Up @@ -1438,9 +1437,9 @@ public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceReque

}
WebResourceResponse response = checkIsVideo(url, webHeaders);
if (response == null)
return super.shouldInterceptRequest(view, request);
else
// if (response == null)
// return super.shouldInterceptRequest(view, request);
// else
return response;
}

Expand Down Expand Up @@ -1580,7 +1579,6 @@ public XWalkWebResourceResponse shouldInterceptLoadRequest(XWalkView view, XWalk
} else {
playUrl(url, null);
}
mController.setUrlTitle("视频地址:"+url);
stopLoadWebView(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static String getFilePrefixName(String fileName) {

//增加对flv|avi|mkv|rm|wmv|mpg等几种视频格式的支持
//private static final Pattern snifferMatch = Pattern.compile("http((?!http).){26,}?\\.(m3u8|mp4)\\?.*|http((?!http).){26,}\\.(m3u8|mp4)|http((?!http).){26,}?/m3u8\\?pt=m3u8.*|http((?!http).)*?default\\.ixigua\\.com/.*|http((?!http).)*?cdn-tos[^\\?]*|http((?!http).)*?/obj/tos[^\\?]*|http.*?/player/m3u8play\\.php\\?url=.*|http.*?/player/.*?[pP]lay\\.php\\?url=.*|http.*?/playlist/m3u8/\\?vid=.*|http.*?\\.php\\?type=m3u8&.*|http.*?/download.aspx\\?.*|http.*?/api/up_api.php\\?.*|https.*?\\.66yk\\.cn.*|http((?!http).)*?netease\\.com/file/.*");
private static final Pattern snifferMatch = Pattern.compile("http((?!http).)*?default\\.365yg\\.com/.*|http((?!http).){26,}?\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg)\\?.*|http((?!http).){26,}\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg)|http((?!http).){20,}?/m3u8\\?pt=m3u8.*|http((?!http).)*?default\\.ixigua\\.com/.*|http((?!http).)*?dycdn-tos\\.pstatp[^\\?]*|http.*?/player/m3u8play\\.php\\?url=.*|http.*?/player/.*?[pP]lay\\.php\\?url=.*|http.*?/playlist/m3u8/\\?vid=.*|http.*?\\.php\\?type=m3u8&.*|http.*?/download.aspx\\?.*|http.*?/api/up_api.php\\?.*|https.*?\\.66yk\\.cn.*|http((?!http).)*?netease\\.com/file/.*");
private static final Pattern snifferMatch = Pattern.compile("http((?!http).)*?default\\.365yg\\.com/.*|http((?!http).){26,}?\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg)\\?.*|http((?!http).){26,}\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg)|http((?!http).){20,}?/m3u8\\?pt=m3u8.*|http((?!http).)*?default\\.ixigua\\.com/.*|http((?!http).)*?dycdn-tos\\.pstatp[^\\?]*|http.*?/play.{0,3}\\?.{2,8}=.*|http.*?/player/m3u8play\\.php\\?url=.*|http.*?/player/.*?[pP]lay\\.php\\?url=.*|http.*?/playlist/m3u8/\\?vid=.*|http.*?\\.php\\?type=m3u8&.*|http.*?/download.aspx\\?.*|http.*?/api/up_api.php\\?.*|https.*?\\.66yk\\.cn.*|http((?!http).)*?netease\\.com/file/.*");
public static boolean isVideoFormat(String url) {
if (url.contains("=http") || url.contains(".html")) {
return false;
Expand Down

0 comments on commit 259a56e

Please sign in to comment.