mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-21 02:08:34 +02:00
Add fuse.basic.min.js in libs instead of full npm package, use lower threshold for quick matching
This commit is contained in:
parent
eda7036f70
commit
6d0d1415e4
9
package-lock.json
generated
9
package-lock.json
generated
@ -13,7 +13,6 @@
|
|||||||
"cookie-parser": "^1.4.6",
|
"cookie-parser": "^1.4.6",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"express-session": "^1.17.3",
|
"express-session": "^1.17.3",
|
||||||
"fuse.js": "^7.1.0",
|
|
||||||
"graceful-fs": "^4.2.10",
|
"graceful-fs": "^4.2.10",
|
||||||
"htmlparser2": "^8.0.1",
|
"htmlparser2": "^8.0.1",
|
||||||
"lru-cache": "^10.0.3",
|
"lru-cache": "^10.0.3",
|
||||||
@ -2106,14 +2105,6 @@
|
|||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/fuse.js": {
|
|
||||||
"version": "7.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-7.1.0.tgz",
|
|
||||||
"integrity": "sha512-trLf4SzuuUxfusZADLINj+dE8clK1frKdmqiJNb1Es75fmI5oY6X2mxLVUciLLjxqw/xr72Dhy+lER6dGd02FQ==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/gensync": {
|
"node_modules/gensync": {
|
||||||
"version": "1.0.0-beta.2",
|
"version": "1.0.0-beta.2",
|
||||||
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz",
|
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz",
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
"cookie-parser": "^1.4.6",
|
"cookie-parser": "^1.4.6",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"express-session": "^1.17.3",
|
"express-session": "^1.17.3",
|
||||||
"fuse.js": "^7.1.0",
|
|
||||||
"graceful-fs": "^4.2.10",
|
"graceful-fs": "^4.2.10",
|
||||||
"htmlparser2": "^8.0.1",
|
"htmlparser2": "^8.0.1",
|
||||||
"lru-cache": "^10.0.3",
|
"lru-cache": "^10.0.3",
|
||||||
|
13
server/libs/fusejs/index.js
Normal file
13
server/libs/fusejs/index.js
Normal file
File diff suppressed because one or more lines are too long
@ -370,7 +370,7 @@ class Scanner {
|
|||||||
|
|
||||||
let numEpisodesUpdated = 0
|
let numEpisodesUpdated = 0
|
||||||
for (const episode of episodesToQuickMatch) {
|
for (const episode of episodesToQuickMatch) {
|
||||||
const episodeMatches = findMatchingEpisodesInFeed(feed, episode.title)
|
const episodeMatches = findMatchingEpisodesInFeed(feed, episode.title, 0.1)
|
||||||
if (episodeMatches?.length) {
|
if (episodeMatches?.length) {
|
||||||
const wasUpdated = await this.updateEpisodeWithMatch(episode, episodeMatches[0].episode, options)
|
const wasUpdated = await this.updateEpisodeWithMatch(episode, episodeMatches[0].episode, options)
|
||||||
if (wasUpdated) numEpisodesUpdated++
|
if (wasUpdated) numEpisodesUpdated++
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
const ssrfFilter = require('ssrf-req-filter')
|
const ssrfFilter = require('ssrf-req-filter')
|
||||||
const Logger = require('../Logger')
|
const Logger = require('../Logger')
|
||||||
const { xmlToJSON, levenshteinDistance, timestampToSeconds } = require('./index')
|
const { xmlToJSON, timestampToSeconds } = require('./index')
|
||||||
const htmlSanitizer = require('../utils/htmlSanitizer')
|
const htmlSanitizer = require('../utils/htmlSanitizer')
|
||||||
const Fuse = require('fuse.js')
|
const Fuse = require('../libs/fusejs')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef RssPodcastChapter
|
* @typedef RssPodcastChapter
|
||||||
@ -421,19 +421,20 @@ module.exports.findMatchingEpisodes = async (feedUrl, searchTitle) => {
|
|||||||
*
|
*
|
||||||
* @param {RssPodcast} feed
|
* @param {RssPodcast} feed
|
||||||
* @param {string} searchTitle
|
* @param {string} searchTitle
|
||||||
|
* @param {number} [threshold=0.4] - 0.0 for perfect match, 1.0 for match anything
|
||||||
* @returns {Array<{ episode: RssPodcastEpisode }>}
|
* @returns {Array<{ episode: RssPodcastEpisode }>}
|
||||||
*/
|
*/
|
||||||
module.exports.findMatchingEpisodesInFeed = (feed, searchTitle) => {
|
module.exports.findMatchingEpisodesInFeed = (feed, searchTitle, threshold = 0.4) => {
|
||||||
if (!feed?.episodes) {
|
if (!feed?.episodes) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const fuseOptions = {
|
const fuseOptions = {
|
||||||
ignoreDiacritics: true,
|
ignoreDiacritics: true,
|
||||||
threshold: 0.4, // default 0.6 return too many matches
|
threshold,
|
||||||
keys: [
|
keys: [
|
||||||
{name: 'title', weight: 0.7}, // prefer match in title
|
{ name: 'title', weight: 0.7 }, // prefer match in title
|
||||||
{name: 'subtitle', weight: 0.3}
|
{ name: 'subtitle', weight: 0.3 }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
const fuse = new Fuse(feed.episodes, fuseOptions)
|
const fuse = new Fuse(feed.episodes, fuseOptions)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user