mirror of
https://github.com/yattee/yattee.git
synced 2026-10-23 13:12:53 +00:00
Add a Hide Shorts toggle to the view options
Videos carry isShort from Yattee Server and Piped, and Invidious feed entries are taken as Shorts when they arrive with no length and aren't live or upcoming: the feed comes from RSS, which lists Shorts, while lengths come from the Videos tab, which doesn't. Subscriptions, search and instance browse hide videos known to be Shorts when the toggle is on; videos whose source can't tell are always shown.
This commit is contained in:
@@ -51,6 +51,9 @@ struct Video: Identifiable, Codable, Sendable {
|
||||
/// Related/recommended videos (populated from video details API).
|
||||
let relatedVideos: [Video]?
|
||||
|
||||
/// Whether this is a YouTube Short: `nil` when the source can't tell.
|
||||
let isShort: Bool?
|
||||
|
||||
// MARK: - Explicit Initializer
|
||||
|
||||
init(
|
||||
@@ -67,7 +70,8 @@ struct Video: Identifiable, Codable, Sendable {
|
||||
isLive: Bool,
|
||||
isUpcoming: Bool,
|
||||
scheduledStartTime: Date?,
|
||||
relatedVideos: [Video]? = nil
|
||||
relatedVideos: [Video]? = nil,
|
||||
isShort: Bool? = nil
|
||||
) {
|
||||
self.id = id
|
||||
self.title = title
|
||||
@@ -83,6 +87,7 @@ struct Video: Identifiable, Codable, Sendable {
|
||||
self.isUpcoming = isUpcoming
|
||||
self.scheduledStartTime = scheduledStartTime
|
||||
self.relatedVideos = relatedVideos
|
||||
self.isShort = isShort
|
||||
}
|
||||
|
||||
// MARK: - Standing in for metadata
|
||||
@@ -134,6 +139,12 @@ struct Video: Identifiable, Codable, Sendable {
|
||||
)
|
||||
}
|
||||
|
||||
/// Whether a "Hide Shorts" filter should drop this video: only when the
|
||||
/// source said it is a Short, never when it couldn't tell.
|
||||
var isKnownShort: Bool {
|
||||
isShort == true
|
||||
}
|
||||
|
||||
/// Whether the title is only the video's own ID standing in for one.
|
||||
///
|
||||
/// Anything showing this video beside details it fetched itself should
|
||||
@@ -518,6 +529,7 @@ extension Video: Equatable {
|
||||
&& lhs.thumbnails == rhs.thumbnails
|
||||
&& lhs.description == rhs.description
|
||||
&& lhs.relatedVideos == rhs.relatedVideos
|
||||
&& lhs.isShort == rhs.isShort
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user