Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Model/Applications/InvidiousAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,12 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
func channelPlaylist(_ id: String) -> Resource? {
resource(baseURL: account.url, path: basePathAppending("playlists/\(id)"))
}

func markWatched(_ videoID: String, onCompletion: @escaping () -> Void = {}) {
resourceWithAuthCheck(baseURL: account.url, path: basePathAppending("auth/history"))
.child(videoID)
.request(.post)
.onCompletion { _ in onCompletion() }
}
func search(_ query: SearchQuery, page: String?) -> Resource {
var resource = resource(baseURL: account.url, path: basePathAppending("search"))
.withParam("q", searchQuery(query.query))
Expand Down
10 changes: 9 additions & 1 deletion Model/HistoryModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,15 @@ extension PlayerModel {
}

watch.watchedAt = Date()

if finished || (watchWasNew && seconds >= 3) {
// Ensure this is an Invidious video
if currentVideo.app == .invidious, let vid = currentVideo.videoID {
// Get the correct API instance for this video's origin
if let api = playerAPI(currentVideo) as? InvidiousAPI {
api.markWatched(vid)
}
}
}
try? self.backgroundContext.save()
}
}
Expand Down