Add album detail and track listing
This commit is contained in:
1 parent
c415380336
commit
39a64bebf2
4 files changed
+355
-11
No files matched your search
@@ -79,9 +79,14 @@ public final class APIClient: @unchecked Sendable {
|
||||
body: Body? = nil,
|
||||
response: Response.Type = Response.self
|
||||
) async throws -> Response {
|
||||
try await perform(
|
||||
method, path: path, query: query, body: body, response: response,
|
||||
refreshAfterUnauthorized: true)
|
||||
do {
|
||||
return try await perform(
|
||||
method, path: path, query: query, body: body, response: response,
|
||||
refreshAfterUnauthorized: true)
|
||||
} catch {
|
||||
print("[APIClient] \(method) \(path) failed: \(error.localizedDescription)")
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
private func perform<Response: Decodable & Sendable, Body: Encodable & Sendable>(
|
||||
@@ -156,7 +161,7 @@ public final class APIClient: @unchecked Sendable {
|
||||
return try decoder.decode(Response.self, from: Data("null".utf8))
|
||||
}
|
||||
return try decoder.decode(Response.self, from: data)
|
||||
} catch { throw APIError.decoding(error.localizedDescription) }
|
||||
} catch { throw APIError.decoding(String(describing: error)) }
|
||||
} catch let error as APIError { throw error } catch {
|
||||
throw APIError.transport(error.localizedDescription)
|
||||
}
|
||||
|
||||
+11
-1
@@ -46,6 +46,16 @@ nonisolated public struct Album: Decodable, Identifiable, Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
nonisolated public struct TrackAlbum: Decodable, Identifiable, Sendable {
|
||||
public let id: String
|
||||
public let name: String
|
||||
public let file: String
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id = "_id"
|
||||
case name, file
|
||||
}
|
||||
}
|
||||
|
||||
nonisolated public struct Lyrics: Decodable, Sendable {
|
||||
public let synced: Bool
|
||||
public let text: String
|
||||
@@ -54,7 +64,7 @@ nonisolated public struct Lyrics: Decodable, Sendable {
|
||||
nonisolated public struct Track: Decodable, Identifiable, Sendable {
|
||||
public let id: String
|
||||
public let name: String
|
||||
public let album: APIReference<Album>
|
||||
public let album: APIReference<TrackAlbum>
|
||||
public let artists: [APIReference<Artist>]
|
||||
public let fileDir: String
|
||||
public let durationInSeconds: Double
|
||||
|
||||
Reference in new issue
Block a user