mirror of
https://github.com/yattee/yattee.git
synced 2025-08-06 10:44:06 +00:00
Adding/removing videos to/from playlists
This commit is contained in:
@@ -112,6 +112,14 @@ final class InvidiousAPI: Service {
|
||||
resource("/auth/playlists/\(id)")
|
||||
}
|
||||
|
||||
func playlistVideos(_ id: String) -> Resource {
|
||||
playlist(id).child("videos")
|
||||
}
|
||||
|
||||
func playlistVideo(_ playlistID: String, _ videoID: String) -> Resource {
|
||||
playlist(playlistID).child("videos").child(videoID)
|
||||
}
|
||||
|
||||
func search(_ query: SearchQuery) -> Resource {
|
||||
var resource = resource("/search")
|
||||
.withParam("q", searchQuery(query.query))
|
||||
|
@@ -6,17 +6,20 @@ struct Playlist: Identifiable, Equatable, Hashable {
|
||||
var title: String
|
||||
var visibility: PlaylistVisibility
|
||||
|
||||
var updated: TimeInterval
|
||||
|
||||
var videos = [Video]()
|
||||
|
||||
init(_ json: JSON) {
|
||||
id = json["playlistId"].stringValue
|
||||
title = json["title"].stringValue
|
||||
visibility = json["isListed"].boolValue ? .public : .private
|
||||
updated = json["updated"].doubleValue
|
||||
videos = json["videos"].arrayValue.map { Video($0) }
|
||||
}
|
||||
|
||||
static func == (lhs: Playlist, rhs: Playlist) -> Bool {
|
||||
lhs.id == rhs.id && lhs.title == rhs.title && lhs.visibility == rhs.visibility
|
||||
lhs.id == rhs.id && lhs.updated == rhs.updated
|
||||
}
|
||||
|
||||
func hash(into hasher: inout Hasher) {
|
||||
|
8
Model/PlaylistVideo.swift
Normal file
8
Model/PlaylistVideo.swift
Normal file
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// PlaylistVideo.swift
|
||||
// Pearvidious
|
||||
//
|
||||
// Created by Arkadiusz Fal on 09/07/2021.
|
||||
//
|
||||
|
||||
import Foundation
|
@@ -15,10 +15,21 @@ struct Video: Identifiable {
|
||||
var description: String
|
||||
var genre: String
|
||||
|
||||
let indexID: String?
|
||||
|
||||
var streams = [Stream]()
|
||||
|
||||
init(_ json: JSON) {
|
||||
id = json["videoId"].stringValue
|
||||
let videoID = json["videoId"].stringValue
|
||||
|
||||
if let id = json["indexId"].string {
|
||||
indexID = id
|
||||
self.id = videoID + id
|
||||
} else {
|
||||
indexID = nil
|
||||
id = videoID
|
||||
}
|
||||
|
||||
title = json["title"].stringValue
|
||||
author = json["author"].stringValue
|
||||
length = json["lengthSeconds"].doubleValue
|
||||
|
Reference in New Issue
Block a user