Add:Library filter for single & multi-track audiobooks #1213

This commit is contained in:
advplyr 2022-11-27 17:42:02 -06:00
parent e97d92a8ac
commit 972271a1a9
3 changed files with 46 additions and 23 deletions

View File

@ -174,6 +174,11 @@ export default {
value: 'missing', value: 'missing',
sublist: true sublist: true
}, },
{
text: this.$strings.LabelTracks,
value: 'tracks',
sublist: true
},
{ {
text: this.$strings.ButtonIssues, text: this.$strings.ButtonIssues,
value: 'issues', value: 'issues',
@ -265,6 +270,18 @@ export default {
progress() { progress() {
return [this.$strings.LabelFinished, this.$strings.LabelInProgress, this.$strings.LabelNotStarted, this.$strings.LabelNotFinished] return [this.$strings.LabelFinished, this.$strings.LabelInProgress, this.$strings.LabelNotStarted, this.$strings.LabelNotFinished]
}, },
tracks() {
return [
{
id: 'single',
name: this.$strings.LabelTracksSingleTrack
},
{
id: 'multi',
name: this.$strings.LabelTracksMultiTrack
}
]
},
missing() { missing() {
return ['ASIN', 'ISBN', this.$strings.LabelSubtitle, this.$strings.LabelAuthor, this.$strings.LabelPublishYear, this.$strings.LabelSeries, this.$strings.LabelDescription, this.$strings.LabelGenres, this.$strings.LabelTags, this.$strings.LabelNarrator, this.$strings.LabelPublisher, this.$strings.LabelLanguage] return ['ASIN', 'ISBN', this.$strings.LabelSubtitle, this.$strings.LabelAuthor, this.$strings.LabelPublishYear, this.$strings.LabelSeries, this.$strings.LabelDescription, this.$strings.LabelGenres, this.$strings.LabelTags, this.$strings.LabelNarrator, this.$strings.LabelPublisher, this.$strings.LabelLanguage]
}, },

View File

@ -389,6 +389,9 @@
"LabelTotalTimeListened": "Total Time Listened", "LabelTotalTimeListened": "Total Time Listened",
"LabelTrackFromFilename": "Track from Filename", "LabelTrackFromFilename": "Track from Filename",
"LabelTrackFromMetadata": "Track from Metadata", "LabelTrackFromMetadata": "Track from Metadata",
"LabelTracks": "Tracks",
"LabelTracksMultiTrack": "Multi-track",
"LabelTracksSingleTrack": "Single-track",
"LabelType": "Type", "LabelType": "Type",
"LabelUnknown": "Unknown", "LabelUnknown": "Unknown",
"LabelUpdateCover": "Update Cover", "LabelUpdateCover": "Update Cover",

View File

@ -10,26 +10,26 @@ module.exports = {
}, },
getFilteredLibraryItems(libraryItems, filterBy, user, feedsArray) { getFilteredLibraryItems(libraryItems, filterBy, user, feedsArray) {
var filtered = libraryItems let filtered = libraryItems
var searchGroups = ['genres', 'tags', 'series', 'authors', 'progress', 'narrators', 'missing', 'languages'] const searchGroups = ['genres', 'tags', 'series', 'authors', 'progress', 'narrators', 'missing', 'languages', 'tracks']
var group = searchGroups.find(_group => filterBy.startsWith(_group + '.')) const group = searchGroups.find(_group => filterBy.startsWith(_group + '.'))
if (group) { if (group) {
var filterVal = filterBy.replace(`${group}.`, '') const filterVal = filterBy.replace(`${group}.`, '')
var filter = this.decode(filterVal) const filter = this.decode(filterVal)
if (group === 'genres') filtered = filtered.filter(li => li.media.metadata && li.media.metadata.genres.includes(filter)) if (group === 'genres') filtered = filtered.filter(li => li.media.metadata && li.media.metadata.genres.includes(filter))
else if (group === 'tags') filtered = filtered.filter(li => li.media.tags.includes(filter)) else if (group === 'tags') filtered = filtered.filter(li => li.media.tags.includes(filter))
else if (group === 'series') { else if (group === 'series') {
if (filter === 'No Series') filtered = filtered.filter(li => li.mediaType === 'book' && !li.media.metadata.series.length) if (filter === 'No Series') filtered = filtered.filter(li => li.isBook && !li.media.metadata.series.length)
else { else {
filtered = filtered.filter(li => li.mediaType === 'book' && li.media.metadata.hasSeries(filter)) filtered = filtered.filter(li => li.isBook && li.media.metadata.hasSeries(filter))
} }
} }
else if (group === 'authors') filtered = filtered.filter(li => li.mediaType === 'book' && li.media.metadata.hasAuthor(filter)) else if (group === 'authors') filtered = filtered.filter(li => li.isBook && li.media.metadata.hasAuthor(filter))
else if (group === 'narrators') filtered = filtered.filter(li => li.mediaType === 'book' && li.media.metadata.hasNarrator(filter)) else if (group === 'narrators') filtered = filtered.filter(li => li.isBook && li.media.metadata.hasNarrator(filter))
else if (group === 'progress') { else if (group === 'progress') {
filtered = filtered.filter(li => { filtered = filtered.filter(li => {
var itemProgress = user.getMediaProgress(li.id) const itemProgress = user.getMediaProgress(li.id)
if (filter === 'Finished' && (itemProgress && itemProgress.isFinished)) return true if (filter === 'Finished' && (itemProgress && itemProgress.isFinished)) return true
if (filter === 'Not Started' && !itemProgress) return true if (filter === 'Not Started' && !itemProgress) return true
if (filter === 'Not Finished' && (!itemProgress || !itemProgress.isFinished)) return true if (filter === 'Not Finished' && (!itemProgress || !itemProgress.isFinished)) return true
@ -38,25 +38,28 @@ module.exports = {
}) })
} else if (group == 'missing') { } else if (group == 'missing') {
filtered = filtered.filter(li => { filtered = filtered.filter(li => {
if (li.mediaType === 'book') { if (li.isBook) {
if (filter === 'ASIN' && li.media.metadata.asin === null) return true; if (filter === 'ASIN' && li.media.metadata.asin === null) return true
if (filter === 'ISBN' && li.media.metadata.isbn === null) return true; if (filter === 'ISBN' && li.media.metadata.isbn === null) return true
if (filter === 'Subtitle' && li.media.metadata.subtitle === null) return true; if (filter === 'Subtitle' && li.media.metadata.subtitle === null) return true
if (filter === 'Author' && li.media.metadata.authors.length === 0) return true; if (filter === 'Author' && li.media.metadata.authors.length === 0) return true
if (filter === 'Publish Year' && li.media.metadata.publishedYear === null) return true; if (filter === 'Publish Year' && li.media.metadata.publishedYear === null) return true
if (filter === 'Series' && li.media.metadata.series.length === 0) return true; if (filter === 'Series' && li.media.metadata.series.length === 0) return true
if (filter === 'Description' && li.media.metadata.description === null) return true; if (filter === 'Description' && li.media.metadata.description === null) return true
if (filter === 'Genres' && li.media.metadata.genres.length === 0) return true; if (filter === 'Genres' && li.media.metadata.genres.length === 0) return true
if (filter === 'Tags' && li.media.tags.length === 0) return true; if (filter === 'Tags' && li.media.tags.length === 0) return true
if (filter === 'Narrator' && li.media.metadata.narrators.length === 0) return true; if (filter === 'Narrator' && li.media.metadata.narrators.length === 0) return true
if (filter === 'Publisher' && li.media.metadata.publisher === null) return true; if (filter === 'Publisher' && li.media.metadata.publisher === null) return true
if (filter === 'Language' && li.media.metadata.language === null) return true; if (filter === 'Language' && li.media.metadata.language === null) return true
} else { } else {
return false return false
} }
}) })
} else if (group === 'languages') { } else if (group === 'languages') {
filtered = filtered.filter(li => li.media.metadata && li.media.metadata.language === filter) filtered = filtered.filter(li => li.media.metadata && li.media.metadata.language === filter)
} else if (group === 'tracks') {
if (filter === 'single') filtered = filtered.filter(li => li.isBook && li.media.numTracks === 1)
else if (filter === 'multi') filtered = filtered.filter(li => li.isBook && li.media.numTracks > 1)
} }
} else if (filterBy === 'issues') { } else if (filterBy === 'issues') {
filtered = filtered.filter(li => li.hasIssues) filtered = filtered.filter(li => li.hasIssues)