Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
grandiloquent committed Sep 29, 2021
1 parent 993c653 commit e206460
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

}

}

Expand Down
48 changes: 48 additions & 0 deletions app/src/main/java/euphoria/psycho/videos/XVideos.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -75,5 +84,44 @@ protected void processVideo(List<Pair<String, String>> 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,"<meta property=\"og:duration\" content=\"","\"");
JSONObject video = new JSONObject();
try {
video.put("title", videoTitle);
video.put("thumbnail", videoThumb);
video.put("url", videoUrl);
int duration = 0;
try {
duration = Integer.parseInt(videoDuration);
} catch (Exception ignored) {
}
video.put("duration", duration);
} catch (JSONException ignored) {
Log.e("B5aOx2", String.format("fetchVideos, %s", ignored));
}
results.put(video);
try {
URL uri = new URL("http://47.106.105.122/api/video");
HttpURLConnection connection = (HttpURLConnection) uri.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
OutputStream out = connection.getOutputStream();
out.write(results.toString().getBytes(StandardCharsets.UTF_8));
out.close();
int code = connection.getResponseCode();
} catch (IOException ignored) {
}


}
}

0 comments on commit e206460

Please sign in to comment.