Skip to content

Commit

Permalink
Fix star
Browse files Browse the repository at this point in the history
  • Loading branch information
FongMi committed Feb 20, 2024
1 parent e92ddea commit 6970f6c
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 114 deletions.
96 changes: 0 additions & 96 deletions app/src/main/java/com/github/catvod/bean/star/Detail.java

This file was deleted.

24 changes: 24 additions & 0 deletions app/src/main/java/com/github/catvod/bean/star/Group.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.github.catvod.bean.star;

import android.text.TextUtils;

import com.google.gson.annotations.SerializedName;

import java.util.Collections;
import java.util.List;

public class Group {

@SerializedName("name")
private String name;
@SerializedName("videos")
private List<Video> videos;

public String getName() {
return TextUtils.isEmpty(name) ? "" : name;
}

public List<Video> getVideos() {
return videos == null ? Collections.emptyList() : videos;
}
}
71 changes: 71 additions & 0 deletions app/src/main/java/com/github/catvod/bean/star/Info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.github.catvod.bean.star;

import android.text.TextUtils;

import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;

import java.util.Collections;
import java.util.List;

public class Info {

@SerializedName("videosGroup")
private List<Group> videosGroup;
@SerializedName("actor")
private List<Person> actor;
@SerializedName("country")
private String country;
@SerializedName("desc")
private String desc;
@SerializedName("director")
private List<Person> director;
@SerializedName("name")
private String name;
@SerializedName("picurl")
private String picurl;
@SerializedName("time")
private String time;
@SerializedName("countStr")
private String countStr;

public static Info objectFrom(String str) {
return new Gson().fromJson(str, Info.class);
}

public List<Group> getVideosGroup() {
return videosGroup == null ? Collections.emptyList() : videosGroup;
}

public List<Person> getActor() {
return actor == null ? Collections.emptyList() : actor;
}

public String getCountry() {
return TextUtils.isEmpty(country) ? "" : country;
}

public String getDesc() {
return TextUtils.isEmpty(desc) ? "" : desc;
}

public List<Person> getDirector() {
return director == null ? Collections.emptyList() : director;
}

public String getName() {
return TextUtils.isEmpty(name) ? "" : name;
}

public String getPicurl() {
return TextUtils.isEmpty(picurl) ? "" : picurl;
}

public String getTime() {
return TextUtils.isEmpty(time) ? "" : time;
}

public String getCountStr() {
return TextUtils.isEmpty(countStr) ? "" : countStr;
}
}
21 changes: 21 additions & 0 deletions app/src/main/java/com/github/catvod/bean/star/Person.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.github.catvod.bean.star;

import android.text.TextUtils;

import com.google.gson.annotations.SerializedName;

public class Person {

@SerializedName("id")
private int id;
@SerializedName("name")
private String name;

public int getId() {
return id;
}

public String getName() {
return TextUtils.isEmpty(name) ? "" : name;
}
}
21 changes: 21 additions & 0 deletions app/src/main/java/com/github/catvod/bean/star/Video.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.github.catvod.bean.star;

import android.text.TextUtils;

import com.google.gson.annotations.SerializedName;

public class Video {

@SerializedName("purl")
private String purl;
@SerializedName("eporder")
private int eporder;

public String getPurl() {
return TextUtils.isEmpty(purl) ? "" : purl;
}

public int getEporder() {
return eporder;
}
}
8 changes: 4 additions & 4 deletions app/src/main/java/com/github/catvod/debug/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.github.catvod.R;
import com.github.catvod.crawler.Spider;
import com.github.catvod.spider.Init;
import com.github.catvod.spider.Yingshiche;
import com.github.catvod.spider.Star;
import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.Logger;

