Update plugins/lyrics.js
Browse files- plugins/lyrics.js +31 -7
plugins/lyrics.js
CHANGED
|
@@ -23,16 +23,40 @@ async function getLyrics(query) {
|
|
| 23 |
let title = ''
|
| 24 |
let artist = ''
|
| 25 |
|
| 26 |
-
const
|
| 27 |
-
if (
|
| 28 |
-
const firstResult =
|
| 29 |
const link = firstResult.find('a').first()
|
| 30 |
if (link.length && link.attr('href')) {
|
| 31 |
songLink = link.attr('href')
|
| 32 |
-
const
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
}
|
| 37 |
}
|
| 38 |
}
|
|
|
|
| 23 |
let title = ''
|
| 24 |
let artist = ''
|
| 25 |
|
| 26 |
+
const songResults = $('.table.table-condensed tbody tr')
|
| 27 |
+
if (songResults.length > 0) {
|
| 28 |
+
const firstResult = songResults.first()
|
| 29 |
const link = firstResult.find('a').first()
|
| 30 |
if (link.length && link.attr('href')) {
|
| 31 |
songLink = link.attr('href')
|
| 32 |
+
const linkText = link.text()
|
| 33 |
+
const resultText = firstResult.text()
|
| 34 |
+
|
| 35 |
+
if (linkText.includes('"')) {
|
| 36 |
+
const parts = linkText.split('"')
|
| 37 |
+
title = parts[1] || parts[0]
|
| 38 |
+
} else {
|
| 39 |
+
title = linkText
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
const artistMatch = resultText.match(/^(.*?)\s*"/)
|
| 43 |
+
if (artistMatch) {
|
| 44 |
+
artist = artistMatch[1].trim()
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
if (!songLink) {
|
| 50 |
+
const panelLinks = $('.panel a[href*="/lyrics/"]')
|
| 51 |
+
if (panelLinks.length > 0) {
|
| 52 |
+
const link = panelLinks.first()
|
| 53 |
+
songLink = link.attr('href')
|
| 54 |
+
const linkText = link.text()
|
| 55 |
+
if (linkText.includes('"')) {
|
| 56 |
+
const parts = linkText.split('"')
|
| 57 |
+
title = parts[1] || linkText
|
| 58 |
+
} else {
|
| 59 |
+
title = linkText
|
| 60 |
}
|
| 61 |
}
|
| 62 |
}
|