update 木鱼音频
This commit is contained in:
@@ -12,7 +12,9 @@ import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BiliBiliUtils {
|
||||
private static long oldBiliBiliHttpTime = 0;
|
||||
@@ -64,6 +66,10 @@ public class BiliBiliUtils {
|
||||
}
|
||||
|
||||
public static <T> T http(String url, HTTP model, String body, RET_MODEL ret_model) {
|
||||
return http(url, model, body, null, ret_model);
|
||||
}
|
||||
|
||||
public static <T> T http(String url, HTTP model, String body, Map<String, String> headers, RET_MODEL ret_model) {
|
||||
JSONObject json = null;
|
||||
BufferedInputStream stream = null;
|
||||
ByteArrayOutputStream outputStream = null;
|
||||
@@ -81,8 +87,22 @@ public class BiliBiliUtils {
|
||||
if (model == HTTP.POST) {
|
||||
connection = getBiliHttpPost(url, getCookie());
|
||||
} else {
|
||||
if (body != null) {
|
||||
if (url.contains("?")) {
|
||||
url += "&" + body;
|
||||
} else {
|
||||
url += "?" + body;
|
||||
}
|
||||
body = null;
|
||||
}
|
||||
connection = getBiliHttpGet(url, getCookie());
|
||||
}
|
||||
if (headers != null) {
|
||||
for (String key : headers.keySet()) {
|
||||
connection.setRequestProperty(key, headers.get(key));
|
||||
}
|
||||
}
|
||||
System.out.println("url = " + url);
|
||||
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
||||
|
||||
if (!StringUtils.isEmpty(body)) {
|
||||
@@ -182,7 +202,9 @@ public class BiliBiliUtils {
|
||||
oldBiliBiliHttpTime = System.currentTimeMillis();
|
||||
}
|
||||
HttpsURLConnection connection = (HttpsURLConnection) new URL(url).openConnection();
|
||||
setConnection(cookie, connection);
|
||||
if (cookie != null) {
|
||||
setConnection(cookie, connection);
|
||||
}
|
||||
connection.setReadTimeout(5000);
|
||||
connection.setConnectTimeout(5000);
|
||||
return connection;
|
||||
@@ -191,7 +213,7 @@ public class BiliBiliUtils {
|
||||
public static File download(final String url, final String saveName, boolean isProxy) {
|
||||
File jar = null;
|
||||
try {
|
||||
File savePath = new File(HttpTools.downloadPath+saveName);
|
||||
File savePath = new File(HttpTools.downloadPath + saveName);
|
||||
Proxy proxy = null;
|
||||
if (!savePath.exists()) {
|
||||
savePath.mkdirs();
|
||||
@@ -230,7 +252,7 @@ public class BiliBiliUtils {
|
||||
}
|
||||
jar.renameTo(oldJar);
|
||||
Log.i("DOWNLOAD", "实际保存:" + oldJar.getAbsolutePath() + " " + oldJar.getName());
|
||||
return oldJar;
|
||||
return oldJar;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (jar != null) {
|
||||
@@ -306,41 +328,45 @@ public class BiliBiliUtils {
|
||||
System.out.println("sign = " + sign);
|
||||
}
|
||||
|
||||
public static boolean sendLiveDanmu(long roomId,String msg){
|
||||
JSONObject body=new JSONObject();
|
||||
body.put("msg",msg);
|
||||
body.put("roomid",roomId);
|
||||
body.put("color",16777215);
|
||||
body.put("fontsize",25);
|
||||
body.put("rnd",System.currentTimeMillis()/1000);
|
||||
body.put("csrf",BiliLogin.getCookieToken());
|
||||
body.put("csrf_token",BiliLogin.getCookieToken());
|
||||
public static boolean sendLiveDanmu(long roomId, String msg) {
|
||||
JSONObject body = new JSONObject();
|
||||
body.put("msg", msg);
|
||||
body.put("roomid", roomId);
|
||||
body.put("color", 16777215);
|
||||
body.put("fontsize", 25);
|
||||
body.put("rnd", System.currentTimeMillis() / 1000);
|
||||
body.put("csrf", BiliLogin.getCookieToken());
|
||||
body.put("csrf_token", BiliLogin.getCookieToken());
|
||||
JSONObject post = BiliBiliUtils.http_post("https://api.live.bilibili.com/msg/send", HttpTools.toUrlParams(body));
|
||||
return post.getInteger("code")==0;
|
||||
return post.getInteger("code") == 0;
|
||||
}
|
||||
public static String liveSignIn(){
|
||||
|
||||
public static String liveSignIn() {
|
||||
//{"code":0,"data":{"coin":1,"gold":19500,"silver":106394,"tid":"Silver2Coin22101413201169763005873"},"message":"兑换成功"}
|
||||
JSONObject body=new JSONObject();
|
||||
body.put("csrf",BiliLogin.getCookieToken());
|
||||
body.put("csrf_token",BiliLogin.getCookieToken());
|
||||
JSONObject body = new JSONObject();
|
||||
body.put("csrf", BiliLogin.getCookieToken());
|
||||
body.put("csrf_token", BiliLogin.getCookieToken());
|
||||
JSONObject post = BiliBiliUtils.http_post("https://api.live.bilibili.com/xlive/revenue/v1/wallet/silver2coin", HttpTools.toUrlParams(body));
|
||||
JSONObject post_ = BiliBiliUtils.http_get("https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign");
|
||||
return post.getString("message")+"|"+post_.getString("message");
|
||||
return post.getString("message") + "|" + post_.getString("message");
|
||||
}
|
||||
public static JSONObject getLiveRoom(int roomId){
|
||||
JSONObject body=new JSONObject();
|
||||
body.put("room_id",roomId);
|
||||
body.put("csrf",BiliLogin.getCookieToken());
|
||||
body.put("csrf_token",BiliLogin.getCookieToken());
|
||||
|
||||
public static JSONObject getLiveRoom(int roomId) {
|
||||
JSONObject body = new JSONObject();
|
||||
body.put("room_id", roomId);
|
||||
body.put("csrf", BiliLogin.getCookieToken());
|
||||
body.put("csrf_token", BiliLogin.getCookieToken());
|
||||
return BiliBiliUtils.http_post("https://api.live.bilibili.com/room/v1/Room/get_info", HttpTools.toUrlParams(body));
|
||||
}
|
||||
public static JSONObject getUserInfo(int mid){
|
||||
JSONObject body=new JSONObject();
|
||||
body.put("mid",mid);
|
||||
return BiliBiliUtils.http_get("https://api.bilibili.com/x/space/acc/info?"+ HttpTools.toUrlParams(body));
|
||||
|
||||
public static JSONObject getUserInfo(int mid) {
|
||||
JSONObject body = new JSONObject();
|
||||
body.put("mid", mid);
|
||||
return BiliBiliUtils.http_get("https://api.bilibili.com/x/space/acc/info?" + HttpTools.toUrlParams(body));
|
||||
}
|
||||
public static boolean checkLiveRoom(int roomId){
|
||||
JSONObject post=getLiveRoom(roomId);
|
||||
return post.getInteger("code")==0;
|
||||
|
||||
public static boolean checkLiveRoom(int roomId) {
|
||||
JSONObject post = getLiveRoom(roomId);
|
||||
return post.getInteger("code") == 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user