Skip to content

Commit

Permalink
fix nICEnnnnnnnLee#192, 修复查询UP主所有链接
Browse files Browse the repository at this point in the history
  • Loading branch information
nICEnnnnnnnLee committed May 8, 2024
1 parent 03240fc commit 5d21df2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ public VideoInfo result(int pageSize, int page, Object... obj) {
try {
// 先获取合集信息
HashMap<String, String> headers = new HttpHeaders().getCommonHeaders("api.bilibili.com");
HashMap<String, String> headersRefer = new HashMap<>(headers);
headersRefer.put("Referer", "https://space.bilibili.com/");
headersRefer.put("Origin", "https://space.bilibili.com/");
if (pageQueryResult.getVideoName() == null) {
String url = "https://api.bilibili.com/x/v1/medialist/info?type=1&tid=0&biz_id=" + spaceID;
Logger.println(url);
Expand All @@ -162,10 +165,10 @@ public VideoInfo result(int pageSize, int page, Object... obj) {
break;
}
}
String firstOid = position2Oid((page - 1) * pageSize + 1, headers, sortFieldParam);
String firstOid = position2Oid((page - 1) * pageSize + 1, headersRefer, sortFieldParam);
if(firstOid.equals("end"))
return pageQueryResult;
String lastOidPlus1 = position2Oid(page * pageSize + 1, headers, sortFieldParam);
String lastOidPlus1 = position2Oid(page * pageSize + 1, headersRefer, sortFieldParam);

// 根据oid查询分页的详细信息
String urlFormat = "https://api.bilibili.com/x/v2/medialist/resource/list?type=1&oid=%s&otype=2&biz_id=%s&bvid=&with_current=%s&mobi_app=web&ps=%d&direction=false&sort_field=%d&tid=%s&desc=true";
Expand Down
5 changes: 4 additions & 1 deletion src/nicelee/bilibili/parsers/impl/URL4UPAllParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ protected boolean query(int page, int min, int max, Object... obj) {
String url = String.format(urlFormat, spaceID, API_PMAX, params.get("tid"), page, keyword, params.get("order"));
url += API.genDmImgParams();
url = API.encWbi(url);
String json = util.getContent(url, new HttpHeaders().getCommonHeaders("api.bilibili.com"), HttpCookies.globalCookiesWithFingerprint());
HashMap<String, String> headersRefer = new HttpHeaders().getCommonHeaders("api.bilibili.com");
headersRefer.put("Referer", "https://space.bilibili.com/");
headersRefer.put("Origin", "https://space.bilibili.com/");
String json = util.getContent(url, headersRefer, HttpCookies.globalCookiesWithFingerprint());
Logger.println(url);
Logger.println(json);
JSONObject jobj = new JSONObject(json);
Expand Down

0 comments on commit 5d21df2

Please sign in to comment.