parent
1e14eb5b6b
commit
504b7e06b5
@ -5,12 +5,113 @@ import { sessionDZ } from '../../../app'
|
|||||||
|
|
||||||
const path: ApiHandler['path'] = '/mainSearch'
|
const path: ApiHandler['path'] = '/mainSearch'
|
||||||
|
|
||||||
|
const emptyResult = {
|
||||||
|
QUERY: '',
|
||||||
|
FUZZINNESS: true,
|
||||||
|
AUTOCORRECT: false,
|
||||||
|
ORDER: ['TOP_RESULT', 'TRACK', 'ARTIST', 'ALBUM', 'PLAYLIST'],
|
||||||
|
TOP_RESULT: [],
|
||||||
|
ARTIST: {
|
||||||
|
data: [],
|
||||||
|
count: 0,
|
||||||
|
total: 0,
|
||||||
|
filtered_count: 0,
|
||||||
|
filtered_items: [],
|
||||||
|
next: 20
|
||||||
|
},
|
||||||
|
ALBUM: {
|
||||||
|
data: [],
|
||||||
|
count: 0,
|
||||||
|
total: 0,
|
||||||
|
filtered_count: 0,
|
||||||
|
filtered_items: [],
|
||||||
|
next: 20
|
||||||
|
},
|
||||||
|
TRACK: {
|
||||||
|
data: [],
|
||||||
|
count: 0,
|
||||||
|
total: 0,
|
||||||
|
filtered_count: 0,
|
||||||
|
filtered_items: [],
|
||||||
|
next: 10
|
||||||
|
},
|
||||||
|
PLAYLIST: {
|
||||||
|
data: [],
|
||||||
|
count: 0,
|
||||||
|
total: 0,
|
||||||
|
filtered_count: 0,
|
||||||
|
filtered_items: [],
|
||||||
|
next: 20
|
||||||
|
},
|
||||||
|
RADIO: {
|
||||||
|
data: [],
|
||||||
|
count: 0,
|
||||||
|
total: 0,
|
||||||
|
filtered_count: 0,
|
||||||
|
filtered_items: [],
|
||||||
|
next: 20
|
||||||
|
},
|
||||||
|
USER: {
|
||||||
|
data: [],
|
||||||
|
count: 0,
|
||||||
|
total: 0,
|
||||||
|
filtered_count: 0,
|
||||||
|
filtered_items: [],
|
||||||
|
next: 20
|
||||||
|
},
|
||||||
|
SHOW: {
|
||||||
|
data: [],
|
||||||
|
count: 0,
|
||||||
|
total: 0,
|
||||||
|
filtered_count: 0,
|
||||||
|
filtered_items: [],
|
||||||
|
next: 20
|
||||||
|
},
|
||||||
|
CHANNEL: {
|
||||||
|
data: [],
|
||||||
|
count: 0,
|
||||||
|
total: 0
|
||||||
|
},
|
||||||
|
LIVESTREAM: {
|
||||||
|
data: [],
|
||||||
|
count: 0,
|
||||||
|
total: 0,
|
||||||
|
filtered_count: 0,
|
||||||
|
filtered_items: [],
|
||||||
|
next: 20
|
||||||
|
},
|
||||||
|
EPISODE: {
|
||||||
|
data: [],
|
||||||
|
count: 0,
|
||||||
|
total: 0,
|
||||||
|
filtered_count: 0,
|
||||||
|
filtered_items: [],
|
||||||
|
next: 20
|
||||||
|
},
|
||||||
|
LYRICS: {
|
||||||
|
data: [],
|
||||||
|
count: 0,
|
||||||
|
total: 0,
|
||||||
|
filtered_count: 0,
|
||||||
|
filtered_items: [],
|
||||||
|
next: 20
|
||||||
|
},
|
||||||
|
ERROR: ''
|
||||||
|
}
|
||||||
|
|
||||||
const handler: ApiHandler['handler'] = async (req, res) => {
|
const handler: ApiHandler['handler'] = async (req, res) => {
|
||||||
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
||||||
const dz = sessionDZ[req.session.id]
|
const dz = sessionDZ[req.session.id]
|
||||||
|
|
||||||
const term = String(req.query.term)
|
const term = String(req.query.term)
|
||||||
const results = await dz.gw.search(term)
|
let results
|
||||||
|
try {
|
||||||
|
results = await dz.gw.search(term)
|
||||||
|
} catch (e) {
|
||||||
|
results = { ...emptyResult }
|
||||||
|
results.QUERY = term
|
||||||
|
results.ERROR = e.message
|
||||||
|
}
|
||||||
const order: string[] = []
|
const order: string[] = []
|
||||||
results.ORDER.forEach((element: string) => {
|
results.ORDER.forEach((element: string) => {
|
||||||
if (['TOP_RESULT', 'TRACK', 'ALBUM', 'ARTIST', 'PLAYLIST'].includes(element)) order.push(element)
|
if (['TOP_RESULT', 'TRACK', 'ALBUM', 'ARTIST', 'PLAYLIST'].includes(element)) order.push(element)
|
||||||
|
@ -5,6 +5,13 @@ import { sessionDZ } from '../../../app'
|
|||||||
|
|
||||||
const path: ApiHandler['path'] = '/search'
|
const path: ApiHandler['path'] = '/search'
|
||||||
|
|
||||||
|
const emptyResult = {
|
||||||
|
data: [],
|
||||||
|
total: 0,
|
||||||
|
type: '',
|
||||||
|
error: ''
|
||||||
|
}
|
||||||
|
|
||||||
const handler: ApiHandler['handler'] = async (req, res) => {
|
const handler: ApiHandler['handler'] = async (req, res) => {
|
||||||
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
||||||
const dz = sessionDZ[req.session.id]
|
const dz = sessionDZ[req.session.id]
|
||||||
@ -16,28 +23,33 @@ const handler: ApiHandler['handler'] = async (req, res) => {
|
|||||||
|
|
||||||
let data
|
let data
|
||||||
|
|
||||||
switch (type) {
|
try {
|
||||||
case 'track':
|
switch (type) {
|
||||||
data = await dz.api.search_track(term, { limit: nb, index: start })
|
case 'track':
|
||||||
break
|
data = await dz.api.search_track(term, { limit: nb, index: start })
|
||||||
case 'album':
|
break
|
||||||
data = await dz.api.search_album(term, { limit: nb, index: start })
|
case 'album':
|
||||||
break
|
data = await dz.api.search_album(term, { limit: nb, index: start })
|
||||||
case 'artist':
|
break
|
||||||
data = await dz.api.search_artist(term, { limit: nb, index: start })
|
case 'artist':
|
||||||
break
|
data = await dz.api.search_artist(term, { limit: nb, index: start })
|
||||||
case 'playlist':
|
break
|
||||||
data = await dz.api.search_playlist(term, { limit: nb, index: start })
|
case 'playlist':
|
||||||
break
|
data = await dz.api.search_playlist(term, { limit: nb, index: start })
|
||||||
case 'radio':
|
break
|
||||||
data = await dz.api.search_radio(term, { limit: nb, index: start })
|
case 'radio':
|
||||||
break
|
data = await dz.api.search_radio(term, { limit: nb, index: start })
|
||||||
case 'user':
|
break
|
||||||
data = await dz.api.search_user(term, { limit: nb, index: start })
|
case 'user':
|
||||||
break
|
data = await dz.api.search_user(term, { limit: nb, index: start })
|
||||||
default:
|
break
|
||||||
data = await dz.api.search(term, { limit: nb, index: start })
|
default:
|
||||||
break
|
data = await dz.api.search(term, { limit: nb, index: start })
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
data = { ...emptyResult }
|
||||||
|
data.error = e.message
|
||||||
}
|
}
|
||||||
|
|
||||||
data.type = type
|
data.type = type
|
||||||
|
2
webui
2
webui
@ -1 +1 @@
|
|||||||
Subproject commit 036329432597bc5211926a9c527b4448a4080efe
|
Subproject commit 79ab849df0ac4183c48d3916effe7ebf5b1b4f46
|
Loading…
Reference in New Issue
Block a user