mirror of
https://github.com/yattee/yattee.git
synced 2025-08-06 18:54:11 +00:00
CC support with Invidious and MPV
This commit is contained in:
@@ -428,7 +428,8 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
|
||||
keywords: json["keywords"].arrayValue.compactMap { $0.string },
|
||||
streams: extractStreams(from: json),
|
||||
related: extractRelated(from: json),
|
||||
chapters: extractChapters(from: description)
|
||||
chapters: extractChapters(from: description),
|
||||
captions: extractCaptions(from: json)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -566,4 +567,17 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
|
||||
channel: Channel(id: channelId, name: author)
|
||||
)
|
||||
}
|
||||
|
||||
private func extractCaptions(from content: JSON) -> [Captions] {
|
||||
content["captions"].arrayValue.compactMap { details in
|
||||
guard let baseURL = account.url,
|
||||
let url = URL(string: baseURL + details["url"].stringValue) else { return nil }
|
||||
|
||||
return Captions(
|
||||
label: details["label"].stringValue,
|
||||
code: details["language_code"].stringValue,
|
||||
url: url
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user