Add experimental setting to hide videos without duration in Invidious

This adds a new instance setting for Invidious that filters out videos
without duration information from feeds, popular, trending, search results,
and channel pages. This can be used to hide YouTube Shorts.

The setting is labeled as "Experimental: Hide videos without duration" and
includes an explanation that it can be used to hide shorts.

Key changes:
- Added hideVideosWithoutDuration property to Instance model
- Updated InstancesBridge to serialize/deserialize the new setting
- Added UI toggle in InstanceSettings with explanatory footer text
- Implemented filtering in InvidiousAPI for:
  * Popular videos
  * Trending videos
  * Search results
  * Subscription feed
  * Channel content
- Videos accessed directly by URL are not filtered
This commit is contained in:
Arkadiusz Fal
2025-11-22 19:42:18 +01:00
parent 735e7d62b6
commit b0dfd2f9d2
6 changed files with 51 additions and 12 deletions

View File

@@ -9,6 +9,7 @@ struct InstanceSettings: View {
@State private var frontendURL = ""
@State private var proxiesVideos = false
@State private var invidiousCompanion = false
@State private var hideVideosWithoutDuration = false
var body: some View {
List {
@@ -97,6 +98,16 @@ struct InstanceSettings: View {
.onChange(of: invidiousCompanion) { newValue in
InstancesModel.shared.setInvidiousCompanion(instance, newValue)
}
Section(footer: Text("This can be used to hide shorts".localized())) {
hideVideosWithoutDurationToggle
.onAppear {
hideVideosWithoutDuration = instance.hideVideosWithoutDuration
}
.onChange(of: hideVideosWithoutDuration) { newValue in
InstancesModel.shared.setHideVideosWithoutDuration(instance, newValue)
}
}
}
}
#if os(tvOS)
@@ -116,6 +127,10 @@ struct InstanceSettings: View {
Toggle("Invidious companion", isOn: $invidiousCompanion)
}
private var hideVideosWithoutDurationToggle: some View {
Toggle("Experimental: Hide videos without duration", isOn: $hideVideosWithoutDuration)
}
private func removeAccount(_ account: Account) {
AccountsModel.remove(account)
accountsChanged.toggle()