From 5d21df237c3039d2a873f0d6987d387b09be41f7 Mon Sep 17 00:00:00 2001 From: lijia Date: Wed, 8 May 2024 20:15:06 +0800 Subject: [PATCH] =?UTF-8?q?fix=20#192,=20=E4=BF=AE=E5=A4=8D`=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2UP=E4=B8=BB=E6=89=80=E6=9C=89=E9=93=BE=E6=8E=A5`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bilibili/parsers/impl/URL4UPAllMedialistParser.java | 7 +++++-- src/nicelee/bilibili/parsers/impl/URL4UPAllParser.java | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/nicelee/bilibili/parsers/impl/URL4UPAllMedialistParser.java b/src/nicelee/bilibili/parsers/impl/URL4UPAllMedialistParser.java index 8c499d35..b56b597a 100644 --- a/src/nicelee/bilibili/parsers/impl/URL4UPAllMedialistParser.java +++ b/src/nicelee/bilibili/parsers/impl/URL4UPAllMedialistParser.java @@ -142,6 +142,9 @@ public VideoInfo result(int pageSize, int page, Object... obj) { try { // 先获取合集信息 HashMap headers = new HttpHeaders().getCommonHeaders("api.bilibili.com"); + HashMap 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); @@ -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"; diff --git a/src/nicelee/bilibili/parsers/impl/URL4UPAllParser.java b/src/nicelee/bilibili/parsers/impl/URL4UPAllParser.java index 306053fc..0c0c3548 100644 --- a/src/nicelee/bilibili/parsers/impl/URL4UPAllParser.java +++ b/src/nicelee/bilibili/parsers/impl/URL4UPAllParser.java @@ -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 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);