pull/101/head
jhengazuki 2 months ago
parent 1068162666
commit c5e03f6cbf
  1. 6
      app/build.gradle
  2. 2
      app/src/main/AndroidManifest.xml
  3. 142
      app/src/main/java/com/github/catvod/MainActivity.java
  4. 129
      app/src/main/java/com/github/catvod/debug/MainActivity.java
  5. 4
      app/src/main/java/com/github/catvod/spider/Init.java
  6. 8
      app/src/main/java/com/github/catvod/spider/Market.java
  7. 2
      app/src/main/java/com/github/catvod/utils/Notify.java
  8. 74
      app/src/main/res/layout/activity_main.xml
  9. BIN
      jar/custom_spider.jar
  10. 2
      jar/custom_spider.jar.md5

@ -16,6 +16,10 @@ android {
targetSdk 36
}
buildFeatures {
viewBinding true
}
buildTypes {
release {
minifyEnabled true
@ -45,8 +49,10 @@ dependencies {
implementation 'com.squareup.okhttp3:okhttp:' + okhttpVersion
implementation 'com.github.thegrizzlylabs:sardine-android:0.9'
implementation 'wang.harlon.quickjs:wrapper-android:3.2.3'
implementation 'com.google.android.flexbox:flexbox:3.0.0'
implementation 'com.google.code.gson:gson:2.13.2'
implementation 'com.hierynomus:smbj:0.14.0'
implementation 'com.orhanobut:logger:2.2.0'
implementation 'androidx.core:core:1.17.0'
implementation 'org.jsoup:jsoup:1.21.2'
}

@ -14,7 +14,7 @@
android:usesCleartextTraffic="true">
<activity
android:name=".debug.MainActivity"
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

@ -0,0 +1,142 @@
package com.github.catvod;
import android.app.Activity;
import android.os.Bundle;
import com.github.catvod.crawler.Spider;
import com.github.catvod.databinding.ActivityMainBinding;
import com.github.catvod.spider.Init;
import com.github.catvod.spider.PTT;
import com.github.catvod.spider.Proxy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParser;
import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.Logger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class MainActivity extends Activity {
private ActivityMainBinding binding;
private ExecutorService executor;
private Spider spider;
private Gson gson;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
gson = new GsonBuilder().setPrettyPrinting().create();
Logger.addLogAdapter(new AndroidLogAdapter());
executor = Executors.newCachedThreadPool();
executor.execute(this::initSpider);
spider = new PTT();
initView();
initEvent();
}
private void initView() {
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
}
private void initEvent() {
binding.home.setOnClickListener(view -> executor.execute(this::homeContent));
binding.homeVideo.setOnClickListener(view -> executor.execute(this::homeVideoContent));
binding.category.setOnClickListener(view -> executor.execute(this::categoryContent));
binding.detail.setOnClickListener(view -> executor.execute(this::detailContent));
binding.player.setOnClickListener(view -> executor.execute(this::playerContent));
binding.search.setOnClickListener(view -> executor.execute(this::searchContent));
binding.live.setOnClickListener(view -> executor.execute(this::liveContent));
binding.proxy.setOnClickListener(view -> executor.execute(this::proxy));
}
private void initSpider() {
try {
Init.init(getApplicationContext());
spider.init(this, "");
} catch (Throwable e) {
e.printStackTrace();
}
}
public void homeContent() {
try {
String result = gson.toJson(JsonParser.parseString(spider.homeContent(true)));
Init.post(() -> binding.result.setText(result));
} catch (Throwable e) {
e.printStackTrace();
}
}
public void homeVideoContent() {
try {
String result = gson.toJson(JsonParser.parseString(spider.homeVideoContent()));
Init.post(() -> binding.result.setText(result));
} catch (Throwable e) {
e.printStackTrace();
}
}
public void categoryContent() {
try {
HashMap<String, String> extend = new HashMap<>();
extend.put("c", "19");
extend.put("year", "2024");
String result = gson.toJson(JsonParser.parseString(spider.categoryContent("3", "2", true, extend)));
Init.post(() -> binding.result.setText(result));
} catch (Throwable e) {
e.printStackTrace();
}
}
public void detailContent() {
try {
String result = gson.toJson(JsonParser.parseString(spider.detailContent(List.of("78702"))));
Init.post(() -> binding.result.setText(result));
} catch (Throwable e) {
e.printStackTrace();
}
}
public void playerContent() {
try {
String result = gson.toJson(JsonParser.parseString(spider.playerContent("", "382044/1/78", new ArrayList<>())));
Init.post(() -> binding.result.setText(result));
} catch (Throwable e) {
e.printStackTrace();
}
}
public void searchContent() {
try {
String result = gson.toJson(JsonParser.parseString(spider.searchContent("我的人间烟火", false)));
Init.post(() -> binding.result.setText(result));
} catch (Throwable e) {
e.printStackTrace();
}
}
public void liveContent() {
try {
String result = gson.toJson(JsonParser.parseString(spider.liveContent("")));
Init.post(() -> binding.result.setText(result));
} catch (Throwable e) {
e.printStackTrace();
}
}
public void proxy() {
try {
Map<String, String> params = new HashMap<>();
Logger.t("liveContent").d(Proxy.proxy(params));
} catch (Throwable e) {
e.printStackTrace();
}
}
}

@ -1,129 +0,0 @@
package com.github.catvod.debug;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import com.github.catvod.R;
import com.github.catvod.crawler.Spider;
import com.github.catvod.spider.Init;
import com.github.catvod.spider.MQiTV;
import com.github.catvod.spider.Proxy;
import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.Logger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class MainActivity extends Activity {
private ExecutorService executor;
private Spider spider;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button homeContent = findViewById(R.id.homeContent);
Button homeVideoContent = findViewById(R.id.homeVideoContent);
Button categoryContent = findViewById(R.id.categoryContent);
Button detailContent = findViewById(R.id.detailContent);
Button playerContent = findViewById(R.id.playerContent);
Button searchContent = findViewById(R.id.searchContent);
Button liveContent = findViewById(R.id.liveContent);
Button proxy = findViewById(R.id.proxy);
homeContent.setOnClickListener(view -> executor.execute(this::homeContent));
homeVideoContent.setOnClickListener(view -> executor.execute(this::homeVideoContent));
categoryContent.setOnClickListener(view -> executor.execute(this::categoryContent));
detailContent.setOnClickListener(view -> executor.execute(this::detailContent));
playerContent.setOnClickListener(view -> executor.execute(this::playerContent));
searchContent.setOnClickListener(view -> executor.execute(this::searchContent));
liveContent.setOnClickListener(view -> executor.execute(this::liveContent));
proxy.setOnClickListener(view -> executor.execute(this::proxy));
Logger.addLogAdapter(new AndroidLogAdapter());
executor = Executors.newCachedThreadPool();
executor.execute(this::initSpider);
}
private void initSpider() {
try {
Init.init(getApplicationContext());
spider = new MQiTV();
spider.init(this, "");
} catch (Throwable e) {
e.printStackTrace();
}
}
public void homeContent() {
try {
Logger.t("homeContent").d(spider.homeContent(true));
} catch (Throwable e) {
e.printStackTrace();
}
}
public void homeVideoContent() {
try {
Logger.t("homeVideoContent").d(spider.homeVideoContent());
} catch (Throwable e) {
e.printStackTrace();
}
}
public void categoryContent() {
try {
HashMap<String, String> extend = new HashMap<>();
extend.put("c", "19");
extend.put("year", "2024");
Logger.t("categoryContent").d(spider.categoryContent("3", "2", true, extend));
} catch (Throwable e) {
e.printStackTrace();
}
}
public void detailContent() {
try {
Logger.t("detailContent").d(spider.detailContent(Arrays.asList("78702")));
} catch (Throwable e) {
e.printStackTrace();
}
}
public void playerContent() {
try {
Logger.t("playerContent").d(spider.playerContent("", "382044/1/78", new ArrayList<>()));
} catch (Throwable e) {
e.printStackTrace();
}
}
public void searchContent() {
try {
Logger.t("searchContent").d(spider.searchContent("我的人间烟火", false));
} catch (Throwable e) {
e.printStackTrace();
}
}
public void liveContent() {
try {
Logger.t("liveContent").d(spider.liveContent(""));
} catch (Throwable e) {
e.printStackTrace();
}
}
public void proxy() {
try {
Map<String, String> params = new HashMap<>();
Logger.t("liveContent").d(Proxy.proxy(params));
} catch (Throwable e) {
e.printStackTrace();
}
}
}

