mirror of
https://github.com/yattee/yattee.git
synced 2025-08-06 18:54:11 +00:00
Creating playlists
This commit is contained in:
@@ -54,6 +54,11 @@ final class InvidiousAPI: Service {
|
||||
content.json.arrayValue.map(Playlist.init)
|
||||
}
|
||||
|
||||
configureTransformer("/auth/playlists", requestMethods: [.post]) { (content: Entity<Data>) -> Playlist in
|
||||
// hacky, to verify if possible to get it in easier way
|
||||
Playlist(JSON(parseJSON: String(data: content.content, encoding: .utf8)!))
|
||||
}
|
||||
|
||||
configureTransformer("/auth/feed", requestMethods: [.get]) { (content: Entity<JSON>) -> [Video] in
|
||||
if let feedVideos = content.json.dictionaryValue["videos"] {
|
||||
return feedVideos.arrayValue.map { Video($0) }
|
||||
@@ -108,12 +113,12 @@ final class InvidiousAPI: Service {
|
||||
.withParam("q", searchQuery(query.query))
|
||||
.withParam("sort_by", query.sortBy.parameter)
|
||||
|
||||
if let date = query.date {
|
||||
resource = resource.withParam("date", date.rawValue)
|
||||
if let date = query.date?.rawValue {
|
||||
resource = resource.withParam("date", date)
|
||||
}
|
||||
|
||||
if let duration = query.duration {
|
||||
resource = resource.withParam("duration", duration.rawValue)
|
||||
if let duration = query.duration?.rawValue {
|
||||
resource = resource.withParam("duration", duration)
|
||||
}
|
||||
|
||||
return resource
|
||||
@@ -135,6 +140,6 @@ final class InvidiousAPI: Service {
|
||||
searchQuery = id
|
||||
}
|
||||
|
||||
return searchQuery.addingPercentEncoding(withAllowedCharacters: .alphanumerics)!
|
||||
return searchQuery
|
||||
}
|
||||
}
|
||||
|
13
Model/PlaylistVisibility.swift
Normal file
13
Model/PlaylistVisibility.swift
Normal file
@@ -0,0 +1,13 @@
|
||||
import Foundation
|
||||
|
||||
enum PlaylistVisibility: String, CaseIterable, Identifiable {
|
||||
case `public`, unlisted, `private`
|
||||
|
||||
var id: String {
|
||||
rawValue
|
||||
}
|
||||
|
||||
var name: String {
|
||||
rawValue.capitalized
|
||||
}
|
||||
}
|
@@ -2,8 +2,8 @@ import Foundation
|
||||
|
||||
final class SearchQuery: ObservableObject {
|
||||
@Published var query: String
|
||||
@Published var sortBy = SearchSortOrder.relevance
|
||||
@Published var date: SearchDate? = SearchDate.month
|
||||
@Published var sortBy: SearchSortOrder = .relevance
|
||||
@Published var date: SearchDate? = .month
|
||||
@Published var duration: SearchDuration?
|
||||
|
||||
@Published var page = 1
|
||||
|
Reference in New Issue
Block a user