Skip to content

Commit

Permalink
fix: 修复互动视频graph_version的获取方式
Browse files Browse the repository at this point in the history
  • Loading branch information
nICEnnnnnnnLee committed Oct 23, 2024
1 parent 547e43d commit 1c9a5c2
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions src/nicelee/bilibili/parsers/impl/AbstractBaseParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public VideoInfo getAVDetail(String bvId, int videoFormat, boolean getVideoLink)
Logger.println(detailJson);
JSONObject detailObj = new JSONObject(detailJson).getJSONObject("data");

long aid = detailObj.getLong("aid");
long ctime = detailObj.optLong("ctime") * 1000;
viInfo.setVideoName(detailObj.getString("title"));
viInfo.setBrief(detailObj.getString("desc"));
Expand All @@ -88,28 +89,26 @@ public VideoInfo getAVDetail(String bvId, int videoFormat, boolean getVideoLink)
// 判断是否是互动视频
if (detailObj.optInt("videos") > 1 && array.length() == 1) {
// 查询graph_version版本
String url_graph_version = String.format("https://api.bilibili.com/x/player.so?id=cid:%d&bvid=%s", cid,
bvId);
String xml = util.getContent(url_graph_version, headers_json, HttpCookies.globalCookiesWithFingerprint());
Logger.println(xml);
Pattern p = Pattern.compile("<interaction>.*\"graph_version\" *: *([0-9]+).*</interaction>");
Matcher matcher = p.matcher(xml);
if (matcher.find()) {
String graph_version = matcher.group(1);
Logger.println(graph_version);
List<List<StoryClipInfo>> story_list = new ArrayList<>();
List<StoryClipInfo> originStory = new ArrayList<StoryClipInfo>();
StoryClipInfo storyClip = new StoryClipInfo(cid);
originStory.add(storyClip);
HashSet<StoryClipInfo> node_list = new HashSet<>();
// 从根节点,一直遍历到子节点,找到所有故事线,放到story_list
collectStoryList(bvId, "", graph_version, originStory, story_list, node_list);
LinkedHashMap<Long, ClipInfo> clipMap = storyList2Map(bvId, videoFormat, getVideoLink, viInfo,
story_list);
viInfo.setClips(clipMap);
viInfo.print();
return viInfo;
}
String url_graph_version = String.format("https://api.bilibili.com/x/player/wbi/v2?aid=%d&cid=%d&isGaiaAvoided=false", aid, cid);
url_graph_version += API.genDmImgParams();
url_graph_version = API.encWbi(url_graph_version);
String result = util.getContent(url_graph_version, headers_json, HttpCookies.globalCookiesWithFingerprint());
Logger.println(url_graph_version);
Logger.println(result);
String graph_version = new JSONObject(result).getJSONObject("data").getJSONObject("interaction").optString("graph_version");
Logger.println(graph_version);
List<List<StoryClipInfo>> story_list = new ArrayList<>();
List<StoryClipInfo> originStory = new ArrayList<StoryClipInfo>();
StoryClipInfo storyClip = new StoryClipInfo(cid);
originStory.add(storyClip);
HashSet<StoryClipInfo> node_list = new HashSet<>();
// 从根节点,一直遍历到子节点,找到所有故事线,放到story_list
collectStoryList(bvId, "", graph_version, originStory, story_list, node_list);
LinkedHashMap<Long, ClipInfo> clipMap = storyList2Map(bvId, videoFormat, getVideoLink, viInfo,
story_list);
viInfo.setClips(clipMap);
viInfo.print();
return viInfo;
} else {
LinkedHashMap<Long, ClipInfo> clipMap = new LinkedHashMap<Long, ClipInfo>();
int[] qnListDefault = null;
Expand Down

0 comments on commit 1c9a5c2

Please sign in to comment.