mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-03-14 00:21:31 +01:00
Fix:Global search support podcasts
This commit is contained in:
parent
10d9e11387
commit
469278cd1e
@ -103,7 +103,7 @@ export default {
|
|||||||
},
|
},
|
||||||
async setShelvesFromSearch() {
|
async setShelvesFromSearch() {
|
||||||
var shelves = []
|
var shelves = []
|
||||||
if (this.results.books) {
|
if (this.results.books && this.results.books.length) {
|
||||||
shelves.push({
|
shelves.push({
|
||||||
id: 'books',
|
id: 'books',
|
||||||
label: '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({
|
shelves.push({
|
||||||
id: 'series',
|
id: 'series',
|
||||||
label: 'Series',
|
label: 'Series',
|
||||||
@ -127,7 +136,7 @@ export default {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (this.results.tags) {
|
if (this.results.tags && this.results.tags.length) {
|
||||||
shelves.push({
|
shelves.push({
|
||||||
id: 'tags',
|
id: 'tags',
|
||||||
label: 'Tags',
|
label: 'Tags',
|
||||||
@ -141,7 +150,7 @@ export default {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (this.results.authors) {
|
if (this.results.authors && this.results.authors.length) {
|
||||||
shelves.push({
|
shelves.push({
|
||||||
id: 'authors',
|
id: 'authors',
|
||||||
label: 'Authors',
|
label: 'Authors',
|
||||||
|
@ -40,6 +40,12 @@ export default {
|
|||||||
media() {
|
media() {
|
||||||
return this.libraryItem ? this.libraryItem.media || {} : {}
|
return this.libraryItem ? this.libraryItem.media || {} : {}
|
||||||
},
|
},
|
||||||
|
mediaType() {
|
||||||
|
return this.libraryItem ? this.libraryItem.mediaType : null
|
||||||
|
},
|
||||||
|
isPodcast() {
|
||||||
|
return this.mediaType == 'podcast'
|
||||||
|
},
|
||||||
mediaMetadata() {
|
mediaMetadata() {
|
||||||
return this.media.metadata || {}
|
return this.media.metadata || {}
|
||||||
},
|
},
|
||||||
@ -49,11 +55,9 @@ export default {
|
|||||||
subtitle() {
|
subtitle() {
|
||||||
return this.mediaMetadata.subtitle || ''
|
return this.mediaMetadata.subtitle || ''
|
||||||
},
|
},
|
||||||
authors() {
|
|
||||||
return this.mediaMetadata.authors || []
|
|
||||||
},
|
|
||||||
authorName() {
|
authorName() {
|
||||||
return this.authors.map((au) => au.name).join(', ')
|
if (this.isPodcast) return this.mediaMetadata.author || 'Unknown'
|
||||||
|
return this.mediaMetadata.authorName || 'Unknown'
|
||||||
},
|
},
|
||||||
matchHtml() {
|
matchHtml() {
|
||||||
if (!this.matchText || !this.search) return ''
|
if (!this.matchText || !this.search) return ''
|
@ -19,11 +19,20 @@
|
|||||||
<p>No Results</p>
|
<p>No Results</p>
|
||||||
</li>
|
</li>
|
||||||
<template v-else>
|
<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">
|
<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">
|
<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}`">
|
<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>
|
</nuxt-link>
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
@ -70,6 +79,7 @@ export default {
|
|||||||
isTyping: false,
|
isTyping: false,
|
||||||
isFetching: false,
|
isFetching: false,
|
||||||
search: null,
|
search: null,
|
||||||
|
podcastResults: [],
|
||||||
bookResults: [],
|
bookResults: [],
|
||||||
authorResults: [],
|
authorResults: [],
|
||||||
seriesResults: [],
|
seriesResults: [],
|
||||||
@ -83,7 +93,7 @@ export default {
|
|||||||
return this.$store.state.libraries.currentLibraryId
|
return this.$store.state.libraries.currentLibraryId
|
||||||
},
|
},
|
||||||
totalResults() {
|
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: {
|
methods: {
|
||||||
@ -96,6 +106,7 @@ export default {
|
|||||||
clearResults() {
|
clearResults() {
|
||||||
this.search = null
|
this.search = null
|
||||||
this.lastSearch = null
|
this.lastSearch = null
|
||||||
|
this.podcastResults = []
|
||||||
this.bookResults = []
|
this.bookResults = []
|
||||||
this.authorResults = []
|
this.authorResults = []
|
||||||
this.seriesResults = []
|
this.seriesResults = []
|
||||||
@ -136,6 +147,7 @@ export default {
|
|||||||
// Search was canceled
|
// Search was canceled
|
||||||
if (!this.isFetching) return
|
if (!this.isFetching) return
|
||||||
|
|
||||||
|
this.podcastResults = searchResults.podcast || []
|
||||||
this.bookResults = searchResults.book || []
|
this.bookResults = searchResults.book || []
|
||||||
this.authorResults = searchResults.authors || []
|
this.authorResults = searchResults.authors || []
|
||||||
this.seriesResults = searchResults.series || []
|
this.seriesResults = searchResults.series || []
|
||||||
|
@ -117,7 +117,6 @@ export default {
|
|||||||
console.error('Failed to get search results', error)
|
console.error('Failed to get search results', error)
|
||||||
return []
|
return []
|
||||||
})
|
})
|
||||||
console.log('Search results', results)
|
|
||||||
this.items = results || []
|
this.items = results || []
|
||||||
this.searching = false
|
this.searching = false
|
||||||
},
|
},
|
||||||
|
@ -78,7 +78,6 @@ export default {
|
|||||||
console.error('Failed to get search results', error)
|
console.error('Failed to get search results', error)
|
||||||
return []
|
return []
|
||||||
})
|
})
|
||||||
// console.log('Search results', results)
|
|
||||||
this.items = results || []
|
this.items = results || []
|
||||||
this.searching = false
|
this.searching = false
|
||||||
},
|
},
|
||||||
|
@ -30,7 +30,8 @@ export default {
|
|||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
results = {
|
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,
|
authors: results && results.authors.length ? results.authors : null,
|
||||||
series: results && results.series.length ? results.series : null,
|
series: results && results.series.length ? results.series : null,
|
||||||
tags: results && results.tags.length ? results.tags : null
|
tags: results && results.tags.length ? results.tags : null
|
||||||
@ -57,7 +58,7 @@ export default {
|
|||||||
return this.$store.state.streamLibraryItem
|
return this.$store.state.streamLibraryItem
|
||||||
},
|
},
|
||||||
hasResults() {
|
hasResults() {
|
||||||
return Object.values(this.results).find((r) => !!r)
|
return Object.values(this.results).find((r) => !!r && r.length)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -67,7 +68,8 @@ export default {
|
|||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
this.results = {
|
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,
|
authors: results && results.authors.length ? results.authors : null,
|
||||||
series: results && results.series.length ? results.series : null,
|
series: results && results.series.length ? results.series : null,
|
||||||
tags: results && results.tags.length ? results.tags : null
|
tags: results && results.tags.length ? results.tags : null
|
||||||
|
@ -457,7 +457,7 @@ class LibraryController {
|
|||||||
var queryResult = li.searchQuery(req.query.q)
|
var queryResult = li.searchQuery(req.query.q)
|
||||||
if (queryResult.matchKey) {
|
if (queryResult.matchKey) {
|
||||||
itemMatches.push({
|
itemMatches.push({
|
||||||
libraryItem: li,
|
libraryItem: li.toJSONExpanded(),
|
||||||
matchKey: queryResult.matchKey,
|
matchKey: queryResult.matchKey,
|
||||||
matchText: queryResult.matchText
|
matchText: queryResult.matchText
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user