Mirror a watch into the account it was watched under

This commit is contained in:
Arkadiusz Fal
2026-09-06 11:06:15 +02:00
parent 3dc129dcfa
commit 7bcc711c40
9 changed files with 1044 additions and 4 deletions

View File

@@ -494,6 +494,59 @@ actor ContentService: ContentServiceProtocol {
}
}
// MARK: - Watch History
/// One page of the credential owner's server-side watch history.
///
/// Invidious is the only backend with a history endpoint at all; the
/// capability gate above this refuses the others long before here.
func watchHistory(
instance: Instance,
credential: String,
page: Int,
maxResults: Int
) async throws -> [String] {
switch instance.type {
case .invidious:
return try await invidiousAPI(for: instance).watchHistory(
instance: instance,
sid: credential,
page: page,
maxResults: maxResults
)
default:
throw APIError.notSupported
}
}
/// Records a video as watched in the credential owner's history.
func markWatched(videoID: String, instance: Instance, credential: String) async throws {
switch instance.type {
case .invidious:
try await invidiousAPI(for: instance).markWatched(
videoID: videoID,
instance: instance,
sid: credential
)
default:
throw APIError.notSupported
}
}
/// Removes one video from the credential owner's history.
func removeWatched(videoID: String, instance: Instance, credential: String) async throws {
switch instance.type {
case .invidious:
try await invidiousAPI(for: instance).removeWatched(
videoID: videoID,
instance: instance,
sid: credential
)
default:
throw APIError.notSupported
}
}
// MARK: - Authentication
/// Signs in to an instance and returns the credential its backend issues —
@@ -658,6 +711,8 @@ actor ContentService: ContentServiceProtocol {
/// that satisfy it; the protocol exists so tests can script a server.
extension ContentService: RemotePlaylistTransport {}
extension ContentService: WatchHistoryTransport {}
// MARK: - Feed Page
/// One page of an authenticated feed, with whatever the backend says about