feat: support YouTube VTT subtitle selection
This commit is contained in:
@@ -68,7 +68,8 @@ struct AutomaticQualityPlaybackChecks {
|
||||
until(model, "compact mode remains usable across empty playback polls while resolving") {
|
||||
model.isCompact && !model.compactWindow.isTransitioning
|
||||
}
|
||||
require(window.level == .floating && window.frame.width < normalFrame.width,
|
||||
require(model.compactWindow.presentationWindow!.level == .floating &&
|
||||
model.compactWindow.presentationWindow!.frame.width < normalFrame.width,
|
||||
"unresolved video has a usable compact window")
|
||||
model.handleKey(compactKey)
|
||||
until(model, "compact shortcut restores while YouTube resolution is still pending") {
|
||||
@@ -86,7 +87,8 @@ struct AutomaticQualityPlaybackChecks {
|
||||
require(model.isCompact, "loading completion preserves the requested compact mode")
|
||||
until(model, "decoded metadata updates compact geometry") {
|
||||
!model.compactWindow.isTransitioning &&
|
||||
abs(window.frame.width / window.frame.height - model.state.video_aspect_ratio) < 0.01
|
||||
abs(model.compactWindow.presentationWindow!.frame.width / model.compactWindow.presentationWindow!.frame.height -
|
||||
model.state.video_aspect_ratio) < 0.01
|
||||
}
|
||||
model.handleKey(compactKey)
|
||||
until(model, "compact shortcut restores during network buffering") {
|
||||
@@ -100,6 +102,12 @@ struct AutomaticQualityPlaybackChecks {
|
||||
polled(model)
|
||||
require(model.youtubeHeight == 1080 && !model.resolvingStream,
|
||||
"disabled automatic quality leaves a stalled manual/default stream alone")
|
||||
let captionCountURL = URL(string: ProcessInfo.processInfo.environment["TEREBI_CAPTION_COUNT"]!)!
|
||||
require(try! String(contentsOf: captionCountURL, encoding: .utf8) == "0",
|
||||
"Off never requests captions during extraction or playback")
|
||||
require(model.selectedSubtitle == nil && model.subtitleTracks.count == 1, "YouTube captions default Off")
|
||||
model.selectSubtitle(0)
|
||||
until(model, "selected original-auto VTT loads through native HTTP") { model.subtitleText == "Automatic caption" }
|
||||
model.setAutomaticYouTubeQuality(true)
|
||||
polled(model)
|
||||
let position = model.state.position
|
||||
@@ -110,11 +118,16 @@ struct AutomaticQualityPlaybackChecks {
|
||||
}
|
||||
require(model.state.position >= position,
|
||||
"automatic quality reopening does not reset acknowledged progress")
|
||||
until(model, "automatic downshift restores the selected caption") { model.subtitleText == "Automatic caption" }
|
||||
require(model.selectedSubtitle == 0, "automatic downshift retains caption identity")
|
||||
polled(model)
|
||||
clock.now = 2063
|
||||
until(model, "sustained health automatically restores actual 1080p media") {
|
||||
model.youtubeHeight == 1080 && model.canTogglePlayback && model.state.status == PLAYER_PLAYING && !model.state.seek_pending
|
||||
}
|
||||
until(model, "automatic upshift restores the selected caption") { model.subtitleText == "Automatic caption" }
|
||||
require(model.selectedSubtitle == 0, "automatic upshift retains caption identity")
|
||||
model.selectSubtitle(nil)
|
||||
model.setYouTubeQuality(model.youtubeHeight)
|
||||
require(!model.automaticYouTubeQuality && !model.isBusy && model.state.status == PLAYER_PLAYING,
|
||||
"reselecting the current manual resolution disables auto without disrupting playback")
|
||||
@@ -134,6 +147,7 @@ struct AutomaticQualityPlaybackChecks {
|
||||
model.youtubeHeight == 720 && model.canChangeYouTubeQuality && model.state.status == PLAYER_PLAYING &&
|
||||
!model.state.seek_pending && (model.bufferedRange.map { $0.upperBound - model.state.position >= 20 } ?? false)
|
||||
}
|
||||
require(model.selectedSubtitle == nil && model.subtitleText.isEmpty, "manual changes preserve Off after automatic changes")
|
||||
let selectedTitle = model.fileName
|
||||
let selectedQuality = model.youtubeQuality
|
||||
mark("gate-1080")
|
||||
|
||||
Reference in New Issue
Block a user