mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-12-01 12:44:06 +01:00
Fix LibraryItem dupe class member hasAudioFiles
This commit is contained in:
1 parent
ad8b235058
commit
8fb7a856d5
2 files changed
+13
-25
No files matched your search
@@ -57,7 +57,7 @@ class RSSFeedController {
|
||||
}
|
||||
|
||||
// Check item has audio tracks
|
||||
if (!itemExpanded.hasAudioTracks()) {
|
||||
if (!itemExpanded.hasAudioTracks) {
|
||||
Logger.error(`[RSSFeedController] Cannot open RSS feed for item "${itemExpanded.media.title}" because it has no audio tracks`)
|
||||
return res.status(400).send('Item has no audio tracks')
|
||||
}
|
||||
|
||||
@@ -491,11 +491,7 @@ class LibraryItem extends Model {
|
||||
}
|
||||
Logger.debug(`Loaded ${newestAuthorsPayload.authors.length} of ${newestAuthorsPayload.count} authors for "Newest Authors" in ${newestAuthorsResult.elapsedSeconds}s`)
|
||||
} else if (library.isPodcast) {
|
||||
const [newestEpisodesResult, mostRecentResult, mediaFinishedResult] = await Promise.all([
|
||||
timed(() => libraryFilters.getNewestPodcastEpisodes(library, user, limit)),
|
||||
timed(() => libraryFilters.getLibraryItemsMostRecentlyAdded(library, user, include, limit)),
|
||||
timed(() => libraryFilters.getMediaFinished(library, user, include, limit))
|
||||
])
|
||||
const [newestEpisodesResult, mostRecentResult, mediaFinishedResult] = await Promise.all([timed(() => libraryFilters.getNewestPodcastEpisodes(library, user, limit)), timed(() => libraryFilters.getLibraryItemsMostRecentlyAdded(library, user, include, limit)), timed(() => libraryFilters.getMediaFinished(library, user, include, limit))])
|
||||
|
||||
const newestEpisodesPayload = newestEpisodesResult.payload
|
||||
// "Newest Episodes" shelf
|
||||
@@ -852,8 +848,18 @@ class LibraryItem extends Model {
|
||||
get isPodcast() {
|
||||
return this.mediaType === 'podcast'
|
||||
}
|
||||
/**
|
||||
* Check if book or podcast library item has audio tracks.
|
||||
* Requires expanded library item (media loaded).
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
get hasAudioTracks() {
|
||||
return this.media.hasAudioTracks()
|
||||
if (!this.media) {
|
||||
Logger.error(`[LibraryItem] hasAudioTracks: Library item "${this.id}" does not have media`)
|
||||
return false
|
||||
}
|
||||
return this.media.hasAudioTracks
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -904,24 +910,6 @@ class LibraryItem extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if book or podcast library item has audio tracks
|
||||
* Requires expanded library item
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
hasAudioTracks() {
|
||||
if (!this.media) {
|
||||
Logger.error(`[LibraryItem] hasAudioTracks: Library item "${this.id}" does not have media`)
|
||||
return false
|
||||
}
|
||||
if (this.isBook) {
|
||||
return this.media.audioFiles?.length > 0
|
||||
} else {
|
||||
return this.media.podcastEpisodes?.length > 0
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} ino
|
||||
|
||||
Reference in new issue
Block a user