Clean code
This commit is contained in:
parent
331a57384f
commit
7807ed0b04
|
|
@ -83,6 +83,10 @@ public class OkHttp {
|
||||||
return string(url, null, header, respHeader);
|
return string(url, null, header, respHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String get(String url, Map<String, String> params, Map<String, String> header) {
|
||||||
|
return string(url, params, header, null);
|
||||||
|
}
|
||||||
|
|
||||||
public static String string(String url, Map<String, String> params, Map<String, String> header, Map<String, List<String>> respHeader) {
|
public static String string(String url, Map<String, String> params, Map<String, String> header, Map<String, List<String>> respHeader) {
|
||||||
return string(url, null, params, header, respHeader);
|
return string(url, null, params, header, respHeader);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ public class Bili extends Spider {
|
||||||
private JsonObject extend;
|
private JsonObject extend;
|
||||||
private String cookie;
|
private String cookie;
|
||||||
private boolean login;
|
private boolean login;
|
||||||
private static boolean AskOnlyOnce = false;
|
private boolean ask;
|
||||||
|
|
||||||
private Map<String, String> getHeader(String cookie) {
|
private Map<String, String> getHeader(String cookie) {
|
||||||
Map<String, String> headers = new HashMap<>();
|
Map<String, String> headers = new HashMap<>();
|
||||||
|
|
@ -146,7 +146,7 @@ public class Bili extends Spider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String detailContent(List<String> ids) throws Exception {
|
public String detailContent(List<String> ids) throws Exception {
|
||||||
if (!login && !AskOnlyOnce) checkLogin();
|
if (!login && !ask) checkLogin();
|
||||||
|
|
||||||
String[] split = ids.get(0).split("@");
|
String[] split = ids.get(0).split("@");
|
||||||
String id = split[0];
|
String id = split[0];
|
||||||
|
|
@ -264,7 +264,7 @@ public class Bili extends Spider {
|
||||||
|
|
||||||
private void getQRCode() {
|
private void getQRCode() {
|
||||||
if (login) return;
|
if (login) return;
|
||||||
AskOnlyOnce = true;
|
ask = true;
|
||||||
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(() -> openApp(data));
|
Init.run(() -> openApp(data));
|
||||||
|
|
|
||||||
|
|
@ -194,11 +194,12 @@ public class Utils {
|
||||||
|
|
||||||
public static String getDigit(String text) {
|
public static String getDigit(String text) {
|
||||||
try {
|
try {
|
||||||
|
String newText = text;
|
||||||
Matcher matcher = Pattern.compile(".*(1080|720|2160|4k|4K).*").matcher(text);
|
Matcher matcher = Pattern.compile(".*(1080|720|2160|4k|4K).*").matcher(text);
|
||||||
if (matcher.find()) text = matcher.group(1) + " " + text;
|
if (matcher.find()) newText = matcher.group(1) + " " + text;
|
||||||
matcher = Pattern.compile("^([0-9]+)").matcher(text);
|
matcher = Pattern.compile("^([0-9]+)").matcher(text);
|
||||||
if (matcher.find()) text = matcher.group(1) + " " + text;
|
if (matcher.find()) newText = matcher.group(1) + " " + newText;
|
||||||
return text.replaceAll("\\D+", "");
|
return newText.replaceAll("\\D+", "") + " " + newText.replaceAll("\\d+", "");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue