直播:新接口适应性支持 - #189
Open
frostnotfall wants to merge 23 commits into
Open
Conversation
…fmp4,回退至ts,支持直播备份地址,目前的小问题,画质选项中会出现HLS相关选项,貌似是potplayer特性。
There was a problem hiding this comment.
Pull request overview
该 PR 针对 Bilibili 直播播放解析切换到新版直播播放接口(getRoomPlayInfo),以适配更多编码/封装与备份地址输出,从而提升直播播放的兼容性与可选项。
Changes:
- 新增直播画质映射(
getLiveQuality),并在直播解析中基于新版playurl_info解析协议/封装/编码信息。 - 直播流优先选择
fmp4,无fmp4时回退到ts,并为主地址提供备份地址条目。 - 直播画质列表按 codec(AVC/HEVC/AV1)分别生成对应 URL 与 itag。
Suppressed comments (1)
Media/PlayParse/MediaPlayParse - Bilibili.as:1791
- 备份流的 itag 同样建议使用 getLiveItag(qn),保持与主流一致的排序/选择逻辑。
qualityItemBackup["itag"] = getItag(temp_codec["current_qn"].asInt()) * 100 + codecOffset * 10 + 1;
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+1602
to
+1612
| string getLiveQuality(int qn) { | ||
| if (qn == 30000) return "杜比"; | ||
| if (qn == 20000) return "4K超高清"; | ||
| if (qn == 15000) return "2K(原画)"; | ||
| if (qn == 10000) return "1080p(原画)"; | ||
| if (qn == 400) return "1080p(蓝光)"; | ||
| if (qn == 250) return "720p(超清)"; | ||
| if (qn == 150) return "480p(高清)"; | ||
| if (qn == 80) return "360p(流畅)"; | ||
| return ""; | ||
| } |
Comment on lines
+1693
to
+1701
| string default_format_name = ""; | ||
| for (int a = 0; a < formats.size(); a++) { | ||
| if (formats[a]["format_name"].asString() == "fmp4") { | ||
| default_format_name = "fmp4"; | ||
| break; | ||
| } else if (formats[a]["format_name"].asString() == "ts") { | ||
| default_format_name = "ts"; | ||
| } | ||
| JsonValue qyality_data = temp["data"]["durl"]; | ||
| if (qyality_data.isArray()) { | ||
| qualityitem["url"] = qyality_data[0]["url"].asString(); | ||
| if (qyality_data.size() > 1) { | ||
| qualityitem2["url"] = qyality_data[1]["url"].asString(); | ||
| } |
Comment on lines
+1721
to
+1729
| int best_qn = 0; | ||
| for (int i = 0; i < accept_qnArray.size(); i++) { | ||
| int accept_qn = accept_qnArray[i]; | ||
| if (best_qn < accept_qn) { | ||
| best_qn = accept_qn; | ||
| } | ||
| } | ||
|
|
||
| if (@QualityList !is null) { |
Comment on lines
+1730
to
+1734
| for (int i = 0; i < accept_qnArray.size(); i++) { | ||
| int accept_qn = accept_qnArray[i]; | ||
| string quality_res = post("https://api.live.bilibili.com/xlive/web-room/v2/index/getRoomPlayInfo?room_id=" + room_id | ||
| + "&qn=" + accept_qn + "&codec=0,1,2&format=0,1,2&mask=0&no_playurl=0&platform=web&protocol=0,1"); | ||
| JsonValue temp; |
Comment on lines
+1735
to
+1742
| if (Reader.parse(quality_res, temp) && temp.isObject()) { | ||
| if (temp["code"].asInt() != 0) { | ||
| continue; | ||
| } | ||
| } | ||
| JsonValue temp_streams = temp["data"]["playurl_info"]["playurl"]["stream"]; | ||
| for (int ts = 0; ts < temp_streams.size(); ts++) { | ||
| string temp_protocol_name = temp_streams[ts]["protocol_name"].asString(); |
Comment on lines
+1777
to
+1779
| if ( best_qn == temp_codec["current_qn"].asInt() ) { | ||
| url = temp_codec["url_info"][0]["host"].asString() + temp_codec["base_url"].asString() + temp_codec["url_info"][0]["extra"].asString(); | ||
| } |
| qualityItemMain["url"] = temp_codec["url_info"][0]["host"].asString() + temp_codec["base_url"].asString() + temp_codec["url_info"][0]["extra"].asString(); | ||
| qualityItemMain["quality"] = getLiveQuality(temp_codec["current_qn"].asInt()) + codec_suffix; | ||
| qualityItemMain["qualityDetail"] = qualityItemMain["quality"]; | ||
| qualityItemMain["itag"] = getItag(temp_codec["current_qn"].asInt()) * 100 + codecOffset * 10; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
直播 - 新接口适应性支持:
目前的小问题:
画质选项中会出现HLS相关选项,貌似是potplayer特性。