mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
Allow any utf-8 char in genre and tags, fix stream manager user undefined
This commit is contained in:
parent
d2a2f3ff6a
commit
e534d015be
@ -121,7 +121,6 @@ export default {
|
|||||||
return _sel.text
|
return _sel.text
|
||||||
},
|
},
|
||||||
genres() {
|
genres() {
|
||||||
// return this.$store.state.audiobooks.genres
|
|
||||||
return this.$store.getters['audiobooks/getGenresUsed']
|
return this.$store.getters['audiobooks/getGenresUsed']
|
||||||
},
|
},
|
||||||
tags() {
|
tags() {
|
||||||
|
@ -75,7 +75,6 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return this.items.filter((i) => {
|
return this.items.filter((i) => {
|
||||||
// var normie = this.$snakeToNormal(i)
|
|
||||||
var iValue = String(i).toLowerCase()
|
var iValue = String(i).toLowerCase()
|
||||||
return iValue.includes(this.currentSearch.toLowerCase())
|
return iValue.includes(this.currentSearch.toLowerCase())
|
||||||
})
|
})
|
||||||
@ -170,7 +169,6 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
insertNewItem(item) {
|
insertNewItem(item) {
|
||||||
// var kebabItem = this.$normalToSnake(item)
|
|
||||||
this.selected.push(item)
|
this.selected.push(item)
|
||||||
this.$emit('input', this.selected)
|
this.$emit('input', this.selected)
|
||||||
this.textInput = null
|
this.textInput = null
|
||||||
@ -183,7 +181,6 @@ export default {
|
|||||||
if (!this.textInput) return
|
if (!this.textInput) return
|
||||||
|
|
||||||
var cleaned = this.textInput.toLowerCase().trim()
|
var cleaned = this.textInput.toLowerCase().trim()
|
||||||
// var cleanedKebab = this.$normalToSnake(cleaned)
|
|
||||||
var matchesItem = this.items.find((i) => {
|
var matchesItem = this.items.find((i) => {
|
||||||
return i === cleaned
|
return i === cleaned
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "audiobookshelf-client",
|
"name": "audiobookshelf-client",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"description": "Audiobook manager and player",
|
"description": "Audiobook manager and player",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -38,105 +38,13 @@ Vue.prototype.$secondsToTimestamp = (seconds) => {
|
|||||||
return `${_hours}:${_minutes.toString().padStart(2, '0')}:${_seconds.toString().padStart(2, '0')}`
|
return `${_hours}:${_minutes.toString().padStart(2, '0')}:${_seconds.toString().padStart(2, '0')}`
|
||||||
}
|
}
|
||||||
|
|
||||||
Vue.prototype.$snakeToNormal = (snake) => {
|
|
||||||
if (!snake) {
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
return String(snake)
|
|
||||||
.split('_')
|
|
||||||
.map((t) => t.slice(0, 1).toUpperCase() + t.slice(1))
|
|
||||||
.join(' ')
|
|
||||||
}
|
|
||||||
|
|
||||||
Vue.prototype.$normalToSnake = (normie) => {
|
|
||||||
if (!normie) return ''
|
|
||||||
return normie
|
|
||||||
.trim()
|
|
||||||
.split(' ')
|
|
||||||
.map((t) => t.toLowerCase())
|
|
||||||
.join('_')
|
|
||||||
}
|
|
||||||
|
|
||||||
const encode = (text) => encodeURIComponent(Buffer.from(text).toString('base64'))
|
|
||||||
Vue.prototype.$encode = encode
|
|
||||||
const decode = (text) => Buffer.from(decodeURIComponent(text), 'base64').toString()
|
|
||||||
Vue.prototype.$decode = decode
|
|
||||||
|
|
||||||
const availableChars = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
|
|
||||||
const getCharCode = (char) => availableChars.indexOf(char)
|
|
||||||
const getCharFromCode = (code) => availableChars[Number(code)] || -1
|
|
||||||
const cleanChar = (char) => getCharCode(char) < 0 ? '?' : char
|
|
||||||
|
|
||||||
Vue.prototype.$cleanString = (str) => {
|
Vue.prototype.$cleanString = (str) => {
|
||||||
if (!str) return ''
|
if (!str) return ''
|
||||||
|
|
||||||
|
// No longer necessary to replace accented chars, full utf-8 charset is supported
|
||||||
// replace accented characters: https://stackoverflow.com/a/49901740/7431543
|
// replace accented characters: https://stackoverflow.com/a/49901740/7431543
|
||||||
str = str.normalize('NFD').replace(/[\u0300-\u036f]/g, "")
|
// str = str.normalize('NFD').replace(/[\u0300-\u036f]/g, "")
|
||||||
|
return str.trim()
|
||||||
var cleaned = ''
|
|
||||||
for (let i = 0; i < str.length; i++) {
|
|
||||||
cleaned += cleanChar(str[i])
|
|
||||||
}
|
|
||||||
return cleaned
|
|
||||||
}
|
|
||||||
|
|
||||||
Vue.prototype.$stringToCode = (str) => {
|
|
||||||
if (!str) return ''
|
|
||||||
var numcode = [...str].map(s => {
|
|
||||||
return String(getCharCode(s)).padStart(2, '0')
|
|
||||||
}).join('')
|
|
||||||
return BigInt(numcode).toString(36)
|
|
||||||
}
|
|
||||||
|
|
||||||
Vue.prototype.$codeToString = (code) => {
|
|
||||||
if (!code) return ''
|
|
||||||
var numcode = ''
|
|
||||||
try {
|
|
||||||
numcode = [...code].reduce((acc, curr) => {
|
|
||||||
return BigInt(parseInt(curr, 36)) + BigInt(36) * acc
|
|
||||||
}, 0n)
|
|
||||||
} catch (err) {
|
|
||||||
console.error('numcode fialed', code, err)
|
|
||||||
}
|
|
||||||
var numcodestr = String(numcode)
|
|
||||||
|
|
||||||
var remainder = numcodestr.length % 2
|
|
||||||
numcodestr = numcodestr.padStart(numcodestr.length - 1 + remainder, '0')
|
|
||||||
|
|
||||||
var finalform = ''
|
|
||||||
var numChunks = Math.floor(numcodestr.length / 2)
|
|
||||||
var remaining = numcodestr
|
|
||||||
for (let i = 0; i < numChunks; i++) {
|
|
||||||
var chunk = remaining.slice(0, 2)
|
|
||||||
remaining = remaining.slice(2)
|
|
||||||
finalform += getCharFromCode(chunk)
|
|
||||||
}
|
|
||||||
return finalform
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadImageBlob(uri) {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
const img = document.createElement('img')
|
|
||||||
const c = document.createElement('canvas')
|
|
||||||
const ctx = c.getContext('2d')
|
|
||||||
img.onload = ({ target }) => {
|
|
||||||
c.width = target.naturalWidth
|
|
||||||
c.height = target.naturalHeight
|
|
||||||
ctx.drawImage(target, 0, 0)
|
|
||||||
c.toBlob((b) => resolve(b), 'image/jpeg', 0.75)
|
|
||||||
}
|
|
||||||
img.crossOrigin = ''
|
|
||||||
img.src = uri
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
Vue.prototype.$downloadImage = async (uri, name) => {
|
|
||||||
var blob = await loadImageBlob(uri)
|
|
||||||
const a = document.createElement('a')
|
|
||||||
a.href = URL.createObjectURL(blob)
|
|
||||||
a.target = '_blank'
|
|
||||||
a.download = name || 'fotosho-image'
|
|
||||||
a.click()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isClickedOutsideEl(clickEvent, elToCheckOutside, ignoreSelectors = [], ignoreElems = []) {
|
function isClickedOutsideEl(clickEvent, elToCheckOutside, ignoreSelectors = [], ignoreElems = []) {
|
||||||
@ -195,6 +103,11 @@ Vue.prototype.$sanitizeFilename = (input, replacement = '') => {
|
|||||||
return sanitized
|
return sanitized
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const encode = (text) => encodeURIComponent(Buffer.from(text).toString('base64'))
|
||||||
|
Vue.prototype.$encode = encode
|
||||||
|
const decode = (text) => Buffer.from(decodeURIComponent(text), 'base64').toString()
|
||||||
|
Vue.prototype.$decode = decode
|
||||||
|
|
||||||
export {
|
export {
|
||||||
encode,
|
encode,
|
||||||
decode
|
decode
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "audiobookshelf",
|
"name": "audiobookshelf",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"description": "Self-hosted audiobook server for managing and playing audiobooks.",
|
"description": "Self-hosted audiobook server for managing and playing audiobooks.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -122,7 +122,7 @@ class StreamManager {
|
|||||||
streamUpdate(socket, { currentTime, streamId }) {
|
streamUpdate(socket, { currentTime, streamId }) {
|
||||||
var client = socket.sheepClient
|
var client = socket.sheepClient
|
||||||
if (!client || !client.stream) {
|
if (!client || !client.stream) {
|
||||||
Logger.error('No stream for client', client.user.id)
|
Logger.error('No stream for client', (client && client.user) ? client.user.id : 'No Client')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (client.stream.id !== streamId) {
|
if (client.stream.id !== streamId) {
|
||||||
|
Loading…
Reference in New Issue
Block a user