Allow to add videos only to user created playlists

This commit is contained in:
Arkadiusz Fal
2022-09-12 17:23:20 +02:00
parent 8c2ffa1b99
commit d01b0f8275
3 changed files with 8 additions and 4 deletions

View File

@@ -634,10 +634,12 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
}
private func extractPlaylist(from content: JSON) -> Playlist {
.init(
id: content["playlistId"].stringValue,
let id = content["playlistId"].stringValue
return Playlist(
id: id,
title: content["title"].stringValue,
visibility: content["isListed"].boolValue ? .public : .private,
editable: id.starts(with: "IV"),
updated: content["updated"].doubleValue,
videos: content["videos"].arrayValue.map { extractVideo(from: $0) }
)

View File

@@ -17,15 +17,17 @@ struct Playlist: Identifiable, Equatable, Hashable {
let id: String
var title: String
var visibility: Visibility
var editable = true
var updated: TimeInterval?
var videos = [Video]()
init(id: String, title: String, visibility: Visibility, updated: TimeInterval? = nil, videos: [Video] = []) {
init(id: String, title: String, visibility: Visibility, editable: Bool = true, updated: TimeInterval? = nil, videos: [Video] = []) {
self.id = id
self.title = title
self.visibility = visibility
self.editable = editable
self.updated = updated
self.videos = videos
}