mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-25 21:04:02 +02:00
Update:iOS stream and download URLs to use new API endpoints
This commit is contained in:
@@ -347,10 +347,21 @@ public class AbsDownloader: CAPPlugin, URLSessionDownloadDelegate {
|
||||
}
|
||||
|
||||
private func urlForTrack(item: LibraryItem, track: AudioTrack) -> URL {
|
||||
// filename needs to be encoded otherwise would just use contentUrl
|
||||
let relPath = track.metadata?.relPath ?? ""
|
||||
let filepathEncoded = relPath.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed)
|
||||
let urlstr = "\(Store.serverConfig!.address)/s/item/\(item.id)/\(filepathEncoded ?? "")?token=\(Store.serverConfig!.token)"
|
||||
// TODO: Future server release should include ino with AudioFile or FileMetadata
|
||||
let trackPath = track.metadata?.path ?? ""
|
||||
|
||||
var audioFileIno = ""
|
||||
if (item.mediaType == "podcast") {
|
||||
let podcastEpisodes = item.media?.episodes ?? List<PodcastEpisode>()
|
||||
let matchingEpisode = podcastEpisodes.first(where: { $0.audioFile?.metadata?.path == trackPath })
|
||||
audioFileIno = matchingEpisode?.audioFile?.ino ?? ""
|
||||
} else {
|
||||
let audioFiles = item.media?.audioFiles ?? List<AudioFile>()
|
||||
let matchingAudioFile = audioFiles.first(where: { $0.metadata?.path == trackPath })
|
||||
audioFileIno = matchingAudioFile?.ino ?? ""
|
||||
}
|
||||
|
||||
let urlstr = "\(Store.serverConfig!.address)/api/items/\(item.id)/file/\(audioFileIno)/download?token=\(Store.serverConfig!.token)"
|
||||
return URL(string: urlstr)!
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user