mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-06-02 00:40:39 +02:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ca12eee19 | |||
| ebdf377fc1 | |||
| 808d23561c | |||
| a34813b3ab |
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "audiobookshelf-client",
|
"name": "audiobookshelf-client",
|
||||||
"version": "2.19.1",
|
"version": "2.19.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "audiobookshelf-client",
|
"name": "audiobookshelf-client",
|
||||||
"version": "2.19.1",
|
"version": "2.19.2",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nuxtjs/axios": "^5.13.6",
|
"@nuxtjs/axios": "^5.13.6",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "audiobookshelf-client",
|
"name": "audiobookshelf-client",
|
||||||
"version": "2.19.1",
|
"version": "2.19.2",
|
||||||
"buildNumber": 1,
|
"buildNumber": 1,
|
||||||
"description": "Self-hosted audiobook and podcast client",
|
"description": "Self-hosted audiobook and podcast client",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "audiobookshelf",
|
"name": "audiobookshelf",
|
||||||
"version": "2.19.1",
|
"version": "2.19.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "audiobookshelf",
|
"name": "audiobookshelf",
|
||||||
"version": "2.19.1",
|
"version": "2.19.2",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.27.2",
|
"axios": "^0.27.2",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "audiobookshelf",
|
"name": "audiobookshelf",
|
||||||
"version": "2.19.1",
|
"version": "2.19.2",
|
||||||
"buildNumber": 1,
|
"buildNumber": 1,
|
||||||
"description": "Self-hosted audiobook and podcast server",
|
"description": "Self-hosted audiobook and podcast server",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const authorFilters = require('./authorFilters')
|
|||||||
|
|
||||||
const ShareManager = require('../../managers/ShareManager')
|
const ShareManager = require('../../managers/ShareManager')
|
||||||
const { profile } = require('../profiler')
|
const { profile } = require('../profiler')
|
||||||
|
const stringifySequelizeQuery = require('../stringifySequelizeQuery')
|
||||||
const countCache = new Map()
|
const countCache = new Map()
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@@ -345,7 +345,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async findAndCountAll(findOptions, limit, offset) {
|
async findAndCountAll(findOptions, limit, offset) {
|
||||||
const findOptionsKey = JSON.stringify(findOptions)
|
const findOptionsKey = stringifySequelizeQuery(findOptions)
|
||||||
Logger.debug(`[LibraryItemsBookFilters] findOptionsKey: ${findOptionsKey}`)
|
Logger.debug(`[LibraryItemsBookFilters] findOptionsKey: ${findOptionsKey}`)
|
||||||
|
|
||||||
findOptions.limit = limit || null
|
findOptions.limit = limit || null
|
||||||
@@ -353,6 +353,7 @@ module.exports = {
|
|||||||
|
|
||||||
if (countCache.has(findOptionsKey)) {
|
if (countCache.has(findOptionsKey)) {
|
||||||
const rows = await Database.bookModel.findAll(findOptions)
|
const rows = await Database.bookModel.findAll(findOptions)
|
||||||
|
|
||||||
return { rows, count: countCache.get(findOptionsKey) }
|
return { rows, count: countCache.get(findOptionsKey) }
|
||||||
} else {
|
} else {
|
||||||
const result = await Database.bookModel.findAndCountAll(findOptions)
|
const result = await Database.bookModel.findAndCountAll(findOptions)
|
||||||
@@ -580,9 +581,9 @@ module.exports = {
|
|||||||
// When collapsing series and sorting by title then use the series name instead of the book title
|
// When collapsing series and sorting by title then use the series name instead of the book title
|
||||||
// for this set an attribute "display_title" to use in sorting
|
// for this set an attribute "display_title" to use in sorting
|
||||||
if (global.ServerSettings.sortingIgnorePrefix) {
|
if (global.ServerSettings.sortingIgnorePrefix) {
|
||||||
bookAttributes.include.push([Sequelize.literal(`IFNULL((SELECT s.nameIgnorePrefix FROM bookSeries AS bs, series AS s WHERE bs.seriesId = s.id AND bs.bookId = book.id AND bs.id IN (${bookSeriesToInclude.map((v) => `"${v.id}"`).join(', ')})), titleIgnorePrefix)`), 'display_title'])
|
bookAttributes.include.push([Sequelize.literal(`IFNULL((SELECT s.nameIgnorePrefix FROM bookSeries AS bs, series AS s WHERE bs.seriesId = s.id AND bs.bookId = book.id AND bs.id IN (${bookSeriesToInclude.map((v) => `"${v.id}"`).join(', ')})), \`libraryItem\`.\`titleIgnorePrefix\`)`), 'display_title'])
|
||||||
} else {
|
} else {
|
||||||
bookAttributes.include.push([Sequelize.literal(`IFNULL((SELECT s.name FROM bookSeries AS bs, series AS s WHERE bs.seriesId = s.id AND bs.bookId = book.id AND bs.id IN (${bookSeriesToInclude.map((v) => `"${v.id}"`).join(', ')})), \`book\`.\`title\`)`), 'display_title'])
|
bookAttributes.include.push([Sequelize.literal(`IFNULL((SELECT s.name FROM bookSeries AS bs, series AS s WHERE bs.seriesId = s.id AND bs.bookId = book.id AND bs.id IN (${bookSeriesToInclude.map((v) => `"${v.id}"`).join(', ')})), \`libraryItem\`.\`title\`)`), 'display_title'])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1035,8 +1036,8 @@ module.exports = {
|
|||||||
|
|
||||||
const textSearchQuery = await Database.createTextSearchQuery(query)
|
const textSearchQuery = await Database.createTextSearchQuery(query)
|
||||||
|
|
||||||
const matchTitle = textSearchQuery.matchExpression('title')
|
const matchTitle = textSearchQuery.matchExpression('book.title')
|
||||||
const matchSubtitle = textSearchQuery.matchExpression('subtitle')
|
const matchSubtitle = textSearchQuery.matchExpression('book.subtitle')
|
||||||
|
|
||||||
// Search title, subtitle, asin, isbn
|
// Search title, subtitle, asin, isbn
|
||||||
const books = await Database.bookModel.findAll({
|
const books = await Database.bookModel.findAll({
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ module.exports = {
|
|||||||
return [[Sequelize.literal(`\`podcast\`.\`author\` COLLATE NOCASE ${nullDir}`)]]
|
return [[Sequelize.literal(`\`podcast\`.\`author\` COLLATE NOCASE ${nullDir}`)]]
|
||||||
} else if (sortBy === 'media.metadata.title') {
|
} else if (sortBy === 'media.metadata.title') {
|
||||||
if (global.ServerSettings.sortingIgnorePrefix) {
|
if (global.ServerSettings.sortingIgnorePrefix) {
|
||||||
return [[Sequelize.literal('titleIgnorePrefix COLLATE NOCASE'), dir]]
|
return [[Sequelize.literal('`podcast`.`titleIgnorePrefix` COLLATE NOCASE'), dir]]
|
||||||
} else {
|
} else {
|
||||||
return [[Sequelize.literal('`podcast`.`title` COLLATE NOCASE'), dir]]
|
return [[Sequelize.literal('`podcast`.`title` COLLATE NOCASE'), dir]]
|
||||||
}
|
}
|
||||||
@@ -321,8 +321,8 @@ module.exports = {
|
|||||||
|
|
||||||
const textSearchQuery = await Database.createTextSearchQuery(query)
|
const textSearchQuery = await Database.createTextSearchQuery(query)
|
||||||
|
|
||||||
const matchTitle = textSearchQuery.matchExpression('title')
|
const matchTitle = textSearchQuery.matchExpression('podcast.title')
|
||||||
const matchAuthor = textSearchQuery.matchExpression('author')
|
const matchAuthor = textSearchQuery.matchExpression('podcast.author')
|
||||||
|
|
||||||
// Search title, author, itunesId, itunesArtistId
|
// Search title, author, itunesId, itunesArtistId
|
||||||
const podcasts = await Database.podcastModel.findAll({
|
const podcasts = await Database.podcastModel.findAll({
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
function stringifySequelizeQuery(findOptions) {
|
||||||
|
// Helper function to handle symbols in nested objects
|
||||||
|
function handleSymbols(obj) {
|
||||||
|
if (!obj || typeof obj !== 'object') return obj
|
||||||
|
|
||||||
|
if (Array.isArray(obj)) {
|
||||||
|
return obj.map(handleSymbols)
|
||||||
|
}
|
||||||
|
|
||||||
|
const newObj = {}
|
||||||
|
for (const [key, value] of Object.entries(obj)) {
|
||||||
|
// Handle Symbol keys from Object.getOwnPropertySymbols
|
||||||
|
Object.getOwnPropertySymbols(obj).forEach((sym) => {
|
||||||
|
newObj[`__Op.${sym.toString()}`] = handleSymbols(obj[sym])
|
||||||
|
})
|
||||||
|
|
||||||
|
// Handle regular keys
|
||||||
|
if (typeof key === 'string') {
|
||||||
|
if (value && typeof value === 'object' && Object.getPrototypeOf(value) === Symbol.prototype) {
|
||||||
|
// Handle Symbol values
|
||||||
|
newObj[key] = `__Op.${value.toString()}`
|
||||||
|
} else {
|
||||||
|
// Recursively handle nested objects
|
||||||
|
newObj[key] = handleSymbols(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newObj
|
||||||
|
}
|
||||||
|
|
||||||
|
const sanitizedOptions = handleSymbols(findOptions)
|
||||||
|
return JSON.stringify(sanitizedOptions)
|
||||||
|
}
|
||||||
|
module.exports = stringifySequelizeQuery
|
||||||
Reference in New Issue
Block a user