From e206460ff7cc06f49b143236ca014285b5e6d127 Mon Sep 17 00:00:00 2001 From: grandiloquent <1785907865@qq.com> Date: Wed, 29 Sep 2021 16:46:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../psycho/explorer/ListenerDelegate.java | 10 +++- .../java/euphoria/psycho/videos/XVideos.java | 48 +++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/euphoria/psycho/explorer/ListenerDelegate.java b/app/src/main/java/euphoria/psycho/explorer/ListenerDelegate.java index 02693c19..a367279c 100644 --- a/app/src/main/java/euphoria/psycho/explorer/ListenerDelegate.java +++ b/app/src/main/java/euphoria/psycho/explorer/ListenerDelegate.java @@ -13,6 +13,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.List; +import java.util.regex.Pattern; import euphoria.psycho.explorer.BookmarkDatabase.Bookmark; import euphoria.psycho.share.DialogShare; @@ -196,9 +197,16 @@ private void onFavorite() { private void onRefresh() { mMainActivity.getWebView().clearCache(true); mMainActivity.getWebView().reload(); - String url=mMainActivity.getWebView().getUrl(); + String url = mMainActivity.getWebView().getUrl(); if (url.startsWith("https://91porn.com/")) new Thread(() -> Porn91.fetchVideos(url, 1)).start(); + else { + Pattern pattern = Pattern.compile("xvideos\\.com/video\\d+"); + if (pattern.matcher(url).find()) { + new Thread(() -> XVideos.fetchVideos(url)).start(); + } + + } } diff --git a/app/src/main/java/euphoria/psycho/videos/XVideos.java b/app/src/main/java/euphoria/psycho/videos/XVideos.java index 551c1a52..aaefa108 100644 --- a/app/src/main/java/euphoria/psycho/videos/XVideos.java +++ b/app/src/main/java/euphoria/psycho/videos/XVideos.java @@ -1,8 +1,17 @@ package euphoria.psycho.videos; +import android.util.Log; import android.util.Pair; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + import java.io.IOException; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; @@ -75,5 +84,44 @@ protected void processVideo(List> videoUriList) { e.printStackTrace(); } } + + public static void fetchVideos(String url) { + String htmlCode = getString(url, new String[][]{ + {"User-Agent", NetShare.PC_USER_AGENT} + }); + JSONArray results = new JSONArray(); + String videoUrl = url; + String videoTitle = StringShare.substring(htmlCode,"html5player.setVideoTitle('","');"); + String videoThumb = StringShare.substring(htmlCode,"html5player.setThumbUrl('","');"); + String videoDuration = StringShare.substring(htmlCode,"