mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-09 06:33:05 -04:00
update to omnilyrics
This commit is contained in:
parent
197e776f03
commit
5c13db8f62
3 changed files with 64 additions and 12 deletions
|
@ -23,6 +23,35 @@ function renderMetadata(metadata){
|
|||
return pills.join(' ')
|
||||
}
|
||||
|
||||
// These have to be synced with the backend (search_service/endpoints/lyrics).
|
||||
const LYRIC_PROVIDERS = {
|
||||
UNKNOWN_PROVIDER: 0,
|
||||
MUSIXMATCH: 1,
|
||||
GENIUS: 2
|
||||
}
|
||||
|
||||
function renderLyricsFooter(context, provider){
|
||||
switch(provider){
|
||||
case LYRIC_PROVIDERS.MUSIXMATCH:
|
||||
return {
|
||||
text: `Musixmatch • ${context.application.name}`,
|
||||
iconUrl: STATICS.musixmatch
|
||||
}
|
||||
break;
|
||||
case LYRIC_PROVIDERS.GENIUS:
|
||||
return {
|
||||
text: `Genius • ${context.application.name}`,
|
||||
iconUrl: STATICS.genius
|
||||
}
|
||||
break;
|
||||
default: // Fallback, this should never happen
|
||||
return {
|
||||
text: context.application.name,
|
||||
iconUrl: STATICS.labscore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createLyricsPage(context, search, fields){
|
||||
let em = createEmbed("default", context, {
|
||||
author: {
|
||||
|
@ -30,10 +59,7 @@ function createLyricsPage(context, search, fields){
|
|||
name: `${search.body.track.title} by ${search.body.track.artist}`
|
||||
},
|
||||
fields: fields,
|
||||
footer: {
|
||||
iconUrl: STATICS.musixmatch,
|
||||
text: `Musixmatch • ${context.application.name}`
|
||||
}
|
||||
footer: renderLyricsFooter(context, search.body.lyrics_provider)
|
||||
})
|
||||
if(search.body.track.cover) em.thumbnail = { url: search.body.track.cover }
|
||||
if(search.body.track.metadata.length) em.description = renderMetadata(search.body.track.metadata)
|
||||
|
@ -79,7 +105,7 @@ module.exports = {
|
|||
for(const f of search.body.lyrics.split('\n\n')){
|
||||
fields.push({
|
||||
name: '',
|
||||
value: f.substr(0,1024),
|
||||
value: f.substr(0,1024).replace(/\[(.*?)\]/g,"-# [$1]"),
|
||||
inline: false
|
||||
})
|
||||
}
|
||||
|
|
|
@ -23,6 +23,35 @@ function renderMetadata(metadata){
|
|||
return pills.join(' ')
|
||||
}
|
||||
|
||||
// These have to be synced with the backend (search_service/endpoints/lyrics).
|
||||
const LYRIC_PROVIDERS = {
|
||||
UNKNOWN_PROVIDER: 0,
|
||||
MUSIXMATCH: 1,
|
||||
GENIUS: 2
|
||||
}
|
||||
|
||||
function renderLyricsFooter(context, provider){
|
||||
switch(provider){
|
||||
case LYRIC_PROVIDERS.MUSIXMATCH:
|
||||
return {
|
||||
text: `Musixmatch • ${context.application.name}`,
|
||||
iconUrl: STATICS.musixmatch
|
||||
}
|
||||
break;
|
||||
case LYRIC_PROVIDERS.GENIUS:
|
||||
return {
|
||||
text: `Genius • ${context.application.name}`,
|
||||
iconUrl: STATICS.genius
|
||||
}
|
||||
break;
|
||||
default: // Fallback, this should never happen
|
||||
return {
|
||||
text: context.application.name,
|
||||
iconUrl: STATICS.labscore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createLyricsPage(context, search, fields){
|
||||
let em = createEmbed("default", context, {
|
||||
author: {
|
||||
|
@ -30,10 +59,7 @@ function createLyricsPage(context, search, fields){
|
|||
name: `${search.body.track.title} by ${search.body.track.artist}`
|
||||
},
|
||||
fields: fields,
|
||||
footer: {
|
||||
iconUrl: STATICS.musixmatch,
|
||||
text: `Musixmatch • ${context.application.name}`
|
||||
}
|
||||
footer: renderLyricsFooter(context, search.body.lyrics_provider)
|
||||
})
|
||||
if(search.body.track.cover) em.thumbnail = { url: search.body.track.cover }
|
||||
if(search.body.track.metadata.length) em.description = renderMetadata(search.body.track.metadata)
|
||||
|
@ -65,7 +91,7 @@ module.exports = {
|
|||
for(const f of search.body.lyrics.split('\n\n')){
|
||||
fields.push({
|
||||
name: '',
|
||||
value: f,
|
||||
value: f.substr(0,1024).replace(/\[(.*?)\]/g,"-# [$1]"),
|
||||
inline: false
|
||||
})
|
||||
}
|
||||
|
@ -89,7 +115,7 @@ module.exports = {
|
|||
});
|
||||
}catch(e){
|
||||
if(e.response?.body?.status && e.response.body.status == 2 && e.response.body.message) return editOrReply(context, createEmbed("error", context, e.response.body.message))
|
||||
console.log(JSON.stringify(e.raw))
|
||||
console.log(JSON.stringify(e.raw) || e)
|
||||
return editOrReply(context, createEmbed("error", context, `Something went wrong.`))
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue