mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-07-28 14:44:30 +02:00
Use book/podcast helper
This commit is contained in:
parent
5f4ff38035
commit
2b07c81e54
2 changed files with 3 additions and 2 deletions
|
@ -39,6 +39,7 @@ struct LocalLibraryItem: Realmable, Codable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isBook: Bool { self.mediaType == "book" }
|
||||||
var isPodcast: Bool { self.mediaType == "podcast" }
|
var isPodcast: Bool { self.mediaType == "podcast" }
|
||||||
|
|
||||||
static func primaryKey() -> String? {
|
static func primaryKey() -> String? {
|
||||||
|
|
|
@ -34,13 +34,13 @@ extension LocalLibraryItem {
|
||||||
var fromMedia = fromMedia
|
var fromMedia = fromMedia
|
||||||
let fileMap = files.map { ($0.filename ?? "", $0.id) }
|
let fileMap = files.map { ($0.filename ?? "", $0.id) }
|
||||||
let fileIdByFilename = Dictionary(fileMap, uniquingKeysWith: { (_, last) in last })
|
let fileIdByFilename = Dictionary(fileMap, uniquingKeysWith: { (_, last) in last })
|
||||||
if ( self.mediaType == "book" ) {
|
if ( self.isBook ) {
|
||||||
if let tracks = fromMedia.tracks {
|
if let tracks = fromMedia.tracks {
|
||||||
for i in tracks.indices {
|
for i in tracks.indices {
|
||||||
_ = fromMedia.tracks?[i].setLocalInfo(filenameIdMap: fileIdByFilename, serverIndex: i)
|
_ = fromMedia.tracks?[i].setLocalInfo(filenameIdMap: fileIdByFilename, serverIndex: i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ( self.mediaType == "podcast" ) {
|
} else if ( self.isPodcast ) {
|
||||||
if let episodes = fromMedia.episodes {
|
if let episodes = fromMedia.episodes {
|
||||||
fromMedia.episodes = episodes.compactMap { episode in
|
fromMedia.episodes = episodes.compactMap { episode in
|
||||||
// Filter out episodes not downloaded
|
// Filter out episodes not downloaded
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue