From 3bba681713942802e3a811a9b9c4a63f424d364e Mon Sep 17 00:00:00 2001 From: grandiloquent <1785907865@qq.com> Date: Mon, 27 Sep 2021 08:34: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 --- app/build.gradle | 1 + .../java/euphoria/psycho/share/NetShare.java | 8 +++- .../euphoria/psycho/videos/VideosHelper.java | 42 +++++++++++++++++-- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1c3d1ba0..44ede70d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,6 +32,7 @@ android { } dependencies { + implementation 'org.brotli:dec:0.1.1' implementation 'com.tencent.bugly:crashreport:latest.release' implementation 'com.github.bumptech.glide:glide:4.12.0' implementation('com.github.evgenyneu:js-evaluator-for-android:v4.0.0') { diff --git a/app/src/main/java/euphoria/psycho/share/NetShare.java b/app/src/main/java/euphoria/psycho/share/NetShare.java index 18993a96..86c5b6ad 100644 --- a/app/src/main/java/euphoria/psycho/share/NetShare.java +++ b/app/src/main/java/euphoria/psycho/share/NetShare.java @@ -4,6 +4,8 @@ import android.content.Context; import android.net.ConnectivityManager; +import org.brotli.dec.BrotliInputStream; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -83,7 +85,9 @@ public static String readString(HttpURLConnection connection) { else if (contentEncoding != null && contentEncoding.equals("br")) { in = new BrotliInputStream(connection.getInputStream()); } */ - else { + if (contentEncoding != null && contentEncoding.equals("br")) { + in = new BrotliInputStream(connection.getInputStream()); + } else { in = connection.getInputStream(); } reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)); @@ -124,7 +128,7 @@ public static boolean isInternetAvailable() { return false; } - public static void disableSSLCertificateChecking() { + public static void disableSSLCertificateChecking() { TrustManager[] trustAllCerts = new TrustManager[]{ new X509TrustManager() { @Override diff --git a/app/src/main/java/euphoria/psycho/videos/VideosHelper.java b/app/src/main/java/euphoria/psycho/videos/VideosHelper.java index aad9b678..d4ee70e4 100644 --- a/app/src/main/java/euphoria/psycho/videos/VideosHelper.java +++ b/app/src/main/java/euphoria/psycho/videos/VideosHelper.java @@ -47,9 +47,27 @@ public static String extract91PornVideoAddress(String uri) { try { headers = getLocationAddCookie( "https://91porn.com/index.php", - null + new String[][]{ + {"Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"}, + {"Accept-Encoding", "gzip, deflate, br"}, + {"Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8"}, + {"Cache-Control", "no-cache"}, + {"Connection", "keep-alive"}, + {"Host", "91porn.com"}, + {"Pragma", "no-cache"}, + {"sec-ch-ua", "\"Google Chrome\";v=\"93\", \" Not;A Brand\";v=\"99\", \"Chromium\";v=\"93\""}, + {"sec-ch-ua-mobile", "?0"}, + {"sec-ch-ua-platform", "\"Windows\""}, + {"Sec-Fetch-Dest", "document"}, + {"Sec-Fetch-Mode", "navigate"}, + {"Sec-Fetch-Site", "none"}, + {"Sec-Fetch-User", "?1"}, + {"Upgrade-Insecure-Requests", "1"}, + {"User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36"}} ); + Log.e("B5aOx2", String.format("extract91PornVideoAddress, %s", headers[1])); } catch (IOException e) { + Log.e("B5aOx2", String.format("extract91PornVideoAddress, %s", e.getMessage())); e.printStackTrace(); } if (headers == null) { @@ -59,10 +77,26 @@ public static String extract91PornVideoAddress(String uri) { // get around the 50 views per day // for non members limitation String response = getString(uri, new String[][]{ - {"Referer", "https://91porn.com"}, + {"Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"}, + {"Accept-Encoding", "gzip, deflate, br"}, + {"Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8"}, + {"Cache-Control", "no-cache"}, + {"Connection", "keep-alive"}, + {"Host", "91porn.com"}, + {"Pragma", "no-cache"}, + {"sec-ch-ua", "\"Google Chrome\";v=\"93\", \" Not;A Brand\";v=\"99\", \"Chromium\";v=\"93\""}, + {"sec-ch-ua-mobile", "?0"}, + {"sec-ch-ua-platform", "\"Windows\""}, + {"Sec-Fetch-Dest", "document"}, + {"Sec-Fetch-Mode", "navigate"}, + {"Sec-Fetch-Site", "none"}, + {"Sec-Fetch-User", "?1"}, + {"Upgrade-Insecure-Requests", "1"}, + {"User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36"}, {"X-Forwarded-For", NetShare.randomIp()}, {"Cookie", headers[1]} }); + Log.e("B5aOx2", String.format("extract91PornVideoAddress, %s", response)); if (response == null) { // byte[] buffer = new byte[128]; // byte[] buf = uri.getBytes(StandardCharsets.UTF_8); @@ -118,12 +152,12 @@ public static String getLocation(String uri, String[][] headers) throws IOExcept public static String[] getLocationAddCookie(String uri, String[][] headers) throws IOException { URL url = new URL(uri); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); + //urlConnection.setRequestProperty("User-Agent", USER_AGENT); if (headers != null) { for (String[] header : headers) { urlConnection.setRequestProperty(header[0], header[1]); } } - urlConnection.setRequestProperty("User-Agent", USER_AGENT); urlConnection.setInstanceFollowRedirects(false); Map> listMap = urlConnection.getHeaderFields(); StringBuilder stringBuilder = new StringBuilder(); @@ -135,6 +169,7 @@ public static String[] getLocationAddCookie(String uri, String[][] headers) thro } } } + Log.e("B5aOx2", String.format("getLocationAddCookie, %s", urlConnection.getResponseCode())); return new String[]{urlConnection.getHeaderField("Location"), stringBuilder.toString()}; } @@ -179,6 +214,7 @@ public static String getString(String uri, String[][] headers) { urlConnection.setRequestProperty(header[0], header[1]); } } + //NetShare.iterateResponseHeader(urlConnection); int code = urlConnection.getResponseCode(); if (code < 400 && code >= 200) { return NetShare.readString(urlConnection);