parent
1068162666
commit
c5e03f6cbf
@ -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(); |
||||
} |
||||
} |
||||
} |
||||
@ -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…
Reference in new issue