mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-02 01:05:25 +02:00
Add:Global library search also searches on podcast episode titles #1363
This commit is contained in:
parent
88bd51e2da
commit
1609f1a499
7 changed files with 45 additions and 20 deletions
|
@ -1,5 +1,5 @@
|
|||
const Path = require('path')
|
||||
const { getId } = require('../../utils/index')
|
||||
const { getId, cleanStringForSearch } = require('../../utils/index')
|
||||
const AudioFile = require('../files/AudioFile')
|
||||
const AudioTrack = require('../files/AudioTrack')
|
||||
|
||||
|
@ -160,5 +160,9 @@ class PodcastEpisode {
|
|||
if (!this.enclosure || !this.enclosure.url) return false
|
||||
return this.enclosure.url == url
|
||||
}
|
||||
|
||||
searchQuery(query) {
|
||||
return cleanStringForSearch(this.title).includes(query)
|
||||
}
|
||||
}
|
||||
module.exports = PodcastEpisode
|
|
@ -311,14 +311,14 @@ class Book {
|
|||
}
|
||||
|
||||
searchQuery(query) {
|
||||
var payload = {
|
||||
const payload = {
|
||||
tags: this.tags.filter(t => cleanStringForSearch(t).includes(query)),
|
||||
series: this.metadata.searchSeries(query),
|
||||
authors: this.metadata.searchAuthors(query),
|
||||
matchKey: null,
|
||||
matchText: null
|
||||
}
|
||||
var metadataMatch = this.metadata.searchQuery(query)
|
||||
const metadataMatch = this.metadata.searchQuery(query)
|
||||
if (metadataMatch) {
|
||||
payload.matchKey = metadataMatch.matchKey
|
||||
payload.matchText = metadataMatch.matchText
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const Logger = require('../../Logger')
|
||||
const PodcastEpisode = require('../entities/PodcastEpisode')
|
||||
const PodcastMetadata = require('../metadata/PodcastMetadata')
|
||||
const { areEquivalent, copyValue } = require('../../utils/index')
|
||||
const { areEquivalent, copyValue, cleanStringForSearch } = require('../../utils/index')
|
||||
const abmetadataGenerator = require('../../utils/abmetadataGenerator')
|
||||
const { readTextFile } = require('../../utils/fileUtils')
|
||||
const { createNewSortInstance } = require('../../libs/fastSort')
|
||||
|
@ -206,9 +206,29 @@ class Podcast {
|
|||
return false
|
||||
}
|
||||
|
||||
searchEpisodes(query) {
|
||||
return this.episodes.filter(ep => ep.searchQuery(query))
|
||||
}
|
||||
|
||||
searchQuery(query) {
|
||||
var payload = this.metadata.searchQuery(query)
|
||||
return payload || {}
|
||||
const payload = {
|
||||
tags: this.tags.filter(t => cleanStringForSearch(t).includes(query)),
|
||||
matchKey: null,
|
||||
matchText: null
|
||||
}
|
||||
const metadataMatch = this.metadata.searchQuery(query)
|
||||
if (metadataMatch) {
|
||||
payload.matchKey = metadataMatch.matchKey
|
||||
payload.matchText = metadataMatch.matchText
|
||||
} else {
|
||||
const matchingEpisodes = this.searchEpisodes(query)
|
||||
if (matchingEpisodes.length) {
|
||||
payload.matchKey = 'episode'
|
||||
payload.matchText = matchingEpisodes[0].title
|
||||
}
|
||||
}
|
||||
|
||||
return payload
|
||||
}
|
||||
|
||||
checkHasEpisode(episodeId) {
|
||||
|
|
|
@ -377,8 +377,8 @@ class BookMetadata {
|
|||
return this.authors.filter(au => cleanStringForSearch(au.name).includes(query))
|
||||
}
|
||||
searchQuery(query) { // Returns key if match is found
|
||||
var keysToCheck = ['title', 'asin', 'isbn']
|
||||
for (var key of keysToCheck) {
|
||||
const keysToCheck = ['title', 'asin', 'isbn']
|
||||
for (const key of keysToCheck) {
|
||||
if (this[key] && cleanStringForSearch(String(this[key])).includes(query)) {
|
||||
return {
|
||||
matchKey: key,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue