mirror of
https://github.com/czp3009/bilibili-api.git
synced 2025-03-21 21:00:26 +08:00
增加日志记录
调用 BilibiliRESTAPI.getAccountInfo() 时将自动保存用户的 mid
This commit is contained in:
parent
304960c819
commit
e3565e2bd3
@ -18,6 +18,7 @@ import java.security.interfaces.RSAPublicKey;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
|
|
||||||
|
//TODO 尚未实现自动 refreshToken 拦截器
|
||||||
public class BilibiliRESTAPI {
|
public class BilibiliRESTAPI {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(BilibiliRESTAPI.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(BilibiliRESTAPI.class);
|
||||||
private static String accessToken;
|
private static String accessToken;
|
||||||
@ -29,6 +30,7 @@ public class BilibiliRESTAPI {
|
|||||||
|
|
||||||
public static LiveService getLiveService() {
|
public static LiveService getLiveService() {
|
||||||
if (liveService == null) {
|
if (liveService == null) {
|
||||||
|
LOGGER.debug("Init LiveService");
|
||||||
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
||||||
.addInterceptor(new AddFixedHeadersInterceptor(
|
.addInterceptor(new AddFixedHeadersInterceptor(
|
||||||
"Display-ID", Utils.calculateDisplayId(),
|
"Display-ID", Utils.calculateDisplayId(),
|
||||||
@ -66,6 +68,7 @@ public class BilibiliRESTAPI {
|
|||||||
//TODO 不明确客户端访问 passport.bilibili.com 时使用的 UA
|
//TODO 不明确客户端访问 passport.bilibili.com 时使用的 UA
|
||||||
public static PassportService getPassportService() {
|
public static PassportService getPassportService() {
|
||||||
if (passportService == null) {
|
if (passportService == null) {
|
||||||
|
LOGGER.debug("Init PassportService");
|
||||||
OkHttpClient okHttpClient = new OkHttpClient().newBuilder()
|
OkHttpClient okHttpClient = new OkHttpClient().newBuilder()
|
||||||
.addInterceptor(AddAppKeyInterceptor.getInstance())
|
.addInterceptor(AddAppKeyInterceptor.getInstance())
|
||||||
.addInterceptor(SortParamsAndSignInterceptor.getInstance())
|
.addInterceptor(SortParamsAndSignInterceptor.getInstance())
|
||||||
@ -140,7 +143,7 @@ public class BilibiliRESTAPI {
|
|||||||
BilibiliRESTAPI.refreshToken = loginResponseEntity.getData().getRefreshToken();
|
BilibiliRESTAPI.refreshToken = loginResponseEntity.getData().getRefreshToken();
|
||||||
BilibiliRESTAPI.mid = loginResponseEntity.getData().getMid();
|
BilibiliRESTAPI.mid = loginResponseEntity.getData().getMid();
|
||||||
LOGGER.info("Login success with username '{}'", username);
|
LOGGER.info("Login success with username '{}'", username);
|
||||||
LOGGER.debug("mid: " + BilibiliRESTAPI.mid);
|
LOGGER.debug("mid: {}", BilibiliRESTAPI.mid);
|
||||||
return loginResponseEntity;
|
return loginResponseEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,6 +161,7 @@ public class BilibiliRESTAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BilibiliRESTAPI.mid = infoEntity.getData().getMid();
|
||||||
return infoEntity;
|
return infoEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,10 +221,11 @@ public class BilibiliRESTAPI {
|
|||||||
if (logoutResponseEntity.getCode() != 0) {
|
if (logoutResponseEntity.getCode() != 0) {
|
||||||
throw new LoginException("access token invalid");
|
throw new LoginException("access token invalid");
|
||||||
}
|
}
|
||||||
|
LOGGER.info("Logout success");
|
||||||
|
LOGGER.debug("Old mid: {}", BilibiliRESTAPI.mid);
|
||||||
BilibiliRESTAPI.accessToken = null;
|
BilibiliRESTAPI.accessToken = null;
|
||||||
BilibiliRESTAPI.refreshToken = null;
|
BilibiliRESTAPI.refreshToken = null;
|
||||||
BilibiliRESTAPI.mid = 0;
|
BilibiliRESTAPI.mid = 0;
|
||||||
LOGGER.info("Logout success");
|
|
||||||
return logoutResponseEntity;
|
return logoutResponseEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user