Merge branch 'main' of https://github.com/FongMi/CatVodSpider
This commit is contained in:
commit
f18e2a2ac6
|
|
@ -535,7 +535,7 @@ public class API {
|
|||
FrameLayout frame = new FrameLayout(Init.context());
|
||||
params.gravity = Gravity.CENTER;
|
||||
frame.addView(image, params);
|
||||
dialog = new AlertDialog.Builder(Init.getActivity()).setView(frame).setOnDismissListener(this::dismiss).show();
|
||||
dialog = new AlertDialog.Builder(Init.getActivity()).setView(frame).setOnCancelListener(this::dismiss).setOnDismissListener(this::dismiss).show();
|
||||
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
Init.show("請使用阿里雲盤 App 掃描二維碼");
|
||||
} catch (Exception ignored) {
|
||||
|
|
|
|||
|
|
@ -47,18 +47,19 @@ public class Bili extends Spider {
|
|||
|
||||
private static final String COOKIE = "buvid3=84B0395D-C9F2-C490-E92E-A09AB48FE26E71636infoc";
|
||||
private ScheduledExecutorService service;
|
||||
private Map<String, String> header;
|
||||
private Map<String, String> audios;
|
||||
private AlertDialog dialog;
|
||||
private String cookie;
|
||||
private String extend;
|
||||
private boolean login;
|
||||
private boolean vip;
|
||||
|
||||
private void setHeader() {
|
||||
header = new HashMap<>();
|
||||
header.put("cookie", getCookie());
|
||||
header.put("User-Agent", Utils.CHROME);
|
||||
header.put("Referer", "https://www.bilibili.com");
|
||||
private Map<String, String> getHeader() {
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("cookie", cookie);
|
||||
headers.put("User-Agent", Utils.CHROME);
|
||||
headers.put("Referer", "https://www.bilibili.com");
|
||||
return headers;
|
||||
}
|
||||
|
||||
private void setAudio() {
|
||||
|
|
@ -79,20 +80,12 @@ public class Bili extends Spider {
|
|||
return FileUtil.getCacheFile("bilibili_user");
|
||||
}
|
||||
|
||||
private String getCookie() {
|
||||
String cookie = FileUtil.read(getUserCache());
|
||||
return TextUtils.isEmpty(cookie) ? COOKIE : cookie;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context, String extend) {
|
||||
try {
|
||||
this.extend = extend;
|
||||
setHeader();
|
||||
setAudio();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.extend = extend;
|
||||
this.cookie = FileUtil.read(getUserCache());
|
||||
this.cookie = TextUtils.isEmpty(cookie) ? COOKIE : cookie;
|
||||
setAudio();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -117,7 +110,7 @@ public class Bili extends Spider {
|
|||
String order = extend.containsKey("order") ? extend.get("order") : "totalrank";
|
||||
String duration = extend.containsKey("duration") ? extend.get("duration") : "0";
|
||||
String api = "https://api.bilibili.com/x/web-interface/search/type?search_type=video&keyword=" + URLEncoder.encode(tid) + "&order=" + order + "&duration=" + duration + "&page=" + pg;
|
||||
String json = OkHttp.string(api, header);
|
||||
String json = OkHttp.string(api, getHeader());
|
||||
Resp resp = Resp.objectFrom(json);
|
||||
List<Vod> list = new ArrayList<>();
|
||||
for (Resp.Result item : Resp.Result.arrayFrom(resp.getData().getResult())) list.add(item.getVod());
|
||||
|
|
@ -130,12 +123,12 @@ public class Bili extends Spider {
|
|||
|
||||
String id = ids.get(0);
|
||||
String api = "https://api.bilibili.com/x/web-interface/archive/stat?bvid=" + id;
|
||||
String json = OkHttp.string(api, header);
|
||||
String json = OkHttp.string(api, getHeader());
|
||||
Resp resp = Resp.objectFrom(json);
|
||||
String aid = resp.getData().getAid();
|
||||
|
||||
api = "https://api.bilibili.com/x/web-interface/view?aid=" + aid;
|
||||
json = OkHttp.string(api, header);
|
||||
json = OkHttp.string(api, getHeader());
|
||||
Data detail = Resp.objectFrom(json).getData();
|
||||
Vod vod = new Vod();
|
||||
vod.setVodId(id);
|
||||
|
|
@ -146,7 +139,7 @@ public class Bili extends Spider {
|
|||
vod.setVodRemarks(detail.getDuration() / 60 + "分鐘");
|
||||
|
||||
api = "https://api.bilibili.com/x/player/playurl?avid=" + aid + "&cid=" + detail.getCid() + "&qn=127&fnval=4048&fourk=1";
|
||||
json = OkHttp.string(api, header);
|
||||
json = OkHttp.string(api, getHeader());
|
||||
Data play = Resp.objectFrom(json).getData();
|
||||
List<String> playList = new ArrayList<>();
|
||||
List<String> playFrom = new ArrayList<>();
|
||||
|
|
@ -178,7 +171,7 @@ public class Bili extends Spider {
|
|||
String qn = ids[2];
|
||||
|
||||
String api = "https://api.bilibili.com/x/player/playurl?avid=" + aid + "&cid=" + cid + "&qn=" + qn + "&fnval=4048&fourk=1";
|
||||
String json = OkHttp.string(api, header);
|
||||
String json = OkHttp.string(api, getHeader());
|
||||
Resp resp = Resp.objectFrom(json);
|
||||
Dash dash = resp.getData().getDash();
|
||||
|
||||
|
|
@ -199,7 +192,7 @@ public class Bili extends Spider {
|
|||
|
||||
String mpd = getMpd(dash, videoList.toString(), audioList.toString());
|
||||
String url = "data:application/dash+xml;base64," + Base64.encodeToString(mpd.getBytes(), 0);
|
||||
return Result.get().url(url).header(header).string();
|
||||
return Result.get().url(url).header(getHeader()).string();
|
||||
}
|
||||
|
||||
private String getMedia(Media media) {
|
||||
|
|
@ -248,7 +241,7 @@ public class Bili extends Spider {
|
|||
}
|
||||
|
||||
private void checkLogin() {
|
||||
String json = OkHttp.string("https://api.bilibili.com/x/web-interface/nav", header);
|
||||
String json = OkHttp.string("https://api.bilibili.com/x/web-interface/nav", getHeader());
|
||||
Data data = Resp.objectFrom(json).getData();
|
||||
login = data.isLogin();
|
||||
vip = data.getVipType() > 0;
|
||||
|
|
@ -270,7 +263,7 @@ public class Bili extends Spider {
|
|||
FrameLayout frame = new FrameLayout(Init.context());
|
||||
params.gravity = Gravity.CENTER;
|
||||
frame.addView(image, params);
|
||||
dialog = new AlertDialog.Builder(Init.getActivity()).setView(frame).setOnDismissListener(this::dismiss).show();
|
||||
dialog = new AlertDialog.Builder(Init.getActivity()).setView(frame).setOnCancelListener(this::cancel).setOnDismissListener(this::dismiss).show();
|
||||
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
Init.show("請使用 BiliBili App 掃描二維碼");
|
||||
Init.execute(() -> startService(data));
|
||||
|
|
@ -282,31 +275,35 @@ public class Bili extends Spider {
|
|||
service = Executors.newScheduledThreadPool(1);
|
||||
service.scheduleAtFixedRate(() -> {
|
||||
String url = "https://passport.bilibili.com/x/passport-login/web/qrcode/poll?qrcode_key=" + data.getQrcodeKey() + "&source=main_mini";
|
||||
String json = OkHttp.string(url, header);
|
||||
String json = OkHttp.string(url, getHeader());
|
||||
url = Resp.objectFrom(json).getData().getUrl();
|
||||
if (url.length() > 0) setCookie(url);
|
||||
}, 1, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
private void setCookie(String url) {
|
||||
StringBuilder cookie = new StringBuilder();
|
||||
String[] splits = Uri.parse(url).getQuery().split("&");
|
||||
for (String split : splits) cookie.append(split).append(";");
|
||||
FileUtil.write(getUserCache(), cookie.toString());
|
||||
Init.show("請重新進入播放頁");
|
||||
stopService();
|
||||
}
|
||||
|
||||
private void stopService() {
|
||||
if (service != null) service.shutdownNow();
|
||||
Init.run(this::dismiss);
|
||||
}
|
||||
|
||||
private void dismiss(DialogInterface dialog) {
|
||||
private void setCookie(String url) {
|
||||
StringBuilder cookie = new StringBuilder();
|
||||
String[] splits = Uri.parse(url).getQuery().split("&");
|
||||
for (String split : splits) cookie.append(split).append(";");
|
||||
FileUtil.write(getUserCache(), this.cookie = cookie.toString());
|
||||
Init.show("請重新進入播放頁");
|
||||
stopService();
|
||||
}
|
||||
|
||||
private void cancel(DialogInterface dialog) {
|
||||
FileUtil.write(getUserCache(), COOKIE);
|
||||
stopService();
|
||||
}
|
||||
|
||||
private void dismiss(DialogInterface dialog) {
|
||||
stopService();
|
||||
}
|
||||
|
||||
private void dismiss() {
|
||||
try {
|
||||
if (dialog != null) dialog.dismiss();
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
cc4a1d56205fd4d1039b53ba3175b81f
|
||||
bc8e0032bdb7abaadf265056bc6800ed
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;cc4a1d56205fd4d1039b53ba3175b81f",
|
||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;bc8e0032bdb7abaadf265056bc6800ed",
|
||||
"wallpaper": "https://gao.chuqiuyu.tk",
|
||||
"sites": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;cc4a1d56205fd4d1039b53ba3175b81f",
|
||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;bc8e0032bdb7abaadf265056bc6800ed",
|
||||
"wallpaper": "http://饭太硬.top/深色壁纸/api.php",
|
||||
"sites": [
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue