yattee/Model/Applications/VideosApp.swift
Toni Förster 6eba2a45c8
Conditional proxying
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled.

This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content.

Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users.

This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
2024-05-16 19:35:31 +02:00

105 lines
1.9 KiB
Swift

import Foundation
enum VideosApp: String, CaseIterable {
enum AppType: String {
case local
case youTube
case peerTube
}
case local
case invidious
case piped
case peerTube
var name: String {
switch self {
case .peerTube:
return "PeerTube"
default:
return rawValue.capitalized
}
}
var appType: AppType {
switch self {
case .local:
return .local
case .invidious:
return .youTube
case .piped:
return .youTube
case .peerTube:
return .peerTube
}
}
var supportsAccounts: Bool {
self != .local
}
var supportsPopular: Bool {
self == .invidious
}
var supportsSearchFilters: Bool {
self == .invidious
}
var supportsSearchSuggestions: Bool {
self != .peerTube
}
var supportsSubscriptions: Bool {
supportsAccounts
}
var paginatesSubscriptions: Bool {
self == .invidious
}
var supportsTrendingCategories: Bool {
self == .invidious
}
var supportsUserPlaylists: Bool {
self != .local
}
var userPlaylistsEndpointIncludesVideos: Bool {
self == .invidious
}
var userPlaylistsUseChannelPlaylistEndpoint: Bool {
self == .piped
}
var userPlaylistsHaveVisibility: Bool {
self == .invidious
}
var userPlaylistsAreEditable: Bool {
self == .invidious
}
var hasFrontendURL: Bool {
self == .piped
}
var searchUsesIndexedPages: Bool {
self == .invidious
}
var supportsOpeningChannelsByName: Bool {
self == .piped
}
var allowsDisablingVidoesProxying: Bool {
self == .invidious || self == .piped
}
var supportsOpeningVideosByID: Bool {
self != .local
}
}