Skip to content

Commit

Permalink
修正字幕解析失败(疑似被风控导致返回随机字幕)
Browse files Browse the repository at this point in the history
  • Loading branch information
yichengchen committed Dec 1, 2024
1 parent bcac706 commit 559a972
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ class BilibiliVideoResourceLoaderDelegate: NSObject, AVAssetResourceLoaderDelega
httpPort = (try? httpServer.port()) ?? 0
}
for subtitle in subtitles {
addSubtitleData(lang: subtitle.lan, name: subtitle.lan_doc, duration: info.dash.duration, url: subtitle.url.absoluteString)
if let url = subtitle.url {
addSubtitleData(lang: subtitle.lan, name: subtitle.lan_doc, duration: info.dash.duration, url: url.absoluteString)
}
}

// i-frame
Expand Down
10 changes: 8 additions & 2 deletions BilibiliLive/Request/WebRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -691,10 +691,16 @@ struct SubtitleResp: Codable {

struct SubtitleData: Codable, Hashable {
let lan_doc: String
let subtitle_url: URL
let subtitle_url: String?
let lan: String

var url: URL { subtitle_url.addSchemeIfNeed() }
var url: URL? {
if let subtitle_url, let sub_url = URL(string: subtitle_url) {
return sub_url.addSchemeIfNeed()
}
return nil
}

var subtitleContents: [SubtitleContent]?
}

Expand Down

0 comments on commit 559a972

Please sign in to comment.