Expand Down Expand Up @@ -46,7 +46,7 @@ protected void onCreate(Bundle savedInstanceState) {
private void initSpider() {
try {
Init.init(getApplicationContext());
spider = new Yingshiche();
spider = new Star();
spider.init(this, "");
} catch (Throwable e) {
e.printStackTrace();
Expand All @@ -71,15 +71,15 @@ public void homeVideoContent() {

public void categoryContent() {
try {
Logger.t("categoryContent").d(spider.categoryContent("tid", "1", true, new HashMap<>()));
Logger.t("categoryContent").d(spider.categoryContent("movie", "1", true, new HashMap<>()));
} catch (Throwable e) {
e.printStackTrace();
}
}

public void detailContent() {
try {
Logger.t("detailContent").d(spider.detailContent(Arrays.asList("/voddetail/5553.html")));
Logger.t("detailContent").d(spider.detailContent(Arrays.asList("2121173431")));
} catch (Throwable e) {
e.printStackTrace();
}
Expand Down
40 changes: 27 additions & 13 deletions app/src/main/java/com/github/catvod/spider/Star.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
import com.github.catvod.bean.Vod;
import com.github.catvod.bean.star.Card;
import com.github.catvod.bean.star.Condition;
import com.github.catvod.bean.star.Detail;
import com.github.catvod.bean.star.Group;
import com.github.catvod.bean.star.Info;
import com.github.catvod.bean.star.Person;
import com.github.catvod.bean.star.Query;
import com.github.catvod.bean.star.Video;
import com.github.catvod.crawler.Spider;
import com.github.catvod.net.OkHttp;
import com.github.catvod.utils.Util;
Expand Down Expand Up @@ -40,7 +43,7 @@ public class Star extends Spider {
private Map<String, String> getHeader() {
Map<String, String> headers = new HashMap<>();
headers.put("User-Agent", Util.CHROME);
headers.put("Cookie", "userIP=127.0.0.1; aws-waf-token=");
headers.put("Cookie", "userIP=64.252.112.99;");
headers.put("Referer", siteUrl);
return headers;
}
Expand All @@ -66,7 +69,6 @@ public void init(Context context, String extend) {
map.put("drama", "电视剧");
map.put("animation", "动漫");
map.put("variety", "综艺");
map.put("documentary", "纪录片");
ver = getVer();
}

Expand Down Expand Up @@ -95,6 +97,7 @@ public String homeVideoContent() throws Exception {

@Override
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
if (tid.endsWith("/{pg}")) return searchContent(tid.split("/")[0], true);
String year = extend.containsKey("year") ? extend.get("year") : "";
String type = extend.containsKey("type") ? extend.get("type") : "";
String area = extend.containsKey("area") ? extend.get("area") : "";
Expand All @@ -115,22 +118,27 @@ public String categoryContent(String tid, String pg, boolean filter, HashMap<Str
@Override
public String detailContent(List<String> ids) throws Exception {
Element script = Jsoup.parse(OkHttp.string(client(), detail.concat(ids.get(0)), getHeader())).select("#__NEXT_DATA__").get(0);
Detail detail = Detail.objectFrom(new JSONObject(script.data()).getJSONObject("props").getJSONObject("pageProps").getJSONObject("pageData").toString());
Info detail = Info.objectFrom(new JSONObject(script.data()).getJSONObject("props").getJSONObject("pageProps").getJSONObject("collectionInfo").toString());
Vod vod = new Vod();
vod.setVodId(ids.get(0));
vod.setVodPic(detail.getPicurl());
vod.setVodYear(detail.getTime());
vod.setVodName(detail.getName());
vod.setVodPic(detail.getPicurl());
vod.setVodArea(detail.getCountry());
vod.setVodActor(detail.getActor());
vod.setVodRemarks(detail.getCountStr());
vod.setVodContent(detail.getDesc());
vod.setVodDirector(detail.getDirector());
vod.setTypeName(detail.getLabel());
vod.setVodPlayFrom("FongMi");
vod.setVodRemarks(detail.getCountStr());
vod.setVodActor(convert(detail.getActor()));
vod.setVodDirector(convert(detail.getDirector()));
List<String> playFrom = new ArrayList<>();
List<String> playUrls = new ArrayList<>();
for (Detail.Video video : detail.getVideos()) playUrls.add(video.getEporder() + "$" + video.getPurl());
vod.setVodPlayUrl(TextUtils.join("#", playUrls));
for (Group group : detail.getVideosGroup()) {
List<String> urls = new ArrayList<>();
for (Video video : group.getVideos()) urls.add(video.getEporder() + "$" + video.getPurl());
playUrls.add(TextUtils.join("#", urls));
playFrom.add(group.getName());
}
vod.setVodPlayUrl(TextUtils.join("$$$", playUrls));
vod.setVodPlayFrom(TextUtils.join("$$$", playFrom));
return Result.string(vod);
}

Expand All @@ -140,12 +148,18 @@ public String searchContent(String key, boolean quick) throws Exception {
String json = OkHttp.string(client(), siteUrl + data + ver + "/search.json?word=" + URLEncoder.encode(key), getHeader());
List<Card> items = Card.arrayFrom(new JSONObject(json).getJSONObject("pageProps").getJSONArray("initList").toString());
for (Card item : items) list.add(item.vod());
return Result.string(list);
return Result.get().vod(list).page().string();
}

@Override
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
return Result.get().url(id).string();
}

private String convert(List<Person> items) {
StringBuilder sb = new StringBuilder();
for (Person item : items) sb.append(String.format("[a=cr:{\"id\":\"%s\",\"name\":\"%s\"}/]%s[/a]", item.getName() + "/{pg}", item.getName(), item.getName())).append(",");
return Util.substring(sb.toString());
}
}

Binary file modified jar/custom_spider.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion jar/custom_spider.jar.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1d4ff8f544bca8e9c4c931bc67f186c9
79ce46d06a14fbf6a8032fb0b1d5b98a

0 comments on commit 6970f6c

Please sign in to comment.