mirror of
https://github.com/yattee/yattee.git
synced 2025-10-14 11:28:13 +00:00
Initial PeerTube Support
This commit is contained in:
@@ -14,7 +14,7 @@ extension Watch {
|
||||
NSFetchRequest<Watch>(entityName: "Watch")
|
||||
}
|
||||
|
||||
@nonobjc class func markAsWatched(videoID: String, duration: Double, context: NSManagedObjectContext) {
|
||||
@nonobjc class func markAsWatched(videoID: String, account: Account, duration: Double, context: NSManagedObjectContext) {
|
||||
let watchFetchRequest = Watch.fetchRequest()
|
||||
watchFetchRequest.predicate = NSPredicate(format: "videoID = %@", videoID as String)
|
||||
|
||||
@@ -26,6 +26,8 @@ extension Watch {
|
||||
if results?.isEmpty ?? true {
|
||||
watch = Watch(context: context)
|
||||
watch?.videoID = videoID
|
||||
watch?.appName = account.app?.rawValue
|
||||
watch?.instanceURL = account.url
|
||||
} else {
|
||||
watch = results?.first
|
||||
}
|
||||
@@ -46,6 +48,14 @@ extension Watch {
|
||||
@NSManaged var watchedAt: Date?
|
||||
@NSManaged var stoppedAt: Double
|
||||
|
||||
@NSManaged var appName: String?
|
||||
@NSManaged var instanceURL: URL?
|
||||
|
||||
var app: VideosApp! {
|
||||
guard let appName else { return nil }
|
||||
return .init(rawValue: appName)
|
||||
}
|
||||
|
||||
var progress: Double {
|
||||
guard videoDuration.isFinite, !videoDuration.isZero else {
|
||||
return 0
|
||||
@@ -83,6 +93,6 @@ extension Watch {
|
||||
return .local(url)
|
||||
}
|
||||
|
||||
return Video(videoID: videoID)
|
||||
return Video(app: app, instanceURL: instanceURL, videoID: videoID)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user