80 lines
3 KiB
Swift
80 lines
3 KiB
Swift
//
|
|
// JellyfinUserData.swift
|
|
//
|
|
// Copyright 2026 Brendan Szymanski <hello@bscubed.dev>
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
//
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
//
|
|
|
|
import Foundation
|
|
|
|
/// One user's playback and favourite state for a single item.
|
|
///
|
|
/// Attached to a ``JellyfinMediaItem`` when the request enabled user data, and returned on its own
|
|
/// by the played and favourite mutations so a caller can refresh a row without refetching the item.
|
|
package struct JellyfinUserData: Hashable, Sendable {
|
|
/// The item this state belongs to.
|
|
package var itemID: String?
|
|
/// The server-side key that groups state for repeated items.
|
|
package var key: String?
|
|
/// The user's personal rating.
|
|
package var rating: Double?
|
|
/// How far through the item the user is, as a percentage.
|
|
package var playedPercentage: Double?
|
|
/// How many descendants of a folder or season remain unplayed.
|
|
package var unplayedItemCount: Int32?
|
|
/// The resume position, in 100-nanosecond ticks.
|
|
package var playbackPositionTicks: Int64?
|
|
/// How many times the user has played the item.
|
|
package var playCount: Int32?
|
|
/// Whether the user marked the item as a favourite.
|
|
package var isFavorite: Bool?
|
|
/// Whether the user gave the item a thumbs up or down.
|
|
package var likes: Bool?
|
|
/// When the user last played the item.
|
|
package var lastPlayedDate: Date?
|
|
/// Whether the item counts as watched.
|
|
package var played: Bool?
|
|
|
|
/// Creates user data, defaulting every unspecified field to `nil`.
|
|
///
|
|
/// Each parameter sets the property of the same name.
|
|
package init(
|
|
itemID: String? = nil,
|
|
key: String? = nil,
|
|
rating: Double? = nil,
|
|
playedPercentage: Double? = nil,
|
|
unplayedItemCount: Int32? = nil,
|
|
playbackPositionTicks: Int64? = nil,
|
|
playCount: Int32? = nil,
|
|
isFavorite: Bool? = nil,
|
|
likes: Bool? = nil,
|
|
lastPlayedDate: Date? = nil,
|
|
played: Bool? = nil
|
|
) {
|
|
self.itemID = itemID
|
|
self.key = key
|
|
self.rating = rating
|
|
self.playedPercentage = playedPercentage
|
|
self.unplayedItemCount = unplayedItemCount
|
|
self.playbackPositionTicks = playbackPositionTicks
|
|
self.playCount = playCount
|
|
self.isFavorite = isFavorite
|
|
self.likes = likes
|
|
self.lastPlayedDate = lastPlayedDate
|
|
self.played = played
|
|
}
|
|
}
|