mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-28 17:49:06 +01:00
Fix:Global search support podcasts
This commit is contained in:
parent
10d9e11387
commit
469278cd1e
@ -103,7 +103,7 @@ export default {
|
||||
},
|
||||
async setShelvesFromSearch() {
|
||||
var shelves = []
|
||||
if (this.results.books) {
|
||||
if (this.results.books && this.results.books.length) {
|
||||
shelves.push({
|
||||
id: 'books',
|
||||
label: 'Books',
|
||||
@ -112,7 +112,16 @@ export default {
|
||||
})
|
||||
}
|
||||
|
||||
if (this.results.series) {
|
||||
if (this.results.podcasts && this.results.podcasts.length) {
|
||||
shelves.push({
|
||||
id: 'podcasts',
|
||||
label: 'Podcasts',
|
||||
type: 'podcast',
|
||||
entities: this.results.podcasts.map((res) => res.libraryItem)
|
||||
})
|
||||
}
|
||||
|
||||
if (this.results.series && this.results.series.length) {
|
||||
shelves.push({
|
||||
id: 'series',
|
||||
label: 'Series',
|
||||
@ -127,7 +136,7 @@ export default {
|
||||
})
|
||||
})
|
||||
}
|
||||
if (this.results.tags) {
|
||||
if (this.results.tags && this.results.tags.length) {
|
||||
shelves.push({
|
||||
id: 'tags',
|
||||
label: 'Tags',
|
||||
@ -141,7 +150,7 @@ export default {
|
||||
})
|
||||
})
|
||||
}
|
||||
if (this.results.authors) {
|
||||
if (this.results.authors && this.results.authors.length) {
|
||||
shelves.push({
|
||||
id: 'authors',
|
||||
label: 'Authors',
|
||||
|
@ -40,6 +40,12 @@ export default {
|
||||
media() {
|
||||
return this.libraryItem ? this.libraryItem.media || {} : {}
|
||||
},
|
||||
mediaType() {
|
||||
return this.libraryItem ? this.libraryItem.mediaType : null
|
||||
},
|
||||
isPodcast() {
|
||||
return this.mediaType == 'podcast'
|
||||
},
|
||||
mediaMetadata() {
|
||||
return this.media.metadata || {}
|
||||
},
|
||||
@ -49,11 +55,9 @@ export default {
|
||||
subtitle() {
|
||||
return this.mediaMetadata.subtitle || ''
|
||||
},
|
||||
authors() {
|
||||
return this.mediaMetadata.authors || []
|
||||
},
|
||||
authorName() {
|
||||
return this.authors.map((au) => au.name).join(', ')
|
||||
if (this.isPodcast) return this.mediaMetadata.author || 'Unknown'
|
||||
return this.mediaMetadata.authorName || 'Unknown'
|
||||
},
|
||||
matchHtml() {
|
||||
if (!this.matchText || !this.search) return ''
|
@ -19,11 +19,20 @@
|
||||
<p>No Results</p>
|
||||
</li>
|
||||
<template v-else>
|
||||
<p class="uppercase text-xs text-gray-400 my-1 px-1 font-semibold">Books</p>
|
||||
<p v-if="bookResults.length" class="uppercase text-xs text-gray-400 my-1 px-1 font-semibold">Books</p>
|
||||
<template v-for="item in bookResults">
|
||||
<li :key="item.libraryItem.id" class="text-gray-50 select-none relative cursor-pointer hover:bg-black-400 py-1" role="option">
|
||||
<nuxt-link :to="`/item/${item.id}`">
|
||||
<cards-audiobook-search-card :library-item="item.libraryItem" :match-key="item.matchKey" :match-text="item.matchText" :search="lastSearch" />
|
||||
<cards-item-search-card :library-item="item.libraryItem" :match-key="item.matchKey" :match-text="item.matchText" :search="lastSearch" />
|
||||
</nuxt-link>
|
||||
</li>
|
||||
</template>
|
||||
|
||||
<p v-if="podcastResults.length" class="uppercase text-xs text-gray-400 my-1 px-1 font-semibold">Podcasts</p>
|
||||
<template v-for="item in podcastResults">
|
||||
<li :key="item.libraryItem.id" class="text-gray-50 select-none relative cursor-pointer hover:bg-black-400 py-1" role="option">
|
||||
<nuxt-link :to="`/item/${item.id}`">
|
||||
<cards-item-search-card :library-item="item.libraryItem" :match-key="item.matchKey" :match-text="item.matchText" :search="lastSearch" />
|
||||
</nuxt-link>
|
||||
</li>
|
||||
</template>
|
||||
@ -70,6 +79,7 @@ export default {
|
||||
isTyping: false,
|
||||
isFetching: false,
|
||||
search: null,
|
||||
podcastResults: [],
|
||||
bookResults: [],
|
||||
authorResults: [],
|
||||
seriesResults: [],
|
||||
@ -83,7 +93,7 @@ export default {
|
||||
return this.$store.state.libraries.currentLibraryId
|
||||
},
|
||||
totalResults() {
|
||||
return this.bookResults.length + this.seriesResults.length + this.authorResults.length + this.tagResults.length
|
||||
return this.bookResults.length + this.seriesResults.length + this.authorResults.length + this.tagResults.length + this.podcastResults.length
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -96,6 +106,7 @@ export default {
|
||||
clearResults() {
|
||||
this.search = null
|
||||
this.lastSearch = null
|
||||
this.podcastResults = []
|
||||
this.bookResults = []
|
||||
this.authorResults = []
|
||||
this.seriesResults = []
|
||||
@ -136,6 +147,7 @@ export default {
|
||||
// Search was canceled
|
||||
if (!this.isFetching) return
|
||||
|
||||
this.podcastResults = searchResults.podcast || []
|
||||
this.bookResults = searchResults.book || []
|
||||
this.authorResults = searchResults.authors || []
|
||||
this.seriesResults = searchResults.series || []
|
||||
|
@ -117,7 +117,6 @@ export default {
|
||||
console.error('Failed to get search results', error)
|
||||
return []
|
||||
})
|
||||
console.log('Search results', results)
|
||||
this.items = results || []
|
||||
this.searching = false
|
||||
},
|
||||
|
@ -78,7 +78,6 @@ export default {
|
||||
console.error('Failed to get search results', error)
|
||||
return []
|
||||
})
|
||||
// console.log('Search results', results)
|
||||
this.items = results || []
|
||||
this.searching = false
|
||||
},
|
||||
|
@ -30,7 +30,8 @@ export default {
|
||||
return null
|
||||
})
|
||||
results = {
|
||||
books: results && results.book.length ? results.book : null,
|
||||
podcasts: results && results.podcast ? results.podcast : null,
|
||||
books: results && results.book ? results.book : null,
|
||||
authors: results && results.authors.length ? results.authors : null,
|
||||
series: results && results.series.length ? results.series : null,
|
||||
tags: results && results.tags.length ? results.tags : null
|
||||
@ -57,7 +58,7 @@ export default {
|
||||
return this.$store.state.streamLibraryItem
|
||||
},
|
||||
hasResults() {
|
||||
return Object.values(this.results).find((r) => !!r)
|
||||
return Object.values(this.results).find((r) => !!r && r.length)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -67,7 +68,8 @@ export default {
|
||||
return null
|
||||
})
|
||||
this.results = {
|
||||
books: results && results.book.length ? results.book : null,
|
||||
podcasts: results && results.podcast ? results.podcast : null,
|
||||
books: results && results.book ? results.book : null,
|
||||
authors: results && results.authors.length ? results.authors : null,
|
||||
series: results && results.series.length ? results.series : null,
|
||||
tags: results && results.tags.length ? results.tags : null
|
||||
|
@ -457,7 +457,7 @@ class LibraryController {
|
||||
var queryResult = li.searchQuery(req.query.q)
|
||||
if (queryResult.matchKey) {
|
||||
itemMatches.push({
|
||||
libraryItem: li,
|
||||
libraryItem: li.toJSONExpanded(),
|
||||
matchKey: queryResult.matchKey,
|
||||
matchText: queryResult.matchText
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user