add bilibili live signIn

add bilibili live room sign
This commit is contained in:
2022-10-14 13:49:43 +08:00
parent fe48b030d9
commit 8207498f2c
5 changed files with 108 additions and 1 deletions

View File

@@ -300,4 +300,33 @@ public class BiliBiliUtils {
File file=BiliBiliUtils.download(url,"16.mp4",false);
System.out.println("file.getAbsolutePath() = " + file.getAbsolutePath());
}
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;
}
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 post = BiliBiliUtils.http_post("https://api.live.bilibili.com/xlive/revenue/v1/wallet/silver2coin", HttpTools.toUrlParams(body));
return post.getString("message");
}
public static boolean checkLiveRoom(int roomId){
JSONObject body=new JSONObject();
body.put("room_id",roomId);
body.put("csrf",BiliLogin.getCookieToken());
body.put("csrf_token",BiliLogin.getCookieToken());
JSONObject post = BiliBiliUtils.http_post("https://api.live.bilibili.com/room/v1/Room/get_info", HttpTools.toUrlParams(body));
return post.getInteger("code")==0;
}
}