From 511a528eb6875bf273e7b66f80b4f964c1b5c9bd Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sat, 6 Jul 2024 12:32:31 +0200 Subject: [PATCH] Add import export of missing settings --- .../AdvancedSettingsGroupExporter.swift | 4 +++ .../HistorySettingsGroupExporter.swift | 9 +++--- .../PlayerSettingsGroupExporter.swift | 9 +++++- .../SponsorBlockSettingsGroupExporter.swift | 6 +++- .../AdvancedSettingsGroupImporter.swift | 16 +++++++++++ .../HistorySettingsGroupImporter.swift | 24 ++++++++-------- .../PlayerSettingsGroupImporter.swift | 28 +++++++++++++++++++ .../SponsorBlockSettingsGroupImporter.swift | 17 +++++++++++ Shared/Defaults.swift | 12 ++++---- 9 files changed, 100 insertions(+), 25 deletions(-) diff --git a/Model/Import Export Settings/Exporters/AdvancedSettingsGroupExporter.swift b/Model/Import Export Settings/Exporters/AdvancedSettingsGroupExporter.swift index 8c2e82a4..9aa5145b 100644 --- a/Model/Import Export Settings/Exporters/AdvancedSettingsGroupExporter.swift +++ b/Model/Import Export Settings/Exporters/AdvancedSettingsGroupExporter.swift @@ -9,7 +9,11 @@ final class AdvancedSettingsGroupExporter: SettingsGroupExporter { "mpvEnableLogging": Defaults[.mpvEnableLogging], "mpvCacheSecs": Defaults[.mpvCacheSecs], "mpvCachePauseWait": Defaults[.mpvCachePauseWait], + "mpvCachePauseInital": Defaults[.mpvCachePauseInital], "mpvDeinterlace": Defaults[.mpvDeinterlace], + "mpvHWdec": Defaults[.mpvHWdec], + "mpvDemuxerLavfProbeInfo": Defaults[.mpvDemuxerLavfProbeInfo], + "mpvInitialAudioSync": Defaults[.mpvInitialAudioSync], "showCacheStatus": Defaults[.showCacheStatus], "feedCacheSize": Defaults[.feedCacheSize] ] diff --git a/Model/Import Export Settings/Exporters/HistorySettingsGroupExporter.swift b/Model/Import Export Settings/Exporters/HistorySettingsGroupExporter.swift index 9f340d48..67d560d2 100644 --- a/Model/Import Export Settings/Exporters/HistorySettingsGroupExporter.swift +++ b/Model/Import Export Settings/Exporters/HistorySettingsGroupExporter.swift @@ -6,6 +6,9 @@ final class HistorySettingsGroupExporter: SettingsGroupExporter { [ "saveRecents": Defaults[.saveRecents], "saveHistory": Defaults[.saveHistory], + "showRecents": Defaults[.showRecents], + "limitRecents": Defaults[.limitRecents], + "limitRecentsAmount": Defaults[.limitRecentsAmount], "showWatchingProgress": Defaults[.showWatchingProgress], "saveLastPlayed": Defaults[.saveLastPlayed], @@ -15,11 +18,7 @@ final class HistorySettingsGroupExporter: SettingsGroupExporter { "watchedVideoStyle": Defaults[.watchedVideoStyle].rawValue, "watchedVideoBadgeColor": Defaults[.watchedVideoBadgeColor].rawValue, - "showToggleWatchedStatusButton": Defaults[.showToggleWatchedStatusButton], - - "showRecents": Defaults[.showRecents], - "limitRecents": Defaults[.limitRecents], - "limitRecentsAmount": Defaults[.limitRecentsAmount] + "showToggleWatchedStatusButton": Defaults[.showToggleWatchedStatusButton] ] } } diff --git a/Model/Import Export Settings/Exporters/PlayerSettingsGroupExporter.swift b/Model/Import Export Settings/Exporters/PlayerSettingsGroupExporter.swift index a70e93da..8c2abf95 100644 --- a/Model/Import Export Settings/Exporters/PlayerSettingsGroupExporter.swift +++ b/Model/Import Export Settings/Exporters/PlayerSettingsGroupExporter.swift @@ -10,6 +10,8 @@ final class PlayerSettingsGroupExporter: SettingsGroupExporter { "expandVideoDescription": Defaults[.expandVideoDescription], "collapsedLinesDescription": Defaults[.collapsedLinesDescription], "showChapters": Defaults[.showChapters], + "showChapterThumbnails": Defaults[.showChapterThumbnails], + "showChapterThumbnailsOnlyWhenDifferent": Defaults[.showChapterThumbnailsOnlyWhenDifferent], "expandChapters": Defaults[.expandChapters], "showRelated": Defaults[.showRelated], "showInspector": Defaults[.showInspector].rawValue, @@ -18,7 +20,12 @@ final class PlayerSettingsGroupExporter: SettingsGroupExporter { "enableReturnYouTubeDislike": Defaults[.enableReturnYouTubeDislike], "closePiPOnNavigation": Defaults[.closePiPOnNavigation], "closePiPOnOpeningPlayer": Defaults[.closePiPOnOpeningPlayer], - "closePlayerOnOpeningPiP": Defaults[.closePlayerOnOpeningPiP] + "closePlayerOnOpeningPiP": Defaults[.closePlayerOnOpeningPiP], + "captionsAutoShow": Defaults[.captionsAutoShow], + "captionsDefaultLanguageCode": Defaults[.captionsDefaultLanguageCode], + "captionsFallbackLanguageCode": Defaults[.captionsFallbackLanguageCode], + "captionsFontScaleSize": Defaults[.captionsFontScaleSize], + "captionsFontColor": Defaults[.captionsFontColor] ] } diff --git a/Model/Import Export Settings/Exporters/SponsorBlockSettingsGroupExporter.swift b/Model/Import Export Settings/Exporters/SponsorBlockSettingsGroupExporter.swift index e2f9d3bd..87872d04 100644 --- a/Model/Import Export Settings/Exporters/SponsorBlockSettingsGroupExporter.swift +++ b/Model/Import Export Settings/Exporters/SponsorBlockSettingsGroupExporter.swift @@ -5,7 +5,11 @@ final class SponsorBlockSettingsGroupExporter: SettingsGroupExporter { override var globalJSON: JSON { [ "sponsorBlockInstance": Defaults[.sponsorBlockInstance], - "sponsorBlockCategories": Array(Defaults[.sponsorBlockCategories]) + "sponsorBlockCategories": Array(Defaults[.sponsorBlockCategories]), + "sponsorBlockColors": Defaults[.sponsorBlockColors], + "sponsorBlockShowTimeWithSkipsRemoved": Defaults[.sponsorBlockShowTimeWithSkipsRemoved], + "sponsorBlockShowCategoriesInTimeline": Defaults[.sponsorBlockShowCategoriesInTimeline], + "sponsorBlockShowNoticeAfterSkip": Defaults[.sponsorBlockShowNoticeAfterSkip] ] } } diff --git a/Model/Import Export Settings/Importers/AdvancedSettingsGroupImporter.swift b/Model/Import Export Settings/Importers/AdvancedSettingsGroupImporter.swift index 3578f8d8..5c2b2113 100644 --- a/Model/Import Export Settings/Importers/AdvancedSettingsGroupImporter.swift +++ b/Model/Import Export Settings/Importers/AdvancedSettingsGroupImporter.swift @@ -25,10 +25,26 @@ struct AdvancedSettingsGroupImporter { Defaults[.mpvCachePauseWait] = mpvCachePauseWait } + if let mpvCachePauseInital = json["mpvCachePauseInital"].bool { + Defaults[.mpvCachePauseInital] = mpvCachePauseInital + } + if let mpvDeinterlace = json["mpvDeinterlace"].bool { Defaults[.mpvDeinterlace] = mpvDeinterlace } + if let mpvHWdec = json["mpvHWdec"].string { + Defaults[.mpvHWdec] = mpvHWdec + } + + if let mpvDemuxerLavfProbeInfo = json["mpvDemuxerLavfProbeInfo"].string { + Defaults[.mpvDemuxerLavfProbeInfo] = mpvDemuxerLavfProbeInfo + } + + if let mpvInitialAudioSync = json["mpvInitialAudioSync"].bool { + Defaults[.mpvInitialAudioSync] = mpvInitialAudioSync + } + if let showCacheStatus = json["showCacheStatus"].bool { Defaults[.showCacheStatus] = showCacheStatus } diff --git a/Model/Import Export Settings/Importers/HistorySettingsGroupImporter.swift b/Model/Import Export Settings/Importers/HistorySettingsGroupImporter.swift index 2fa9e19a..849be1d4 100644 --- a/Model/Import Export Settings/Importers/HistorySettingsGroupImporter.swift +++ b/Model/Import Export Settings/Importers/HistorySettingsGroupImporter.swift @@ -13,6 +13,18 @@ struct HistorySettingsGroupImporter { Defaults[.saveHistory] = saveHistory } + if let showRecents = json["showRecents"].bool { + Defaults[.showRecents] = showRecents + } + + if let limitRecents = json["limitRecents"].bool { + Defaults[.limitRecents] = limitRecents + } + + if let limitRecentsAmount = json["limitRecentsAmount"].int { + Defaults[.limitRecentsAmount] = limitRecentsAmount + } + if let showWatchingProgress = json["showWatchingProgress"].bool { Defaults[.showWatchingProgress] = showWatchingProgress } @@ -50,17 +62,5 @@ struct HistorySettingsGroupImporter { if let showToggleWatchedStatusButton = json["showToggleWatchedStatusButton"].bool { Defaults[.showToggleWatchedStatusButton] = showToggleWatchedStatusButton } - - if let showRecents = json["showRecents"].bool { - Defaults[.showRecents] = showRecents - } - - if let limitRecents = json["limitRecents"].bool { - Defaults[.limitRecents] = limitRecents - } - - if let limitRecentsAmount = json["limitRecentsAmount"].int { - Defaults[.limitRecentsAmount] = limitRecentsAmount - } } } diff --git a/Model/Import Export Settings/Importers/PlayerSettingsGroupImporter.swift b/Model/Import Export Settings/Importers/PlayerSettingsGroupImporter.swift index df556438..3f9375fe 100644 --- a/Model/Import Export Settings/Importers/PlayerSettingsGroupImporter.swift +++ b/Model/Import Export Settings/Importers/PlayerSettingsGroupImporter.swift @@ -29,6 +29,14 @@ struct PlayerSettingsGroupImporter { Defaults[.showChapters] = showChapters } + if let showChapterThumbnails = json["showChapterThumbnails"].bool { + Defaults[.showChapterThumbnails] = showChapterThumbnails + } + + if let showChapterThumbnailsOnlyWhenDifferent = json["showChapterThumbnailsOnlyWhenDifferent"].bool { + Defaults[.showChapterThumbnailsOnlyWhenDifferent] = showChapterThumbnailsOnlyWhenDifferent + } + if let expandChapters = json["expandChapters"].bool { Defaults[.expandChapters] = expandChapters } @@ -96,5 +104,25 @@ struct PlayerSettingsGroupImporter { Defaults[.rotateToLandscapeOnEnterFullScreen] = rotateToLandscapeOnEnterFullScreen } #endif + + if let captionsAutoShow = json["captionsAutoShow"].bool { + Defaults[.captionsAutoShow] = captionsAutoShow + } + + if let captionsDefaultLanguageCode = json["captionsDefaultLanguageCode"].string { + Defaults[.captionsDefaultLanguageCode] = captionsDefaultLanguageCode + } + + if let captionsFallbackLanguageCode = json["captionsFallbackLanguageCode"].string { + Defaults[.captionsFallbackLanguageCode] = captionsFallbackLanguageCode + } + + if let captionsFontScaleSize = json["captionsFontScaleSize"].string { + Defaults[.captionsFontScaleSize] = captionsFontScaleSize + } + + if let captionsFontColor = json["captionsFontColor"].string { + Defaults[.captionsFontColor] = captionsFontColor + } } } diff --git a/Model/Import Export Settings/Importers/SponsorBlockSettingsGroupImporter.swift b/Model/Import Export Settings/Importers/SponsorBlockSettingsGroupImporter.swift index ea9da9c1..98e09b34 100644 --- a/Model/Import Export Settings/Importers/SponsorBlockSettingsGroupImporter.swift +++ b/Model/Import Export Settings/Importers/SponsorBlockSettingsGroupImporter.swift @@ -12,5 +12,22 @@ struct SponsorBlockSettingsGroupImporter { if let sponsorBlockCategories = json["sponsorBlockCategories"].array { Defaults[.sponsorBlockCategories] = Set(sponsorBlockCategories.compactMap { $0.string }) } + + if let sponsorBlockColors = json["sponsorBlockColors"].dictionary { + let colors = sponsorBlockColors.mapValues { json in json.stringValue } + Defaults[.sponsorBlockColors] = colors + } + + if let sponsorBlockShowTimeWithSkipsRemoved = json["sponsorBlockShowTimeWithSkipsRemoved"].bool { + Defaults[.sponsorBlockShowTimeWithSkipsRemoved] = sponsorBlockShowTimeWithSkipsRemoved + } + + if let sponsorBlockShowCategoriesInTimeline = json["sponsorBlockShowCategoriesInTimeline"].bool { + Defaults[.sponsorBlockShowCategoriesInTimeline] = sponsorBlockShowCategoriesInTimeline + } + + if let sponsorBlockShowNoticeAfterSkip = json["sponsorBlockShowNoticeAfterSkip"].bool { + Defaults[.sponsorBlockShowNoticeAfterSkip] = sponsorBlockShowNoticeAfterSkip + } } } diff --git a/Shared/Defaults.swift b/Shared/Defaults.swift index 6b9b7a18..f7b7415f 100644 --- a/Shared/Defaults.swift +++ b/Shared/Defaults.swift @@ -106,6 +106,12 @@ extension Defaults.Keys { static let closePiPAndOpenPlayerOnEnteringForeground = Key("closePiPAndOpenPlayerOnEnteringForeground", default: false) #endif + static let captionsAutoShow = Key("captionsAutoShow", default: false) + static let captionsDefaultLanguageCode = Key("captionsDefaultLanguageCode", default: LanguageCodes.English.rawValue) + static let captionsFallbackLanguageCode = Key("captionsDefaultFallbackCode", default: LanguageCodes.English.rawValue) + static let captionsFontScaleSize = Key("captionsFontScale", default: "1.0") + static let captionsFontColor = Key("captionsFontColor", default: "#FFFFFF") + // MARK: GROUP - Controls static let avPlayerUsesSystemControls = Key("avPlayerUsesSystemControls", default: true) @@ -304,13 +310,7 @@ extension Defaults.Keys { static let lastPlayed = Key("lastPlayed") static let activeBackend = Key("activeBackend", default: .mpv) - static let captionsAutoShow = Key("captionsAutoShow", default: false) static let captionsLanguageCode = Key("captionsLanguageCode") - static let captionsDefaultLanguageCode = Key("captionsDefaultLanguageCode", default: LanguageCodes.English.rawValue) - static let captionsFallbackLanguageCode = Key("captionsDefaultFallbackCode", default: LanguageCodes.English.rawValue) - static let captionsFontScaleSize = Key("captionsFontScale", default: "1.0") - static let captionsFontColor = Key("captionsFontColor", default: "#FFFFFF") - static let lastUsedPlaylistID = Key("lastPlaylistID") static let lastAccountIsPublic = Key("lastAccountIsPublic", default: false)