From 559a972f4f4e1caff1d2e543b3c7d9b4e6d55537 Mon Sep 17 00:00:00 2001 From: yicheng <11733500+yichengchen@users.noreply.github.com> Date: Sun, 1 Dec 2024 11:21:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=AD=97=E5=B9=95=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E5=A4=B1=E8=B4=A5=EF=BC=88=E7=96=91=E4=BC=BC=E8=A2=AB?= =?UTF-8?q?=E9=A3=8E=E6=8E=A7=E5=AF=BC=E8=87=B4=E8=BF=94=E5=9B=9E=E9=9A=8F?= =?UTF-8?q?=E6=9C=BA=E5=AD=97=E5=B9=95=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Player/BilibiliVideoResourceLoaderDelegate.swift | 4 +++- BilibiliLive/Request/WebRequest.swift | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/BilibiliLive/Component/Player/BilibiliVideoResourceLoaderDelegate.swift b/BilibiliLive/Component/Player/BilibiliVideoResourceLoaderDelegate.swift index 85b90366..debe39d4 100644 --- a/BilibiliLive/Component/Player/BilibiliVideoResourceLoaderDelegate.swift +++ b/BilibiliLive/Component/Player/BilibiliVideoResourceLoaderDelegate.swift @@ -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 diff --git a/BilibiliLive/Request/WebRequest.swift b/BilibiliLive/Request/WebRequest.swift index 67956ac8..b4be79ed 100644 --- a/BilibiliLive/Request/WebRequest.swift +++ b/BilibiliLive/Request/WebRequest.swift @@ -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]? }