Fix podcast episode downloading

This commit is contained in:
ronaldheft 2022-08-11 11:20:17 -04:00
parent 81a4e4ff7b
commit 599a8e23cb
2 changed files with 3 additions and 4 deletions

View file

@ -234,7 +234,7 @@ public class AbsDownloader: CAPPlugin, URLSessionDownloadDelegate {
// Queue up everything for downloading // Queue up everything for downloading
var downloadItem = DownloadItem(libraryItem: item, episodeId: episodeId, server: Store.serverConfig!) var downloadItem = DownloadItem(libraryItem: item, episodeId: episodeId, server: Store.serverConfig!)
downloadItem.downloadItemParts = try tracks.enumerated().map({ i, track in downloadItem.downloadItemParts = try tracks.enumerated().map({ i, track in
try startLibraryItemTrackDownload(item: item, position: i, track: track) try startLibraryItemTrackDownload(item: item, position: i, track: track, episode: episode)
}) })
// Also download the cover // Also download the cover
@ -253,7 +253,7 @@ public class AbsDownloader: CAPPlugin, URLSessionDownloadDelegate {
} }
} }
private func startLibraryItemTrackDownload(item: LibraryItem, position: Int, track: AudioTrack) throws -> DownloadItemPart { private func startLibraryItemTrackDownload(item: LibraryItem, position: Int, track: AudioTrack, episode: PodcastEpisode?) throws -> DownloadItemPart {
NSLog("TRACK \(track.contentUrl!)") NSLog("TRACK \(track.contentUrl!)")
// If we don't name metadata, then we can't proceed // If we don't name metadata, then we can't proceed
@ -266,7 +266,7 @@ public class AbsDownloader: CAPPlugin, URLSessionDownloadDelegate {
let localUrl = "\(itemDirectory)/\(filename)" let localUrl = "\(itemDirectory)/\(filename)"
let task = session.downloadTask(with: serverUrl) let task = session.downloadTask(with: serverUrl)
var downloadItemPart = DownloadItemPart(filename: filename, destination: localUrl, itemTitle: track.title ?? "Unknown", serverPath: Store.serverConfig!.address, audioTrack: track, episode: nil) var downloadItemPart = DownloadItemPart(filename: filename, destination: localUrl, itemTitle: track.title ?? "Unknown", serverPath: Store.serverConfig!.address, audioTrack: track, episode: episode)
// Store the id on the task so the download item can be pulled from the database later // Store the id on the task so the download item can be pulled from the database later
task.taskDescription = downloadItemPart.id task.taskDescription = downloadItemPart.id

View file

@ -161,7 +161,6 @@ struct AudioFile: Realmable, Codable {
var metadata: FileMetadata var metadata: FileMetadata
init() { init() {
index = 0
ino = "" ino = ""
metadata = FileMetadata() metadata = FileMetadata()
} }