feat: make sponsored blocks skippable

This commit is contained in:
2026-10-25 21:35:46 +01:00
parent 7052fe29af
commit a604810319
7 changed files with 170 additions and 43 deletions
@@ -9,6 +9,7 @@ public struct PlayerConfiguration: Equatable, Sendable {
public var showBufferInfo: Bool
public var automaticQuality: Bool
public var sponsorBlock: Bool
public var sponsorBlockAutoSkip: Bool
public var snapToEdges: Bool
public var compactTitleProgress: CompactTitleProgress
public var miruroVideoProvider: String
@@ -16,12 +17,13 @@ public struct PlayerConfiguration: Equatable, Sendable {
public var keys: KeyBindings
public init(showBufferInfo: Bool = false, automaticQuality: Bool = false, sponsorBlock: Bool = false,
snapToEdges: Bool = true,
sponsorBlockAutoSkip: Bool = false, snapToEdges: Bool = true,
compactTitleProgress: CompactTitleProgress = .time, miruroVideoProvider: String = "",
miruroCaptionProvider: String = "", keys: KeyBindings = KeyBindings()) {
self.showBufferInfo = showBufferInfo
self.automaticQuality = automaticQuality
self.sponsorBlock = sponsorBlock
self.sponsorBlockAutoSkip = sponsorBlockAutoSkip
self.snapToEdges = snapToEdges
self.compactTitleProgress = compactTitleProgress
self.miruroVideoProvider = miruroVideoProvider
@@ -37,6 +39,7 @@ public struct PlayerConfiguration: Equatable, Sendable {
"[playback]",
"automatic_quality = \(defaults.automaticQuality)",
"sponsorblock = \(defaults.sponsorBlock)",
"sponsorblock_autoskip = \(defaults.sponsorBlockAutoSkip)",
"", "[miruro]",
"video_provider = \"\(defaults.miruroVideoProvider)\"",
"caption_provider = \"\(defaults.miruroCaptionProvider)\"",
@@ -96,6 +99,7 @@ public struct PlayerConfiguration: Equatable, Sendable {
return Self(showBufferInfo: values.ui?.bufferInfo ?? false,
automaticQuality: values.playback?.automaticQuality ?? false,
sponsorBlock: values.playback?.sponsorBlock ?? false,
sponsorBlockAutoSkip: values.playback?.sponsorBlockAutoSkip ?? false,
snapToEdges: values.ui?.compactSnapToEdges ?? true,
compactTitleProgress: values.ui?.compactTitleProgress ?? .time,
miruroVideoProvider: values.miruro?.videoProvider ?? "",
@@ -181,11 +185,13 @@ public struct PlayerConfiguration: Equatable, Sendable {
private struct PlaybackConfiguration {
let automaticQuality: Bool?
let sponsorBlock: Bool?
let sponsorBlockAutoSkip: Bool?
init(container: KeyedDecodingContainer<SettingKey>) throws {
try validate(container, allowed: ["automatic_quality", "sponsorblock"])
try validate(container, allowed: ["automatic_quality", "sponsorblock", "sponsorblock_autoskip"])
automaticQuality = try container.decodeIfPresent(Bool.self, forKey: SettingKey("automatic_quality"))
sponsorBlock = try container.decodeIfPresent(Bool.self, forKey: SettingKey("sponsorblock"))
sponsorBlockAutoSkip = try container.decodeIfPresent(Bool.self, forKey: SettingKey("sponsorblock_autoskip"))
}
}