Files
yattee/Yattee/Services/API/InstanceAPI.swift
Arkadiusz Fal 4770bbe3b9 Remove dead code found by Periphery on all platforms
Delete declarations that Periphery reports unused on every platform that
compiles them (iOS, macOS, tvOS), including nine views used only by their
own previews. Platform-gated code still used on another platform, device-
only MPV render paths, migration models, CloudKit record names, App
Intents metadata and unused parameters are kept.
2026-10-08 23:57:56 +02:00

66 lines
3.1 KiB
Swift

//
// InstanceAPI.swift
// Yattee
//
// Protocol defining the API interface that each backend must implement.
//
import Foundation
/// Protocol that each backend API (Invidious, Piped, PeerTube) must implement.
protocol InstanceAPI: Sendable {
func trending(instance: Instance) async throws -> [Video]
func popular(instance: Instance) async throws -> [Video]
func search(query: String, instance: Instance, page: Int, filters: SearchFilters) async throws -> SearchResult
func searchSuggestions(query: String, instance: Instance) async throws -> [String]
func video(id: String, instance: Instance) async throws -> Video
func channel(id: String, instance: Instance) async throws -> Channel
func channelVideos(id: String, instance: Instance, continuation: String?) async throws -> ChannelVideosPage
func channelPlaylists(id: String, instance: Instance, continuation: String?) async throws -> ChannelPlaylistsPage
func channelShorts(id: String, instance: Instance, continuation: String?) async throws -> ChannelVideosPage
func channelStreams(id: String, instance: Instance, continuation: String?) async throws -> ChannelVideosPage
func playlist(id: String, instance: Instance) async throws -> Playlist
func comments(videoID: String, instance: Instance, continuation: String?) async throws -> CommentsPage
func captions(videoID: String, instance: Instance) async throws -> [Caption]
func channelSearch(id: String, query: String, instance: Instance, page: Int) async throws -> ChannelSearchPage
}
// MARK: - Default Implementations
extension InstanceAPI {
/// Default implementation for backends that don't distinguish popular from trending.
func popular(instance: Instance) async throws -> [Video] {
try await trending(instance: instance)
}
/// Default implementation for backends that don't support search suggestions.
func searchSuggestions(query: String, instance: Instance) async throws -> [String] {
[]
}
/// Default implementation for backends that don't support captions.
func captions(videoID: String, instance: Instance) async throws -> [Caption] {
[]
}
/// Default implementation for backends that don't support channel playlists tab.
func channelPlaylists(id: String, instance: Instance, continuation: String?) async throws -> ChannelPlaylistsPage {
ChannelPlaylistsPage(playlists: [], continuation: nil)
}
/// Default implementation for backends that don't support channel shorts tab.
func channelShorts(id: String, instance: Instance, continuation: String?) async throws -> ChannelVideosPage {
ChannelVideosPage(videos: [], continuation: nil)
}
/// Default implementation for backends that don't support channel streams tab.
func channelStreams(id: String, instance: Instance, continuation: String?) async throws -> ChannelVideosPage {
ChannelVideosPage(videos: [], continuation: nil)
}
/// Default implementation for backends that don't support channel search.
func channelSearch(id: String, query: String, instance: Instance, page: Int) async throws -> ChannelSearchPage {
throw APIError.notSupported
}
}