HerzaJ commited on
Commit
791bd63
·
verified ·
1 Parent(s): 1a48491

Update plugins/lyrics.js

Browse files
Files changed (1) hide show
  1. 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 songsPanel = $('.panel').find('td.text-left')
27
- if (songsPanel.length > 0) {
28
- const firstResult = songsPanel.first()
29
  const link = firstResult.find('a').first()
30
  if (link.length && link.attr('href')) {
31
  songLink = link.attr('href')
32
- const parts = firstResult.text().split('"')
33
- if (parts.length >= 2) {
34
- title = parts[1]
35
- artist = parts[0].trim().replace(/\s+/g, ' ')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
  }