diff --git a/app/src/main/java/me/bello/viptv/ui/VideoSiteActivity.java b/app/src/main/java/me/bello/viptv/ui/VideoSiteActivity.java index 5c030ee..4c403d4 100644 --- a/app/src/main/java/me/bello/viptv/ui/VideoSiteActivity.java +++ b/app/src/main/java/me/bello/viptv/ui/VideoSiteActivity.java @@ -36,6 +36,7 @@ import org.jsoup.Connection; import org.jsoup.Jsoup; +import java.net.URLDecoder; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; @@ -72,6 +73,7 @@ private List siteList = new ArrayList<>(); private List analysisList = new ArrayList<>(); + private String referUrl; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -123,22 +125,39 @@ @Override public void onPageFinished(WebView webView, String s) { super.onPageFinished(webView, s); - webTitle = StringTool.getPageTitle(mWebView.getTitle()); + + // 乐视请求标题需要带refer + if (s.contains("le.com/vplay_")){ + referUrl = s; + } +// log("onPageFinished ===> " + webView.getTitle() + ", " + s); + String t = StringTool.getPageTitle(webView.getTitle()); + if(!t.isEmpty()){ + webTitle = t; + } loadingDlg.dismiss(); + + log("onPageFinished ===> " + webTitle); } @Override public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) { String s = webResourceRequest.getUrl().toString(); - log("shouldInterceptRequest 4 =============>" + s); if (s.contains("kvcollect") || s.contains("analytics/upload?")){ return null; } +// if (s.contains(".jpg") || s.contains(".png") || s.contains(".gif") || s.contains(".ico") || s.contains(".css") || s.contains(".js")){ +// +// } else { + log("shouldInterceptRequest 4 =============>" + s); +// } + + // 爱奇艺获取标题 if (s.contains("/playervideoinfo?")){ try { Connection con = Jsoup.connect(s); Connection.Response doc = con.timeout(10000).ignoreContentType(true).execute(); - String body = doc.body().toString(); + String body = doc.body(); Pattern p = Pattern.compile("\"vn\":\"(.*?)\","); Matcher m = p.matcher(body); if (m.find()){ @@ -151,6 +170,71 @@ } } + + // 腾讯视频获取标题 + if (s.contains("api/long_video_rec")){ + try { + Pattern p = Pattern.compile("title=(.*?)&"); + Matcher m = p.matcher(s); + if (m.find()){ + log("body ==> " + URLDecoder.decode(m.group(1), "utf-8")); + webTitle = URLDecoder.decode(m.group(1), "utf-8"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + // 优酷获取标题 + if (s.contains("mf.atm.youku.com/mf")){ + try { + Pattern p = Pattern.compile("ti=(.*?)&"); + Matcher m = p.matcher(s); + if (m.find()){ + log("body ==> " + URLDecoder.decode(m.group(1), "utf-8")); + webTitle = URLDecoder.decode(m.group(1), "utf-8"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + // 搜狐获取标题 + if (s.contains("sohu.com/phone_playinfo?")){ + try { + Connection con = Jsoup.connect(s); + Connection.Response doc = con.timeout(10000).ignoreContentType(true).execute(); + String body = doc.body(); + Pattern p = Pattern.compile("\"video_name\":\"(.*?)\""); + Matcher m = p.matcher(body); + if (m.find()){ + log("body ==> " + m.group(1)); + webTitle = m.group(1); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + // 乐视获取标题 + if (s.contains("apiplay/pageInfo")){ + try { + Connection con = Jsoup.connect(s); + con.header("Referer", referUrl); + Connection.Response doc = con.timeout(10000).ignoreContentType(true).execute(); + String body = doc.body(); +// log("body ==> " + s + "\n" +body); + Pattern p = Pattern.compile("\"title\":\"(.*?)\""); + Matcher m = p.matcher(body); + if (m.find()){ + log("body ==> " + m.group(1)); + webTitle = m.group(1); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + return super.shouldInterceptRequest(webView, webResourceRequest); } }); @@ -172,7 +256,7 @@ return super.shouldInterceptRequest(webView, webResourceRequest); } String url = uri.toString(); - log("shouldInterceptRequest=============>" + url); +// log("shouldInterceptRequest=============>" + url); if (url.contains("/") && !url.contains("=http")) { String[] us = url.split("/"); if (us[us.length - 1].contains(".m3u8") || us[us.length - 1].contains(".mp4")) {