Fix Invidious captions URL when companion is enabled

Prefix caption URLs with /companion when invidiousCompanion is enabled in instance settings. This ensures captions are routed through the companion service, matching the behavior of video streams.
This commit is contained in:
Arkadiusz Fal
2025-11-22 22:52:46 +01:00
parent 5f53e53c7a
commit 2e27dcd2cf

View File

@@ -858,7 +858,14 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
private func extractCaptions(from content: JSON) -> [Captions] {
content["captions"].arrayValue.compactMap { details in
guard let url = URL(string: details["url"].stringValue, relativeTo: account.url) else { return nil }
var urlString = details["url"].stringValue
// Prefix with /companion if enabled
if account.instance.invidiousCompanion {
urlString = "/companion" + urlString
}
guard let url = URL(string: urlString, relativeTo: account.url) else { return nil }
return Captions(
label: details["label"].stringValue,