mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-15 16:29:37 +00:00
Add support for searching podcast episode titles #3301
This commit is contained in:
parent
25c7e95a64
commit
0ed6045d1e
5 changed files with 123 additions and 1 deletions
|
|
@ -411,6 +411,43 @@ module.exports = {
|
|||
})
|
||||
}
|
||||
|
||||
// Search podcast episode title
|
||||
const podcastEpisodes = await Database.podcastEpisodeModel.findAll({
|
||||
where: [
|
||||
Sequelize.literal(textSearchQuery.matchExpression('podcastEpisode.title')),
|
||||
{
|
||||
'$podcast.libraryItem.libraryId$': library.id
|
||||
}
|
||||
],
|
||||
replacements: userPermissionPodcastWhere.replacements,
|
||||
include: [
|
||||
{
|
||||
model: Database.podcastModel,
|
||||
where: [...userPermissionPodcastWhere.podcastWhere],
|
||||
include: [
|
||||
{
|
||||
model: Database.libraryItemModel
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
distinct: true,
|
||||
offset,
|
||||
limit
|
||||
})
|
||||
const episodeMatches = []
|
||||
for (const episode of podcastEpisodes) {
|
||||
const libraryItem = episode.podcast.libraryItem
|
||||
libraryItem.media = episode.podcast
|
||||
libraryItem.media.podcastEpisodes = []
|
||||
const oldPodcastEpisodeJson = episode.toOldJSONExpanded(libraryItem.id)
|
||||
const libraryItemJson = libraryItem.toOldJSONExpanded()
|
||||
libraryItemJson.recentEpisode = oldPodcastEpisodeJson
|
||||
episodeMatches.push({
|
||||
libraryItem: libraryItemJson
|
||||
})
|
||||
}
|
||||
|
||||
const matchJsonValue = textSearchQuery.matchExpression('json_each.value')
|
||||
|
||||
// Search tags
|
||||
|
|
@ -450,7 +487,8 @@ module.exports = {
|
|||
return {
|
||||
podcast: itemMatches,
|
||||
tags: tagMatches,
|
||||
genres: genreMatches
|
||||
genres: genreMatches,
|
||||
episodes: episodeMatches
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue