fix(Genius For Lyrics): Fix Genius For Lyrics Not Loading
This commit is contained in:
parent
baf13606e8
commit
d50f4f7223
1 changed files with 5 additions and 9 deletions
14
js/lyrics.js
14
js/lyrics.js
|
|
@ -36,12 +36,10 @@ class GeniusManager {
|
||||||
async searchTrack(title, artist) {
|
async searchTrack(title, artist) {
|
||||||
const cleanTitle = title.split('(')[0].split('-')[0].trim();
|
const cleanTitle = title.split('(')[0].split('-')[0].trim();
|
||||||
const query = encodeURIComponent(`${cleanTitle} ${artist}`);
|
const query = encodeURIComponent(`${cleanTitle} ${artist}`);
|
||||||
|
|
||||||
const url = `https://api.genius.com/search?q=${query}`;
|
|
||||||
const token = this.getToken();
|
const token = this.getToken();
|
||||||
const response = await fetch(`https://corsproxy.io/?${encodeURIComponent(url)}`, {
|
|
||||||
headers: { Authorization: `Bearer ${token}` },
|
const url = `https://api.genius.com/search?q=${query}&access_token=${token}`;
|
||||||
});
|
const response = await fetch(`https://api.allorigins.win/raw?url=${encodeURIComponent(url)}`);
|
||||||
|
|
||||||
if (!response.ok) throw new Error('Failed to search Genius');
|
if (!response.ok) throw new Error('Failed to search Genius');
|
||||||
|
|
||||||
|
|
@ -61,10 +59,8 @@ class GeniusManager {
|
||||||
|
|
||||||
async getReferents(songId) {
|
async getReferents(songId) {
|
||||||
const token = this.getToken();
|
const token = this.getToken();
|
||||||
const url = `https://api.genius.com/referents?song_id=${songId}&text_format=plain&per_page=50`;
|
const url = `https://api.genius.com/referents?song_id=${songId}&text_format=plain&per_page=50&access_token=${token}`;
|
||||||
const response = await fetch(`https://corsproxy.io/?${encodeURIComponent(url)}`, {
|
const response = await fetch(`https://api.allorigins.win/raw?url=${encodeURIComponent(url)}`);
|
||||||
headers: { Authorization: `Bearer ${token}` },
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) throw new Error('Failed to fetch annotations');
|
if (!response.ok) throw new Error('Failed to fetch annotations');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue