Merge branch 'main' of https://github.com/FongMi/CatVodSpider
This commit is contained in:
commit
9da3764288
|
|
@ -168,7 +168,7 @@ public class API {
|
||||||
|
|
||||||
private boolean isManyRequest(String result) {
|
private boolean isManyRequest(String result) {
|
||||||
if (!result.contains("Too Many Requests")) return false;
|
if (!result.contains("Too Many Requests")) return false;
|
||||||
Init.show("洗洗睡吧,Too Many Requests。");
|
Utils.notify("洗洗睡吧,Too Many Requests。");
|
||||||
oauth.clean().save();
|
oauth.clean().save();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -188,7 +188,7 @@ public class API {
|
||||||
shareToken = new JSONObject(result).getString("share_token");
|
shareToken = new JSONObject(result).getString("share_token");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Init.show("來晚啦,該分享已失效。");
|
Utils.notify("來晚啦,該分享已失效。");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -537,7 +537,7 @@ public class API {
|
||||||
frame.addView(image, params);
|
frame.addView(image, params);
|
||||||
dialog = new AlertDialog.Builder(Init.getActivity()).setView(frame).setOnCancelListener(this::dismiss).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));
|
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||||
Init.show("請使用阿里雲盤 App 掃描二維碼");
|
Utils.notify("請使用阿里雲盤 App 掃描二維碼");
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -553,7 +553,7 @@ public class API {
|
||||||
|
|
||||||
private void setToken(String value) {
|
private void setToken(String value) {
|
||||||
SpiderDebug.log("Token:" + value);
|
SpiderDebug.log("Token:" + value);
|
||||||
Init.show("Token:" + value);
|
Utils.notify("Token:" + value);
|
||||||
user.setRefreshToken(value);
|
user.setRefreshToken(value);
|
||||||
refreshAccessToken();
|
refreshAccessToken();
|
||||||
stopService();
|
stopService();
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.github.catvod.spider;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
@ -54,7 +55,7 @@ public class Bili extends Spider {
|
||||||
private boolean login;
|
private boolean login;
|
||||||
private boolean vip;
|
private boolean vip;
|
||||||
|
|
||||||
private Map<String, String> getHeader() {
|
private Map<String, String> getHeader(String cookie) {
|
||||||
Map<String, String> headers = new HashMap<>();
|
Map<String, String> headers = new HashMap<>();
|
||||||
headers.put("cookie", cookie);
|
headers.put("cookie", cookie);
|
||||||
headers.put("User-Agent", Utils.CHROME);
|
headers.put("User-Agent", Utils.CHROME);
|
||||||
|
|
@ -62,6 +63,14 @@ public class Bili extends Spider {
|
||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<String, String> getGuest() {
|
||||||
|
return getHeader(COOKIE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, String> getMember() {
|
||||||
|
return getHeader(cookie);
|
||||||
|
}
|
||||||
|
|
||||||
private void setAudio() {
|
private void setAudio() {
|
||||||
audios = new HashMap<>();
|
audios = new HashMap<>();
|
||||||
audios.put("30280", "192000");
|
audios.put("30280", "192000");
|
||||||
|
|
@ -110,7 +119,7 @@ public class Bili extends Spider {
|
||||||
String order = extend.containsKey("order") ? extend.get("order") : "totalrank";
|
String order = extend.containsKey("order") ? extend.get("order") : "totalrank";
|
||||||
String duration = extend.containsKey("duration") ? extend.get("duration") : "0";
|
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 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, getHeader());
|
String json = OkHttp.string(api, getGuest());
|
||||||
Resp resp = Resp.objectFrom(json);
|
Resp resp = Resp.objectFrom(json);
|
||||||
List<Vod> list = new ArrayList<>();
|
List<Vod> list = new ArrayList<>();
|
||||||
for (Resp.Result item : Resp.Result.arrayFrom(resp.getData().getResult())) list.add(item.getVod());
|
for (Resp.Result item : Resp.Result.arrayFrom(resp.getData().getResult())) list.add(item.getVod());
|
||||||
|
|
@ -123,12 +132,12 @@ public class Bili extends Spider {
|
||||||
|
|
||||||
String id = ids.get(0);
|
String id = ids.get(0);
|
||||||
String api = "https://api.bilibili.com/x/web-interface/archive/stat?bvid=" + id;
|
String api = "https://api.bilibili.com/x/web-interface/archive/stat?bvid=" + id;
|
||||||
String json = OkHttp.string(api, getHeader());
|
String json = OkHttp.string(api, getMember());
|
||||||
Resp resp = Resp.objectFrom(json);
|
Resp resp = Resp.objectFrom(json);
|
||||||
String aid = resp.getData().getAid();
|
String aid = resp.getData().getAid();
|
||||||
|
|
||||||
api = "https://api.bilibili.com/x/web-interface/view?aid=" + aid;
|
api = "https://api.bilibili.com/x/web-interface/view?aid=" + aid;
|
||||||
json = OkHttp.string(api, getHeader());
|
json = OkHttp.string(api, getMember());
|
||||||
Data detail = Resp.objectFrom(json).getData();
|
Data detail = Resp.objectFrom(json).getData();
|
||||||
Vod vod = new Vod();
|
Vod vod = new Vod();
|
||||||
vod.setVodId(id);
|
vod.setVodId(id);
|
||||||
|
|
@ -139,7 +148,7 @@ public class Bili extends Spider {
|
||||||
vod.setVodRemarks(detail.getDuration() / 60 + "分鐘");
|
vod.setVodRemarks(detail.getDuration() / 60 + "分鐘");
|
||||||
|
|
||||||
api = "https://api.bilibili.com/x/player/playurl?avid=" + aid + "&cid=" + detail.getCid() + "&qn=127&fnval=4048&fourk=1";
|
api = "https://api.bilibili.com/x/player/playurl?avid=" + aid + "&cid=" + detail.getCid() + "&qn=127&fnval=4048&fourk=1";
|
||||||
json = OkHttp.string(api, getHeader());
|
json = OkHttp.string(api, getMember());
|
||||||
Data play = Resp.objectFrom(json).getData();
|
Data play = Resp.objectFrom(json).getData();
|
||||||
List<String> playList = new ArrayList<>();
|
List<String> playList = new ArrayList<>();
|
||||||
List<String> playFrom = new ArrayList<>();
|
List<String> playFrom = new ArrayList<>();
|
||||||
|
|
@ -171,7 +180,7 @@ public class Bili extends Spider {
|
||||||
String qn = ids[2];
|
String qn = ids[2];
|
||||||
|
|
||||||
String api = "https://api.bilibili.com/x/player/playurl?avid=" + aid + "&cid=" + cid + "&qn=" + qn + "&fnval=4048&fourk=1";
|
String api = "https://api.bilibili.com/x/player/playurl?avid=" + aid + "&cid=" + cid + "&qn=" + qn + "&fnval=4048&fourk=1";
|
||||||
String json = OkHttp.string(api, getHeader());
|
String json = OkHttp.string(api, getMember());
|
||||||
Resp resp = Resp.objectFrom(json);
|
Resp resp = Resp.objectFrom(json);
|
||||||
Dash dash = resp.getData().getDash();
|
Dash dash = resp.getData().getDash();
|
||||||
|
|
||||||
|
|
@ -192,7 +201,7 @@ public class Bili extends Spider {
|
||||||
|
|
||||||
String mpd = getMpd(dash, videoList.toString(), audioList.toString());
|
String mpd = getMpd(dash, videoList.toString(), audioList.toString());
|
||||||
String url = "data:application/dash+xml;base64," + Base64.encodeToString(mpd.getBytes(), 0);
|
String url = "data:application/dash+xml;base64," + Base64.encodeToString(mpd.getBytes(), 0);
|
||||||
return Result.get().url(url).header(getHeader()).string();
|
return Result.get().url(url).header(getMember()).string();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMedia(Media media) {
|
private String getMedia(Media media) {
|
||||||
|
|
@ -241,17 +250,43 @@ public class Bili extends Spider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkLogin() {
|
private void checkLogin() {
|
||||||
String json = OkHttp.string("https://api.bilibili.com/x/web-interface/nav", getHeader());
|
String json = OkHttp.string("https://api.bilibili.com/x/web-interface/nav", getMember());
|
||||||
Data data = Resp.objectFrom(json).getData();
|
Data data = Resp.objectFrom(json).getData();
|
||||||
login = data.isLogin();
|
|
||||||
vip = data.getVipType() > 0;
|
vip = data.getVipType() > 0;
|
||||||
if (!login && !getUserCache().exists()) getQRCode();
|
login = data.isLogin();
|
||||||
|
getQRCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getQRCode() {
|
private void getQRCode() {
|
||||||
|
if (login || getUserCache().exists() && COOKIE.equals(cookie)) return;
|
||||||
String json = OkHttp.string("https://passport.bilibili.com/x/passport-login/web/qrcode/generate?source=main-mini");
|
String json = OkHttp.string("https://passport.bilibili.com/x/passport-login/web/qrcode/generate?source=main-mini");
|
||||||
Data data = Resp.objectFrom(json).getData();
|
Data data = Resp.objectFrom(json).getData();
|
||||||
Init.run(() -> showQRCode(data));
|
Init.run(() -> openApp1(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Intent getIntent(String pkgName, Data data) {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
|
intent.setClassName(pkgName, "tv.danmaku.bili.ui.intent.IntentHandlerActivity");
|
||||||
|
intent.setData(Uri.parse(data.getUrl()));
|
||||||
|
return intent;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openApp1(Data data) {
|
||||||
|
try {
|
||||||
|
Init.getActivity().startActivity(getIntent("tv.danmaku.bili", data));
|
||||||
|
} catch (Exception e) {
|
||||||
|
openApp2(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openApp2(Data data) {
|
||||||
|
try {
|
||||||
|
Init.getActivity().startActivity(getIntent("com.bilibili.app.in", data));
|
||||||
|
} catch (Exception e) {
|
||||||
|
showQRCode(data);
|
||||||
|
} finally {
|
||||||
|
Init.execute(() -> startService(data));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showQRCode(Data data) {
|
private void showQRCode(Data data) {
|
||||||
|
|
@ -265,8 +300,7 @@ public class Bili extends Spider {
|
||||||
frame.addView(image, params);
|
frame.addView(image, params);
|
||||||
dialog = new AlertDialog.Builder(Init.getActivity()).setView(frame).setOnCancelListener(this::cancel).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));
|
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||||
Init.show("請使用 BiliBili App 掃描二維碼");
|
Utils.notify("請使用 BiliBili App 掃描二維碼");
|
||||||
Init.execute(() -> startService(data));
|
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -275,7 +309,7 @@ public class Bili extends Spider {
|
||||||
service = Executors.newScheduledThreadPool(1);
|
service = Executors.newScheduledThreadPool(1);
|
||||||
service.scheduleAtFixedRate(() -> {
|
service.scheduleAtFixedRate(() -> {
|
||||||
String url = "https://passport.bilibili.com/x/passport-login/web/qrcode/poll?qrcode_key=" + data.getQrcodeKey() + "&source=main_mini";
|
String url = "https://passport.bilibili.com/x/passport-login/web/qrcode/poll?qrcode_key=" + data.getQrcodeKey() + "&source=main_mini";
|
||||||
String json = OkHttp.string(url, getHeader());
|
String json = OkHttp.string(url, getGuest());
|
||||||
url = Resp.objectFrom(json).getData().getUrl();
|
url = Resp.objectFrom(json).getData().getUrl();
|
||||||
if (url.length() > 0) setCookie(url);
|
if (url.length() > 0) setCookie(url);
|
||||||
}, 1, 1, TimeUnit.SECONDS);
|
}, 1, 1, TimeUnit.SECONDS);
|
||||||
|
|
@ -291,7 +325,7 @@ public class Bili extends Spider {
|
||||||
String[] splits = Uri.parse(url).getQuery().split("&");
|
String[] splits = Uri.parse(url).getQuery().split("&");
|
||||||
for (String split : splits) cookie.append(split).append(";");
|
for (String split : splits) cookie.append(split).append(";");
|
||||||
FileUtil.write(getUserCache(), this.cookie = cookie.toString());
|
FileUtil.write(getUserCache(), this.cookie = cookie.toString());
|
||||||
Init.show("請重新進入播放頁");
|
Utils.notify("請重新進入播放頁");
|
||||||
stopService();
|
stopService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.github.catvod.crawler.SpiderDebug;
|
import com.github.catvod.crawler.SpiderDebug;
|
||||||
|
|
||||||
|
|
@ -54,10 +53,6 @@ public class Init {
|
||||||
get().handler.postDelayed(runnable, delay);
|
get().handler.postDelayed(runnable, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void show(String msg) {
|
|
||||||
get().handler.post(() -> Toast.makeText(context(), msg, Toast.LENGTH_LONG).show());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Activity getActivity() throws Exception {
|
public static Activity getActivity() throws Exception {
|
||||||
Class<?> activityThreadClass = Class.forName("android.app.ActivityThread");
|
Class<?> activityThreadClass = Class.forName("android.app.ActivityThread");
|
||||||
Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null);
|
Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null);
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import android.view.ViewGroup;
|
||||||
import android.webkit.ValueCallback;
|
import android.webkit.ValueCallback;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.github.catvod.spider.Init;
|
import com.github.catvod.spider.Init;
|
||||||
|
|
||||||
|
|
@ -155,6 +156,10 @@ public class Utils {
|
||||||
else webView.loadUrl(script);
|
else webView.loadUrl(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void notify(String msg) {
|
||||||
|
Init.run(() -> Toast.makeText(Init.context(), msg, Toast.LENGTH_LONG).show());
|
||||||
|
}
|
||||||
|
|
||||||
public static void addView(View view, ViewGroup.LayoutParams params) {
|
public static void addView(View view, ViewGroup.LayoutParams params) {
|
||||||
try {
|
try {
|
||||||
ViewGroup group = Init.getActivity().getWindow().getDecorView().findViewById(android.R.id.content);
|
ViewGroup group = Init.getActivity().getWindow().getDecorView().findViewById(android.R.id.content);
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
bc8e0032bdb7abaadf265056bc6800ed
|
7b867141be64b2346f595bc76cce671b
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;bc8e0032bdb7abaadf265056bc6800ed",
|
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;7b867141be64b2346f595bc76cce671b",
|
||||||
"wallpaper": "https://gao.chuqiuyu.tk",
|
"wallpaper": "https://gao.chuqiuyu.tk",
|
||||||
"sites": [
|
"sites": [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;bc8e0032bdb7abaadf265056bc6800ed",
|
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;7b867141be64b2346f595bc76cce671b",
|
||||||
"wallpaper": "http://饭太硬.top/深色壁纸/api.php",
|
"wallpaper": "http://饭太硬.top/深色壁纸/api.php",
|
||||||
"sites": [
|
"sites": [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue