add 新增了批量订阅 add
This commit is contained in:
@@ -1,18 +1,15 @@
|
||||
package com.yutou.biliapi;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.biliapi.api.UserApi;
|
||||
import com.yutou.biliapi.bean.live.SpiBean;
|
||||
import com.yutou.biliapi.bean.login.LoginCookieDatabaseBean;
|
||||
import com.yutou.biliapi.bean.login.LoginUserDatabaseBean;
|
||||
import com.yutou.biliapi.bean.login.UserInfoBean;
|
||||
import com.yutou.biliapi.bean.user.UserInfoBean;
|
||||
import com.yutou.biliapi.net.BiliLoginNetApiManager;
|
||||
import com.yutou.biliapi.databases.BiliBiliLoginDatabase;
|
||||
import com.yutou.biliapi.net.BiliUserNetApiManager;
|
||||
import com.yutou.common.inter.IHttpApiCheckCallback;
|
||||
import com.yutou.common.okhttp.HttpBody;
|
||||
import com.yutou.common.okhttp.HttpCallback;
|
||||
import com.yutou.common.okhttp.HttpLoggingInterceptor;
|
||||
import com.yutou.common.utils.Log;
|
||||
import jakarta.xml.bind.DatatypeConverter;
|
||||
import okhttp3.Headers;
|
||||
@@ -21,8 +18,6 @@ import retrofit2.Response;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -6,9 +6,7 @@ import com.yutou.biliapi.bean.login.QRCodeGenerateBean;
|
||||
import com.yutou.common.okhttp.FileBody;
|
||||
import com.yutou.common.okhttp.HttpBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Path;
|
||||
import retrofit2.http.Query;
|
||||
import retrofit2.http.*;
|
||||
|
||||
public interface LoginApi {
|
||||
/**
|
||||
@@ -32,10 +30,11 @@ public interface LoginApi {
|
||||
@GET("https://www.bilibili.com/correspond/1/{correspondPath}")
|
||||
Call<FileBody<String>> getCorrespond(@Path("correspondPath") String correspondPath);
|
||||
|
||||
@GET("/x/passport-login/web/cookie/refresh")
|
||||
Call<HttpBody<LoginInfoBean>> refreshCookie(@Query("csrf") String bili_jct
|
||||
, @Query("refresh_csrf") String refresh_csrf
|
||||
, @Query("source") String source
|
||||
, @Query("refresh_token") String refresh_token
|
||||
@POST("/x/passport-login/web/cookie/refresh")
|
||||
@FormUrlEncoded
|
||||
Call<HttpBody<LoginInfoBean>> refreshCookie(@Field("csrf") String bili_jct
|
||||
, @Field("refresh_csrf") String refresh_csrf
|
||||
, @Field("source") String source
|
||||
, @Field("refresh_token") String refresh_token
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
package com.yutou.biliapi.api;
|
||||
|
||||
import com.yutou.biliapi.bean.live.SpiBean;
|
||||
import com.yutou.biliapi.bean.login.UserInfoBean;
|
||||
import com.yutou.biliapi.bean.user.UserFollowingsBean;
|
||||
import com.yutou.biliapi.bean.user.UserHomeInfoBean;
|
||||
import com.yutou.biliapi.bean.user.UserInfoBean;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import com.yutou.common.okhttp.HttpBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Path;
|
||||
import retrofit2.http.Query;
|
||||
import retrofit2.http.QueryMap;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public interface UserApi {
|
||||
@GET("/x/web-interface/nav")
|
||||
@@ -13,4 +22,18 @@ public interface UserApi {
|
||||
|
||||
@GET("/x/frontend/finger/spi")
|
||||
Call<HttpBody<SpiBean>> getFingerSpi();
|
||||
|
||||
@GET("/x/relation/followings")
|
||||
Call<HttpBody<UserFollowingsBean>> getFollowings(
|
||||
@Query("vmid") String uid,
|
||||
@Query("order_type") String type,
|
||||
@Query("ps") int num,
|
||||
@Query("pn") int page
|
||||
|
||||
);
|
||||
|
||||
@GET("/x/space/wbi/acc/info")
|
||||
Call<HttpBody<UserHomeInfoBean>> getWbiAccInfo(
|
||||
@QueryMap TreeMap<String,Object> param
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,10 +15,7 @@ import java.math.BigInteger;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import static com.alibaba.fastjson2.util.DateUtils.DateTimeFormatPattern.DATE_FORMAT_10_DASH;
|
||||
|
||||
@@ -40,7 +37,7 @@ public class LiveConfigDatabaseBean extends AbsDatabasesBean {
|
||||
@JSONField(name = "keyword")
|
||||
private List<String> keywordList;
|
||||
@JSONField(name = "weeks")
|
||||
private List<String> weeks;
|
||||
private List<String> weeks=Arrays.asList("1","2","3","4","5","6","7");
|
||||
@JSONField(name = "recordPath")
|
||||
private String recordPath = "live";
|
||||
@JSONField(name = "recordUid")
|
||||
@@ -48,9 +45,9 @@ public class LiveConfigDatabaseBean extends AbsDatabasesBean {
|
||||
@JSONField(name = "recordLiveModel")
|
||||
private int recordLiveModel;//0 - ffmpeg 1 - java
|
||||
@JSONField(name = "recordDanmuDate")
|
||||
private String recordDanmuDate = null;// 时间范围 20:00:00 - 23:59:59
|
||||
private String recordDanmuDate = "00:00:00 - 23:59:59";// 时间范围 20:00:00 - 23:59:59
|
||||
@JSONField(name = "recordLiveDate")
|
||||
private String recordLiveDate = null;// 时间范围 20:00:00 - 23:59:59
|
||||
private String recordLiveDate = "00:00:00 - 23:59:59";// 时间范围 20:00:00 - 23:59:59
|
||||
|
||||
|
||||
public LiveConfigDatabaseBean() {
|
||||
@@ -58,11 +55,11 @@ public class LiveConfigDatabaseBean extends AbsDatabasesBean {
|
||||
}
|
||||
|
||||
public boolean checkRecordDanmuTime() {
|
||||
return DateFormatUtils.checkTime(weeks,recordDanmuDate);
|
||||
return DateFormatUtils.getInstance().checkTime(weeks,recordDanmuDate);
|
||||
}
|
||||
|
||||
public boolean checkRecordLiveTime() {
|
||||
return DateFormatUtils.checkTime(weeks,recordLiveDate);
|
||||
return DateFormatUtils.getInstance().checkTime(weeks,recordLiveDate);
|
||||
}
|
||||
|
||||
public boolean verifyDanmuTimer() {
|
||||
@@ -76,8 +73,8 @@ public class LiveConfigDatabaseBean extends AbsDatabasesBean {
|
||||
private boolean verifyTimer(String val) {
|
||||
try {
|
||||
String[] time = val.split(" - ");
|
||||
Date start = DateFormatUtils.parseTimer(time[0]);
|
||||
Date end = DateFormatUtils.parseTimer(time[1]);
|
||||
Date start = DateFormatUtils.getInstance().parseTimer(time[0]);
|
||||
Date end = DateFormatUtils.getInstance().parseTimer(time[1]);
|
||||
if (start != null && end != null) {
|
||||
return true;
|
||||
}
|
||||
@@ -94,6 +91,6 @@ public class LiveConfigDatabaseBean extends AbsDatabasesBean {
|
||||
List<String> weeks = Arrays.asList("1", "2", "3", "4", "5", "6", "7");
|
||||
LiveConfigDatabaseBean bean=new LiveConfigDatabaseBean();
|
||||
bean.setWeeks(weeks);
|
||||
System.out.println(DateFormatUtils.checkTime(weeks,t));
|
||||
System.out.println(DateFormatUtils.getInstance().checkTime(weeks,t));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.yutou.biliapi.bean.login;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.alibaba.fastjson2.util.DateUtils;
|
||||
import com.yutou.biliapi.bean.user.UserInfoBean;
|
||||
import com.yutou.common.databases.AbsDatabasesBean;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.yutou.biliapi.bean.user;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class UserFollowingsBean extends BaseBean {
|
||||
|
||||
@JSONField(name = "list")
|
||||
private List<Follow> list;
|
||||
@JSONField(name = "total")
|
||||
private int total;
|
||||
|
||||
@Data
|
||||
public static class Follow{
|
||||
@JSONField(name = "mid")
|
||||
private String mid;
|
||||
|
||||
@JSONField(name = "attribute")
|
||||
private int attribute;
|
||||
|
||||
@JSONField(name = "mtime")
|
||||
private long mtime;
|
||||
|
||||
@JSONField(name = "tag")
|
||||
private Object tag; // 可能为 null
|
||||
|
||||
@JSONField(name = "special")
|
||||
private int special;
|
||||
|
||||
@JSONField(name = "contract_info")
|
||||
private Object contractInfo; // 可能为一个空对象 {}
|
||||
|
||||
@JSONField(name = "uname")
|
||||
private String uname;
|
||||
|
||||
@JSONField(name = "face")
|
||||
private String face;
|
||||
|
||||
@JSONField(name = "sign")
|
||||
private String sign;
|
||||
|
||||
@JSONField(name = "face_nft")
|
||||
private int faceNft;
|
||||
|
||||
@JSONField(name = "official_verify")
|
||||
private OfficialVerify officialVerify;
|
||||
|
||||
@JSONField(name = "vip")
|
||||
private Vip vip;
|
||||
|
||||
@JSONField(name = "name_render")
|
||||
private Object nameRender; // 可能为一个空对象 {}
|
||||
|
||||
@JSONField(name = "nft_icon")
|
||||
private String nftIcon;
|
||||
|
||||
@JSONField(name = "rec_reason")
|
||||
private String recReason;
|
||||
|
||||
@JSONField(name = "track_id")
|
||||
private String trackId;
|
||||
|
||||
@JSONField(name = "follow_time")
|
||||
private String followTime;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
public static class OfficialVerify {
|
||||
@JSONField(name = "type")
|
||||
private int type;
|
||||
|
||||
@JSONField(name = "desc")
|
||||
private String desc;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Vip {
|
||||
@JSONField(name = "vipType")
|
||||
private int vipType;
|
||||
|
||||
@JSONField(name = "vipDueDate")
|
||||
private long vipDueDate;
|
||||
|
||||
@JSONField(name = "dueRemark")
|
||||
private String dueRemark;
|
||||
|
||||
@JSONField(name = "accessStatus")
|
||||
private int accessStatus;
|
||||
|
||||
@JSONField(name = "vipStatus")
|
||||
private int vipStatus;
|
||||
|
||||
@JSONField(name = "vipStatusWarn")
|
||||
private String vipStatusWarn;
|
||||
|
||||
@JSONField(name = "themeType")
|
||||
private int themeType;
|
||||
|
||||
@JSONField(name = "label")
|
||||
private Label label;
|
||||
|
||||
@JSONField(name = "avatar_subscript")
|
||||
private int avatarSubscript;
|
||||
|
||||
@JSONField(name = "nickname_color")
|
||||
private String nicknameColor;
|
||||
|
||||
@JSONField(name = "avatar_subscript_url")
|
||||
private String avatarSubscriptUrl;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Label {
|
||||
@JSONField(name = "path")
|
||||
private String path;
|
||||
|
||||
@JSONField(name = "text")
|
||||
private String text;
|
||||
|
||||
@JSONField(name = "label_theme")
|
||||
private String labelTheme;
|
||||
|
||||
@JSONField(name = "text_color")
|
||||
private String textColor;
|
||||
|
||||
@JSONField(name = "bg_style")
|
||||
private int bgStyle;
|
||||
|
||||
@JSONField(name = "bg_color")
|
||||
private String bgColor;
|
||||
|
||||
@JSONField(name = "border_color")
|
||||
private String borderColor;
|
||||
}
|
||||
}
|
||||
495
src/main/java/com/yutou/biliapi/bean/user/UserHomeInfoBean.java
Normal file
495
src/main/java/com/yutou/biliapi/bean/user/UserHomeInfoBean.java
Normal file
@@ -0,0 +1,495 @@
|
||||
package com.yutou.biliapi.bean.user;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.yutou.common.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class UserHomeInfoBean extends BaseBean {
|
||||
|
||||
@JSONField(name = "mid")
|
||||
private long mid;
|
||||
|
||||
@JSONField(name = "name")
|
||||
private String name;
|
||||
|
||||
@JSONField(name = "sex")
|
||||
private String sex;
|
||||
|
||||
@JSONField(name = "face")
|
||||
private String face;
|
||||
|
||||
@JSONField(name = "face_nft")
|
||||
private long faceNft;
|
||||
|
||||
@JSONField(name = "face_nft_type")
|
||||
private long faceNftType;
|
||||
|
||||
@JSONField(name = "sign")
|
||||
private String sign;
|
||||
|
||||
@JSONField(name = "rank")
|
||||
private long rank;
|
||||
|
||||
@JSONField(name = "level")
|
||||
private long level;
|
||||
|
||||
@JSONField(name = "jointime")
|
||||
private long jointime;
|
||||
|
||||
@JSONField(name = "moral")
|
||||
private long moral;
|
||||
|
||||
@JSONField(name = "silence")
|
||||
private long silence;
|
||||
|
||||
@JSONField(name = "coins")
|
||||
private long coins;
|
||||
|
||||
@JSONField(name = "fans_badge")
|
||||
private boolean fansBadge;
|
||||
|
||||
@JSONField(name = "fans_medal")
|
||||
private FansMedal fansMedal;
|
||||
|
||||
@JSONField(name = "official")
|
||||
private Official official;
|
||||
|
||||
@JSONField(name = "vip")
|
||||
private Vip vip;
|
||||
|
||||
@JSONField(name = "pendant")
|
||||
private Pendant pendant;
|
||||
|
||||
@JSONField(name = "nameplate")
|
||||
private Nameplate nameplate;
|
||||
|
||||
@JSONField(name = "user_honour_info")
|
||||
private UserHonourInfo userHonourInfo;
|
||||
|
||||
@JSONField(name = "is_followed")
|
||||
private boolean isFollowed;
|
||||
|
||||
@JSONField(name = "top_photo")
|
||||
private String topPhoto;
|
||||
|
||||
@JSONField(name = "theme")
|
||||
private SysNotice theme;
|
||||
|
||||
@JSONField(name = "sys_notice")
|
||||
private SysNotice sysNotice;
|
||||
|
||||
@JSONField(name = "live_room")
|
||||
private LiveRoom liveRoom;
|
||||
|
||||
@JSONField(name = "birthday")
|
||||
private String birthday;
|
||||
|
||||
@JSONField(name = "school")
|
||||
private Object school;
|
||||
|
||||
@JSONField(name = "profession")
|
||||
private Profession profession;
|
||||
|
||||
@JSONField(name = "tags")
|
||||
private List<String> tags;
|
||||
|
||||
@JSONField(name = "series")
|
||||
private Series series;
|
||||
|
||||
@JSONField(name = "is_senior_member")
|
||||
private long isSeniorMember;
|
||||
|
||||
@JSONField(name = "mcn_info")
|
||||
private Object mcnInfo;
|
||||
|
||||
@JSONField(name = "gaia_res_type")
|
||||
private long gaiaResType;
|
||||
|
||||
@JSONField(name = "gaia_data")
|
||||
private Object gaiaData;
|
||||
|
||||
@JSONField(name = "is_risk")
|
||||
private boolean isRisk;
|
||||
|
||||
@JSONField(name = "elec")
|
||||
private Elec elec;
|
||||
|
||||
@JSONField(name = "contract")
|
||||
private Object contract;
|
||||
|
||||
@JSONField(name = "certificate_show")
|
||||
private boolean certificateShow;
|
||||
|
||||
@JSONField(name = "name_render")
|
||||
private Object nameRender;
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
public static class Elec {
|
||||
@JSONField(name = "show_info")
|
||||
private ShowInfo showInfo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
public static class ShowInfo {
|
||||
@JSONField(name = "show")
|
||||
private boolean show;
|
||||
|
||||
@JSONField(name = "state")
|
||||
private long state;
|
||||
|
||||
@JSONField(name = "title")
|
||||
private String title;
|
||||
|
||||
@JSONField(name = "icon")
|
||||
private String icon;
|
||||
|
||||
@JSONField(name = "jump_url")
|
||||
private String jumpURL;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class FansMedal {
|
||||
@JSONField(name = "show")
|
||||
private boolean show;
|
||||
|
||||
@JSONField(name = "wear")
|
||||
private boolean wear;
|
||||
|
||||
@JSONField(name = "medal")
|
||||
private Medal medal;
|
||||
}
|
||||
|
||||
|
||||
@Data
|
||||
public static class Medal {
|
||||
|
||||
@JSONField(name = "uid")
|
||||
private long uid;
|
||||
|
||||
@JSONField(name = "target_id")
|
||||
private long targetID;
|
||||
|
||||
@JSONField(name = "medal_id")
|
||||
private long medalID;
|
||||
|
||||
@JSONField(name = "level")
|
||||
private long level;
|
||||
|
||||
@JSONField(name = "medal_name")
|
||||
private String medalName;
|
||||
|
||||
@JSONField(name = "medal_color")
|
||||
private long medalColor;
|
||||
|
||||
@JSONField(name = "intimacy")
|
||||
private long intimacy;
|
||||
|
||||
@JSONField(name = "next_intimacy")
|
||||
private long nextIntimacy;
|
||||
|
||||
@JSONField(name = "day_limit")
|
||||
private long dayLimit;
|
||||
|
||||
@JSONField(name = "today_feed")
|
||||
private long todayFeed;
|
||||
|
||||
@JSONField(name = "medal_color_start")
|
||||
private long medalColorStart;
|
||||
|
||||
@JSONField(name = "medal_color_end")
|
||||
private long medalColorEnd;
|
||||
|
||||
@JSONField(name = "medal_color_border")
|
||||
private long medalColorBorder;
|
||||
|
||||
@JSONField(name = "is_lighted")
|
||||
private long isLighted;
|
||||
|
||||
@JSONField(name = "guard_level")
|
||||
private long guardLevel;
|
||||
|
||||
@JSONField(name = "light_status")
|
||||
private long lightStatus;
|
||||
|
||||
@JSONField(name = "wearing_status")
|
||||
private long wearingStatus;
|
||||
|
||||
@JSONField(name = "score")
|
||||
private long score;
|
||||
}
|
||||
|
||||
|
||||
@Data
|
||||
public static class LiveRoom {
|
||||
|
||||
@JSONField(name = "roomStatus")
|
||||
private long roomStatus;
|
||||
|
||||
@JSONField(name = "liveStatus")
|
||||
private long liveStatus;
|
||||
|
||||
@JSONField(name = "url")
|
||||
private String url;
|
||||
|
||||
@JSONField(name = "title")
|
||||
private String title;
|
||||
|
||||
@JSONField(name = "cover")
|
||||
private String cover;
|
||||
|
||||
@JSONField(name = "roomid")
|
||||
private long roomid;
|
||||
|
||||
@JSONField(name = "roundStatus")
|
||||
private long roundStatus;
|
||||
|
||||
@JSONField(name = "broadcast_type")
|
||||
private long broadcastType;
|
||||
|
||||
@JSONField(name = "watched_show")
|
||||
private WatchedShow watchedShow;
|
||||
}
|
||||
|
||||
|
||||
@Data
|
||||
public static class WatchedShow {
|
||||
|
||||
@JSONField(name = "switch")
|
||||
private boolean watchedShowSwitch;
|
||||
|
||||
@JSONField(name = "num")
|
||||
private long num;
|
||||
|
||||
@JSONField(name = "text_small")
|
||||
private String textSmall;
|
||||
|
||||
@JSONField(name = "text_large")
|
||||
private String textLarge;
|
||||
|
||||
@JSONField(name = "icon")
|
||||
private String icon;
|
||||
|
||||
@JSONField(name = "icon_location")
|
||||
private String iconLocation;
|
||||
|
||||
@JSONField(name = "icon_web")
|
||||
private String iconWeb;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Nameplate {
|
||||
|
||||
@JSONField(name = "nid")
|
||||
private long nid;
|
||||
|
||||
@JSONField(name = "name")
|
||||
private String name;
|
||||
|
||||
@JSONField(name = "image")
|
||||
private String image;
|
||||
|
||||
@JSONField(name = "image_small")
|
||||
private String imageSmall;
|
||||
|
||||
@JSONField(name = "level")
|
||||
private String level;
|
||||
|
||||
@JSONField(name = "condition")
|
||||
private String condition;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Official {
|
||||
|
||||
@JSONField(name = "role")
|
||||
private long role;
|
||||
|
||||
@JSONField(name = "title")
|
||||
private String title;
|
||||
|
||||
@JSONField(name = "desc")
|
||||
private String desc;
|
||||
|
||||
@JSONField(name = "type")
|
||||
private long type;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Pendant {
|
||||
|
||||
@JSONField(name = "pid")
|
||||
private long pid;
|
||||
|
||||
@JSONField(name = "name")
|
||||
private String name;
|
||||
|
||||
@JSONField(name = "image")
|
||||
private String image;
|
||||
|
||||
@JSONField(name = "expire")
|
||||
private long expire;
|
||||
|
||||
@JSONField(name = "image_enhance")
|
||||
private String imageEnhance;
|
||||
|
||||
@JSONField(name = "image_enhance_frame")
|
||||
private String imageEnhanceFrame;
|
||||
|
||||
@JSONField(name = "n_pid")
|
||||
private long nPID;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Profession {
|
||||
|
||||
@JSONField(name = "name")
|
||||
private String name;
|
||||
|
||||
@JSONField(name = "department")
|
||||
private String department;
|
||||
|
||||
@JSONField(name = "title")
|
||||
private String title;
|
||||
|
||||
@JSONField(name = "is_show")
|
||||
private long isShow;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Series {
|
||||
|
||||
@JSONField(name = "user_upgrade_status")
|
||||
private long userUpgradeStatus;
|
||||
|
||||
@JSONField(name = "show_upgrade_window")
|
||||
private boolean showUpgradeWindow;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class SysNotice {
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class UserHonourInfo {
|
||||
|
||||
@JSONField(name = "mid")
|
||||
private long mid;
|
||||
|
||||
@JSONField(name = "colour")
|
||||
private Object colour;
|
||||
|
||||
@JSONField(name = "tags")
|
||||
private List<Object> tags;
|
||||
|
||||
@JSONField(name = "is_latest_100honour")
|
||||
private long isLatest100Honour;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Vip {
|
||||
|
||||
@JSONField(name = "type")
|
||||
private long type;
|
||||
|
||||
@JSONField(name = "status")
|
||||
private long status;
|
||||
|
||||
@JSONField(name = "due_date")
|
||||
private long dueDate;
|
||||
|
||||
@JSONField(name = "vip_pay_type")
|
||||
private long vipPayType;
|
||||
|
||||
@JSONField(name = "theme_type")
|
||||
private long themeType;
|
||||
|
||||
@JSONField(name = "label")
|
||||
private Label label;
|
||||
|
||||
@JSONField(name = "avatar_subscript")
|
||||
private long avatarSubscript;
|
||||
|
||||
@JSONField(name = "nickname_color")
|
||||
private String nicknameColor;
|
||||
|
||||
@JSONField(name = "role")
|
||||
private long role;
|
||||
|
||||
@JSONField(name = "avatar_subscript_url")
|
||||
private String avatarSubscriptURL;
|
||||
|
||||
@JSONField(name = "tv_vip_status")
|
||||
private long tvVipStatus;
|
||||
|
||||
@JSONField(name = "tv_vip_pay_type")
|
||||
private long tvVipPayType;
|
||||
|
||||
@JSONField(name = "tv_due_date")
|
||||
private long tvDueDate;
|
||||
|
||||
@JSONField(name = "avatar_icon")
|
||||
private AvatarIcon avatarIcon;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class AvatarIcon {
|
||||
|
||||
@JSONField(name = "icon_type")
|
||||
private long iconType;
|
||||
|
||||
@JSONField(name = "icon_resource")
|
||||
private SysNotice iconResource;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Label {
|
||||
|
||||
@JSONField(name = "path")
|
||||
private String path;
|
||||
|
||||
@JSONField(name = "text")
|
||||
private String text;
|
||||
|
||||
@JSONField(name = "label_theme")
|
||||
private String labelTheme;
|
||||
|
||||
@JSONField(name = "text_color")
|
||||
private String textColor;
|
||||
|
||||
@JSONField(name = "bg_style")
|
||||
private long bgStyle;
|
||||
|
||||
@JSONField(name = "bg_color")
|
||||
private String bgColor;
|
||||
|
||||
@JSONField(name = "border_color")
|
||||
private String borderColor;
|
||||
|
||||
@JSONField(name = "use_img_label")
|
||||
private boolean useImgLabel;
|
||||
|
||||
@JSONField(name = "img_label_uri_hans")
|
||||
private String imgLabelURIHans;
|
||||
|
||||
@JSONField(name = "img_label_uri_hant")
|
||||
private String imgLabelURIHant;
|
||||
|
||||
@JSONField(name = "img_label_uri_hans_static")
|
||||
private String imgLabelURIHansStatic;
|
||||
|
||||
@JSONField(name = "img_label_uri_hant_static")
|
||||
private String imgLabelURIHantStatic;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.yutou.biliapi.bean.login;
|
||||
package com.yutou.biliapi.bean.user;
|
||||
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
@@ -6,7 +6,6 @@ import com.yutou.common.okhttp.BaseBean;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Date;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@@ -4,11 +4,11 @@ import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.biliapi.bean.login.LoginCookieDatabaseBean;
|
||||
import com.yutou.biliapi.bean.login.LoginUserDatabaseBean;
|
||||
import com.yutou.biliapi.bean.login.UserInfoBean;
|
||||
import com.yutou.biliapi.bean.user.UserInfoBean;
|
||||
import com.yutou.bilibili.Tools.DateFormatUtils;
|
||||
import com.yutou.common.databases.AbsDatabasesBean;
|
||||
import com.yutou.common.databases.SQLiteManager;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -86,7 +86,9 @@ public class BiliBiliLoginDatabase extends SQLiteManager {
|
||||
List<LoginUserDatabaseBean> list = new ArrayList<>();
|
||||
for (Object o : jsonArray) {
|
||||
JSONObject json = (JSONObject) o;
|
||||
list.add(new LoginUserDatabaseBean(json.to(UserInfoBean.class)));
|
||||
LoginUserDatabaseBean bean = new LoginUserDatabaseBean(json.to(UserInfoBean.class));
|
||||
bean.setSql_time(DateFormatUtils.getInstance().parse(json.getString("sql_time"),DateFormatUtils.DEFAULT_PATTERN));
|
||||
list.add(bean);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@@ -100,6 +102,10 @@ public class BiliBiliLoginDatabase extends SQLiteManager {
|
||||
protected List<AbsDatabasesBean> getDataBean() {
|
||||
return List.of(new LoginCookieDatabaseBean(), new LoginUserDatabaseBean(null));
|
||||
}
|
||||
|
||||
public void updateLoginCookie(LoginCookieDatabaseBean cookie) {
|
||||
update(cookie);
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.yutou.biliapi.databases;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.util.DateUtils;
|
||||
import com.yutou.biliapi.bean.live.*;
|
||||
@@ -116,8 +117,67 @@ public class BiliLiveDatabase extends SQLiteManager {
|
||||
addData(bean);
|
||||
}
|
||||
|
||||
public JSONObject getGiftInfo(long startTimeLong, long endTimeLong) {
|
||||
String startTime = DateFormatUtils.getInstance().format(startTimeLong);
|
||||
String endTime = DateFormatUtils.getInstance().format(endTimeLong);
|
||||
String giftSql = "WITH filtered_gifts AS (" +
|
||||
"SELECT " +
|
||||
"`gift_name`," +
|
||||
"`icon`, " +
|
||||
"SUM(`gift_num`) AS `total_gift_num`," +
|
||||
"CASE " +
|
||||
"WHEN `coin_type` = 'silver' THEN 0 " +
|
||||
"ELSE SUM(`price` * `gift_num`) " +
|
||||
"END AS `total_price`" +
|
||||
"FROM " +
|
||||
"`gift` " +
|
||||
"WHERE " +
|
||||
"`sql_time` >= '" + startTime + "' " +
|
||||
"AND `sql_time` <= '" + endTime + "' " +
|
||||
"GROUP BY " +
|
||||
"`gift_name`, `coin_type`" +
|
||||
")" +
|
||||
"SELECT " +
|
||||
"`gift_name`," +
|
||||
"`icon`," +
|
||||
"SUM(`total_gift_num`) AS `total_gift_num`," +
|
||||
"SUM(`total_price`) AS `total_price`" +
|
||||
"FROM " +
|
||||
"filtered_gifts " +
|
||||
"GROUP BY " +
|
||||
"`gift_name`, `icon`;";
|
||||
String guardSql = "SELECT `gift_name`, SUM(`num`) AS `total_num`,SUM(`price`*`num`) as `total_price`" +
|
||||
"FROM `guardBuy` where `sql_time` >= '" + startTime + "' and `sql_time` <= '" + endTime + "'" +
|
||||
"GROUP BY `gift_name`;";
|
||||
String superChatSql = "SELECT SUM(`price`*100) as `total_price`, count(`price`) as `total_count`" +
|
||||
"FROM `superChat` where `sql_time` >= '" + startTime + "' and `sql_time` <= '" + endTime + "';";
|
||||
JSONObject json = new JSONObject();
|
||||
JSONArray giftInfo = get(giftSql);
|
||||
JSONArray guardInfo = get(guardSql);
|
||||
JSONArray superChatInfo = get(superChatSql);
|
||||
json.put("giftInfo", giftInfo);
|
||||
json.put("guardInfo", guardInfo);
|
||||
if (!superChatInfo.isEmpty()) {
|
||||
json.put("superChatInfo", superChatInfo.getFirst());
|
||||
} else {
|
||||
json.put("superChatInfo", new JSONObject());
|
||||
}
|
||||
json.put("price", getGiftPrice(giftInfo) + getGiftPrice(guardInfo) + getGiftPrice(superChatInfo));
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
private long getGiftPrice(JSONArray array) {
|
||||
long price = 0;
|
||||
for (Object o : array) {
|
||||
JSONObject item = (JSONObject) o;
|
||||
price += item.getLongValue("total_price");
|
||||
}
|
||||
return price;
|
||||
}
|
||||
|
||||
private void createInfo(LiveVideoDatabaseBean bean) {
|
||||
String format = DateFormatUtils.format(bean.getSql_time());
|
||||
String format = DateFormatUtils.getInstance().format(bean.getSql_time());
|
||||
if (get(bean.getTableName(), " `sql_time` = '" + format + "'", LiveVideoDatabaseBean.class).isEmpty()) {
|
||||
add(bean);
|
||||
} else {
|
||||
@@ -125,18 +185,18 @@ public class BiliLiveDatabase extends SQLiteManager {
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends AbsDatabasesBean> List<T> getOfTime(String startTime, String entTime, Class<T> clazz) {
|
||||
public <T extends AbsDatabasesBean> List<T> getOfTime(String startTime, String endTime, Class<T> clazz) {
|
||||
String tableName = null;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String where = null;
|
||||
if (startTime != null) {
|
||||
sb.append(" `sql_time` >= ").append("\"").append(startTime).append("\"");
|
||||
}
|
||||
if (entTime != null) {
|
||||
if (endTime != null) {
|
||||
if (!sb.isEmpty()) {
|
||||
sb.append(" and ");
|
||||
}
|
||||
sb.append(" `sql_time` <= ").append("\"").append(entTime).append("\"");
|
||||
sb.append(" `sql_time` <= ").append("\"").append(endTime).append("\"");
|
||||
}
|
||||
if (!sb.isEmpty()) {
|
||||
where = sb.toString();
|
||||
@@ -150,6 +210,16 @@ public class BiliLiveDatabase extends SQLiteManager {
|
||||
return super.get(tableName, where, clazz);
|
||||
}
|
||||
|
||||
public LiveVideoDatabaseBean getVideo(String videoId) {
|
||||
for (LiveVideoDatabaseBean info : getLiveInfos()) {
|
||||
System.out.println(videoId + " " + info.getSql_time().getTime());
|
||||
if (videoId.trim().equals(String.valueOf(info.getSql_time().getTime()))) {
|
||||
return info;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void resetSQL() {
|
||||
List<AbsDatabasesBean> list = List.of(
|
||||
new LiveInfoDatabaseBean(),
|
||||
@@ -175,7 +245,7 @@ public class BiliLiveDatabase extends SQLiteManager {
|
||||
|
||||
public static void main(String[] args) {
|
||||
BiliLiveDatabase biliLiveDatabase = new BiliLiveDatabase(LiveRoomConfig.buildConfig("7688602"));
|
||||
biliLiveDatabase.resetSQL();
|
||||
biliLiveDatabase.resetSQL();
|
||||
biliLiveDatabase.resetData();
|
||||
|
||||
}
|
||||
|
||||
@@ -3,22 +3,17 @@ package com.yutou.biliapi.net;
|
||||
import com.yutou.biliapi.api.LoginApi;
|
||||
import com.yutou.biliapi.bean.login.LoginCookieDatabaseBean;
|
||||
import com.yutou.biliapi.bean.login.LoginInfoBean;
|
||||
import com.yutou.biliapi.databases.BiliBiliLoginDatabase;
|
||||
import com.yutou.common.okhttp.FileBody;
|
||||
import com.yutou.common.okhttp.HttpBody;
|
||||
import com.yutou.common.okhttp.HttpLoggingInterceptor;
|
||||
import com.yutou.common.utils.Log;
|
||||
import com.yutou.common.utils.WebClient;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import retrofit2.Response;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.OAEPParameterSpec;
|
||||
import javax.crypto.spec.PSource;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.KeyFactory;
|
||||
@@ -75,13 +70,15 @@ public class BiliCookieManager {
|
||||
return htmlContent;
|
||||
}
|
||||
|
||||
public static boolean resetCookie(LoginCookieDatabaseBean cookie) {
|
||||
public static boolean refreshCookie(LoginCookieDatabaseBean cookie) {
|
||||
try {
|
||||
LoginApi api = BiliLoginNetApiManager.getInstance().getLoginApi(cookie.getDedeUserID());
|
||||
String correspondPath = getCorrespondPath(String.format("refresh_%d", System.currentTimeMillis()));
|
||||
System.out.println("correspondPath = " + correspondPath);
|
||||
Thread.sleep(300);
|
||||
Response<FileBody<String>> body = api.getCorrespond(correspondPath).execute();
|
||||
if(body.code()==404){
|
||||
System.out.println("返回404");
|
||||
return false;
|
||||
}
|
||||
System.out.println("body.code() = " + body.code());
|
||||
@@ -91,9 +88,13 @@ public class BiliCookieManager {
|
||||
Response<HttpBody<LoginInfoBean>> newCookie = api.refreshCookie(cookie.getBiliJct(), refreshCsrf, "main_web", cookie.getRefreshToken()).execute();
|
||||
LoginCookieDatabaseBean nc = BiliLoginNetApiManager.getInstance().getCookie(newCookie.headers(), newCookie.body());
|
||||
nc.setGourl(cookie.getGourl());
|
||||
nc.setSql_time(cookie.getSql_time());
|
||||
BiliBiliLoginDatabase.getInstance().updateLoginCookie(nc);
|
||||
System.out.println("返回正确");
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
Log.e(e);
|
||||
System.out.println("返回错误");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,17 @@ package com.yutou.biliapi.net;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.biliapi.api.UserApi;
|
||||
import com.yutou.biliapi.bean.login.LoginCookieDatabaseBean;
|
||||
import com.yutou.biliapi.bean.user.UserFollowingsBean;
|
||||
import com.yutou.biliapi.databases.BiliBiliLoginDatabase;
|
||||
import com.yutou.bilibili.Controllers.BiliUserController;
|
||||
import com.yutou.bilibili.services.LiveLoginService;
|
||||
import com.yutou.common.inter.IHttpApiCheckCallback;
|
||||
import com.yutou.common.okhttp.HttpCallback;
|
||||
import com.yutou.common.okhttp.api.BaseApi;
|
||||
import okhttp3.Headers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class BiliUserNetApiManager extends BaseApi {
|
||||
public static final int LOGIN_LOGOUT = 1;
|
||||
@@ -26,17 +32,45 @@ public class BiliUserNetApiManager extends BaseApi {
|
||||
}
|
||||
|
||||
public UserApi getUserApi(LoginCookieDatabaseBean cookie) {
|
||||
return getUserApi(cookie, null);
|
||||
}
|
||||
|
||||
public UserApi getUserApi(LoginCookieDatabaseBean cookie, HashMap<String, String> addCookie) {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
StringBuilder ck = new StringBuilder();
|
||||
if (cookie != null) {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
JSONObject json = JSONObject.parseObject(JSONObject.toJSONString(cookie));
|
||||
StringBuilder ck = new StringBuilder();
|
||||
for (String key : json.keySet()) {
|
||||
ck.append(key).append("=").append(json.getString(key)).append("; ");
|
||||
}
|
||||
}
|
||||
if (addCookie != null) {
|
||||
addCookie.forEach((k, v) -> ck.append(k).append("=").append(v).append("; "));
|
||||
}
|
||||
if(!ck.isEmpty()) {
|
||||
headers.put("Cookie", ck.toString());
|
||||
setHeaders(headers);
|
||||
}
|
||||
return createApi(UserApi.class);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
LiveLoginService loginService = new LiveLoginService();
|
||||
LoginCookieDatabaseBean cookie = loginService.getCookie("96300");
|
||||
UserApi api = BiliUserNetApiManager.getInstance().getUserApi(cookie);
|
||||
api.getFollowings(cookie.getDedeUserID(), "", 50, 1).enqueue(new HttpCallback<UserFollowingsBean>() {
|
||||
@Override
|
||||
public void onResponse(Headers headers, int code, String status, UserFollowingsBean response, String rawResponse) {
|
||||
System.out.println("关注数:" + response.getTotal());
|
||||
for (UserFollowingsBean.Follow follow : response.getList()) {
|
||||
System.out.println(follow.getUname());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable throwable) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
89
src/main/java/com/yutou/biliapi/net/WebSignManager.java
Normal file
89
src/main/java/com/yutou/biliapi/net/WebSignManager.java
Normal file
@@ -0,0 +1,89 @@
|
||||
package com.yutou.biliapi.net;
|
||||
|
||||
import com.yutou.biliapi.bean.live.SpiBean;
|
||||
import com.yutou.biliapi.bean.user.UserHomeInfoBean;
|
||||
import com.yutou.biliapi.bean.user.UserInfoBean;
|
||||
import com.yutou.common.utils.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WebSignManager {
|
||||
private static final int[] mixinKeyEncTab = new int[]{
|
||||
46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49,
|
||||
33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40,
|
||||
61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, 62, 11,
|
||||
36, 20, 34, 44, 52
|
||||
};
|
||||
|
||||
private static final char[] hexDigits = "0123456789abcdef".toCharArray();
|
||||
|
||||
public static String md5(String input) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] messageDigest = md.digest(input.getBytes(StandardCharsets.UTF_8));
|
||||
char[] result = new char[messageDigest.length * 2];
|
||||
for (int i = 0; i < messageDigest.length; i++) {
|
||||
result[i * 2] = hexDigits[(messageDigest[i] >> 4) & 0xF];
|
||||
result[i * 2 + 1] = hexDigits[messageDigest[i] & 0xF];
|
||||
}
|
||||
return new String(result);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getMixinKey(String imgKey, String subKey) {
|
||||
String s = imgKey + subKey;
|
||||
StringBuilder key = new StringBuilder();
|
||||
for (int i = 0; i < 32; i++)
|
||||
key.append(s.charAt(mixinKeyEncTab[i]));
|
||||
return key.toString();
|
||||
}
|
||||
|
||||
public static String encodeURIComponent(Object o) {
|
||||
return URLEncoder.encode(o.toString(), StandardCharsets.UTF_8).replace("+", "%20");
|
||||
}
|
||||
|
||||
private static String getKey(String url) {
|
||||
// 使用正则表达式匹配所需的字段
|
||||
String pattern = "/(\\w+)\\.png$";
|
||||
Pattern r = Pattern.compile(pattern);
|
||||
Matcher m = r.matcher(url);
|
||||
if (m.find()) {
|
||||
return m.group(1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static TreeMap<String, Object> getWebSign(TreeMap<String,Object> map, UserInfoBean userInfo) {
|
||||
try {
|
||||
String imgKey = getKey(userInfo.getWbiImg().getImgUrl());
|
||||
String subKey = getKey(userInfo.getWbiImg().getSubUrl());
|
||||
String mixinKey = getMixinKey(imgKey, subKey);
|
||||
// 用TreeMap自动排序
|
||||
|
||||
map.put("wts", System.currentTimeMillis() / 1000);
|
||||
String param = map.entrySet().stream()
|
||||
.map(it -> String.format("%s=%s", it.getKey(), encodeURIComponent(it.getValue())))
|
||||
.collect(Collectors.joining("&"));
|
||||
String s = param + mixinKey;
|
||||
String wbiSign = md5(s);
|
||||
map.put("w_rid", wbiSign);
|
||||
return map;
|
||||
} catch (Exception e) {
|
||||
Log.e(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user