mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-29 06:37:16 +02:00
Handle download complete lifecycle
This commit is contained in:
@@ -9,7 +9,7 @@ import Foundation
|
||||
import Unrealm
|
||||
|
||||
struct DownloadItem: Realmable, Codable {
|
||||
var id: String = UUID().uuidString
|
||||
var id: String?
|
||||
var libraryItemId: String?
|
||||
var episodeId: String?
|
||||
var userMediaProgress: MediaProgress?
|
||||
@@ -36,6 +36,7 @@ struct DownloadItem: Realmable, Codable {
|
||||
|
||||
extension DownloadItem {
|
||||
init(libraryItem: LibraryItem, server: ServerConnectionConfig) {
|
||||
self.id = libraryItem.id
|
||||
self.libraryItemId = libraryItem.id
|
||||
//self.episodeId // TODO
|
||||
self.userMediaProgress = libraryItem.userMediaProgress
|
||||
@@ -52,7 +53,7 @@ extension DownloadItem {
|
||||
}
|
||||
|
||||
func didDownloadSuccessfully() -> Bool {
|
||||
self.downloadItemParts.allSatisfy({ $0.failed = false })
|
||||
self.downloadItemParts.allSatisfy({ $0.failed == false })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +102,10 @@ extension DownloadItemPart {
|
||||
self.destinationUri = destination.path
|
||||
}
|
||||
|
||||
func mimeType() -> String? {
|
||||
audioTrack?.mimeType ?? episode?.audioTrack?.mimeType
|
||||
}
|
||||
|
||||
func downloadURL() -> URL? {
|
||||
if let uri = self.uri {
|
||||
return URL(string: uri)
|
||||
|
||||
Reference in New Issue
Block a user