@ -58,11 +58,11 @@ public class Init {
get().executor.execute(runnable);
}
public static void run(Runnable runnable) {
public static void post(Runnable runnable) {
get().handler.post(runnable);
}
public static void run(Runnable runnable, int delay) {
public static void post(Runnable runnable, int delay) {
get().handler.postDelayed(runnable, delay);
}

@ -62,7 +62,7 @@ public class Market extends Spider {
try {
if (isBusy()) return "";
setBusy(true);
Init.run(this::setDialog, 500);
Init.post(this::setDialog, 500);
Response response = OkHttp.newCall(action);
File file = Path.create(new File(Path.download(), Uri.parse(action).getLastPathSegment()));
download(file, response.body().byteStream(), Double.parseDouble(response.header("Content-Length", "1")));
@ -103,7 +103,7 @@ public class Market extends Spider {
}
private void setDialog() {
Init.run(() -> {
Init.post(() -> {
try {
dialog = new ProgressDialog(Init.activity());
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
@ -116,7 +116,7 @@ public class Market extends Spider {
}
private void dismiss() {
Init.run(() -> {
Init.post(() -> {
try {
setBusy(false);
if (dialog != null) dialog.dismiss();
@ -127,7 +127,7 @@ public class Market extends Spider {
}
private void setProgress(int value) {
Init.run(() -> {
Init.post(() -> {
try {
if (dialog != null) dialog.setProgress(value);
} catch (Exception e) {

@ -18,7 +18,7 @@ public class Notify {
}
public static void show(String text) {
Init.run(() -> get().makeText(text));
Init.post(() -> get().makeText(text));
}
private void makeText(String message) {

@ -1,77 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
android:orientation="vertical">
<LinearLayout
<com.google.android.flexbox.FlexboxLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">
android:layout_height="wrap_content"
android:padding="16dp"
app:flexDirection="row"
app:flexWrap="wrap"
app:justifyContent="flex_start">
<Button
android:id="@+id/homeContent"
android:id="@+id/home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="homeContent"
android:text="home"
android:textAllCaps="false" />
<Button
android:id="@+id/homeVideoContent"
android:id="@+id/homeVideo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="homeVideoContent"
android:text="homeVideo"
android:textAllCaps="false" />
<Button
android:id="@+id/categoryContent"
android:id="@+id/category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="categoryContent"
android:text="category"
android:textAllCaps="false" />
<Button
android:id="@+id/detailContent"
android:id="@+id/detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="detailContent"
android:text="detail"
android:textAllCaps="false" />
<Button
android:id="@+id/playerContent"
android:id="@+id/player"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="playerContent"
android:text="player"
android:textAllCaps="false" />
<Button
android:id="@+id/searchContent"
android:id="@+id/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="searchContent"
android:text="search"
android:textAllCaps="false" />
<Button
android:id="@+id/liveContent"
android:id="@+id/live"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="liveContent"
android:text="live"
android:textAllCaps="false" />
<Button
android:id="@+id/proxy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="proxy"
android:textAllCaps="false" />
</LinearLayout>
</ScrollView>
</com.google.android.flexbox.FlexboxLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="#000000" />
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<TextView
android:id="@+id/result"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:textColor="#000000"
android:textSize="14sp" />
</androidx.core.widget.NestedScrollView>
</LinearLayout>

Binary file not shown.

@ -1 +1 @@
f26beb81517406a66100b90f6927377a
9126aa90a41b25415d66a7fa572c92bc

Loading…
Cancel
Save