Giter Site home page Giter Site logo

genius-lyrics-api's People

Contributors

axiver avatar dastormer avatar dependabot[bot] avatar farshed avatar simeon-byte avatar tweak4141 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

genius-lyrics-api's Issues

Can't fetch lyrics

Hey I'm recieving a very big error with status code 403. It was working fine on repl.it but the moment I hosted it on my Azure Vps it is throwing errors with status code 403

Implementing entirely on front end

Hi, I'm wondering if you have an example of how this can be implemented entirely on the front end. I'm reasonably familiar with front end js but Node not so much. I'm not sure what needs to be done to the existing code to make that kind of implementation work. Thanks!

Confused about the implementation

Hey there, I got a question about the way this tool is implemented: Why do I need an API token? From the looks of it, you're scraping the lyrics directly from the official webpage anyway. Wouldn't it make more sense to fetch lyrics through Genius' API?

getLyrics() returns an empty array

Issue

The getLyrics() method returns an empty array instead of null for certain songs.

Steps to reproduce

Set these as the options for search:

{ apiKey: 'APIKEY', title: 'DESPACITO', artist: 'LUIS%20FONSI%20FT.%20JUSTIN%20BIEBER', optimizeQuery: true }

Details

getLyrics() works for many other songs that I try, including the example song shown in the readme. So far, this is the only song that has gone through the method to have returned an empty array instead of a string or a null value.

Getting a weird page from law.justia.com instead of lyrics

When trying to fetch the lyrics for the song "I Killed A Man (Live in Moscow)" by the artist "Slaughter To Prevail",
somehow i get the contents of this page.

Code:
const options = {
apiKey: Bun.env.CLIENT_ACCESS_TOKEN,
title: "I Killed A Man (Live in Moscow)",
artist: "Slaughter To Prevail",
optimizeQuery: true,
};
const rawLyrics = await getLyrics(options);
console.log(rawLyrics);

It's very weird, any idea for how that's happening?

getSongById documentation incorrect

Hi, you work has really made life easier for me. Just wanted to let you know that there is a small error in the documentation.

Documentation states:
getSongById
Returns a promise that resolves to an array of type song.

In reality it returns a promise that resolves to an object of type song, not an array.

Keep getting a 401 error

Hi there

I tried implementing this solution. I am running my script locally and I keep running into a 401 error.
Here is the initial setup:

const geniusApi = require('genius-lyrics-api');

const apiConfig = {
    apiKey: 'KkzEtd3JSxlUu1iy-XXXXXXXXXXXXXXXXXXXXXXXXX-PNpwuSc9ufTQByjZ8Nrq85A',
    title: '',
    artist: '',
    optimizeQuery: true
};

And then I call it as follows:

function callLyricApi(songTitle, songArtist) {
    return new Promise(function (resolve, reject) {
        apiConfig.artist = songArtist;
        apiConfig.title = songTitle;
        //Call the remote API for lyrics
        geniusApi.getLyrics(apiConfig)
            .then((lyrics) => {
                resolve(lyrics);
            })
            .catch((err) => {
                console.error("Genius call failed", err);
                reject(err);
            })
    });
}

Do you possibly know why I keep getting 401 error doing it like this?

Method getLyrics() sometimes isn't returning all the lyrics

  • I have downloaded the latest v. of the genius-lyrics-api npm module.
  • I've got an explanation of the issue.

For a little tiny bit of context, I'm making a Discord bot, and wanted to add a lyrics command to its music system. That's how I found your module.
It's working pretty good, but I noticed something.
When I call the getLyrics() method, sometimes it'll return the entire lyrics, and sometimes just a chunk of it.
I made two pastebins with the two different outputs for a same song (K. Money - Come Outside).

Here is my code.

import * as Discord from "discord.js";
import { getLyrics } from "genius-lyrics-api";
import getArtistTitle from 'get-artist-title';
import * as dotenv from "dotenv";
dotenv.config();

// Music command

/**
 * Skips actual guild music.
 * @param {Discord.Client} Client the client
 * @param {Discord.Message} Message the message that contains the command name
 * @param {string[]} args the command args
 * @param {any} options some options
 */
export async function run(Client: Discord.Client, message: Discord.Message, args: string[], ops: any) {
    const accessToken = process.env.ACCESS_TOKEN;
    const queue: any = await ops.queue.get(message.guild.id);
    let songID;
    let songArtist, songTitle;

    async function retrieveArtistTitle() {
        [songArtist, songTitle] = await getArtistTitle(queue.songs[0].title, {
            defaultArtist: queue.songs[0].author.name
        });
    }

    await retrieveArtistTitle();

    const options = {
        apiKey: accessToken,
        title: songTitle,
        artist: songArtist,
        optimizeQuery: true
    };

    await gatherLyrics();

    async function gatherLyrics() {
        await getLyrics(options).then((lyrics) => {
            if (lyrics == null) {
                return message.channel.send(`No lyrics found for **${queue.songs[0].title}**.`);
            } else {
                const lyricsEmbedOne = new Discord.MessageEmbed()
                .setAuthor(message.author.username, message.author.avatarURL())
                .setDescription(lyrics.slice(0, lyrics.length / 2))
                .setColor("#80F906")
                .setFooter(`Lyrics (1) - ${Client.user.username}`, Client.user.avatarURL())
                message.channel.send(lyricsEmbedOne);

                const lyricsEmbedTwo = new Discord.MessageEmbed()
                .setAuthor(message.author.username, message.author.avatarURL())
                .setDescription(lyrics.slice(lyrics.length / 2, lyrics.length))
                .setColor("#80F906")
                .setFooter(`Lyrics (2) - ${Client.user.username}`, Client.user.avatarURL())
                message.channel.send(lyricsEmbedTwo);
            }
        });
    }

    if (!queue) {
        return message.channel.send("No song is currently playing.");
    }
}

Music system works like a charm, so that doesn't cause the problem. Other modules used in this code are also working fine - same for my Genius Developer Token.

Thank you for reading this issue.

getSongById 401 response

Get song by id gives me 401 response. I think it's because of this line ${url}${id}&access_token=${apiKey} instead of ${url}${id}?access_token=${apiKey}.

Throws a "UnhandledPromiseRejectionWarning: TypeError [ERR_UNESCAPED_CHARACTERS]" when trying to search for Chinese, Japanese, Hebrew, or Arabic lyrics

I tried to search for Chinese, Japanese, Hebrew, and Arabic lyrics, but when doing so, I get a UnhandledPromiseRejectionWarning: TypeError [ERR_UNESCAPED_CHARACTERS]: Request path contains unescaped characters.

Here's a log:

2020-06-28T06:47:53.331907+00:00 app[worker.1]: (node:23) UnhandledPromiseRejectionWarning: TypeError [ERR_UNESCAPED_CHARACTERS]: Request path contains unescaped characters

2020-06-28T06:47:53.331916+00:00 app[worker.1]:     at new ClientRequest (_http_client.js:151:13)

2020-06-28T06:47:53.331917+00:00 app[worker.1]:     at Object.request (https.js:310:10)

2020-06-28T06:47:53.331917+00:00 app[worker.1]:     at RedirectableRequest._performRequest (/app/node_modules/follow-redirects/index.js:169:24)

2020-06-28T06:47:53.331918+00:00 app[worker.1]:     at new RedirectableRequest (/app/node_modules/follow-redirects/index.js:66:8)

2020-06-28T06:47:53.331918+00:00 app[worker.1]:     at Object.wrappedProtocol.request (/app/node_modules/follow-redirects/index.js:307:14)

2020-06-28T06:47:53.331919+00:00 app[worker.1]:     at dispatchHttpRequest (/app/node_modules/genius-lyrics-api/node_modules/axios/lib/adapters/http.js:179:25)

2020-06-28T06:47:53.331919+00:00 app[worker.1]:     at new Promise (<anonymous>)

2020-06-28T06:47:53.331919+00:00 app[worker.1]:     at httpAdapter (/app/node_modules/genius-lyrics-api/node_modules/axios/lib/adapters/http.js:21:10)

2020-06-28T06:47:53.331920+00:00 app[worker.1]:     at dispatchRequest (/app/node_modules/genius-lyrics-api/node_modules/axios/lib/core/dispatchRequest.js:52:10)

2020-06-28T06:47:53.331920+00:00 app[worker.1]:     at runMicrotasks (<anonymous>)

2020-06-28T06:47:53.331920+00:00 app[worker.1]: (Use `node --trace-warnings ...` to show where the warning was created)

2020-06-28T06:47:53.331950+00:00 app[worker.1]: (node:23) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)

2020-06-28T06:47:53.331991+00:00 app[worker.1]: (node:23) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```

Error 403 (Captcha)

I got the same problem as one of the closed (and never solved) issues. Its working on my computer but when I push it to the server it only returns 403. Maybe its the reverse proxy that causes the issue. It returns html that contains some sort of captcha.

Code is quite simple:

const genius = require('genius-lyrics-api')

function getLyrics(title) {
	var searchOptions = {
		title: title,
		artist: " ",
		apiKey: "XXX",
		optimizeQuery: true
	}
	genius.getLyrics(searchOptions).then((lyrics) => {
		console.log(lyrics);
	});
}

Originally posted by @nicokimmel in #21 (comment)

The searchSong() method is not working properly with special characters.

Special characters present in a search query such as "&" are not properly encoded with the encodeURI() method present inside of the searchSong() method.

For example ;
the requested song : Safe & Sound by Taylor Swift
will return the song: It Ain't Safe by Skepta (Ft. A$AP Bari)

Possible fix:
Replace the method encoreURI() with encodeURIComponent(). This change will make the above example return the good song. However, I didn't do a large test sample to ensure the effectiveness of this change for different combinations of songs and special character like (&, ?, etc.)

CORS issue

Hey! Getting a Cross-Origin Request Blocked response from Genius on local host and on Netlify.

Is there an updated workaround for this?

Cheers!

Network Error (Access Control Checks) in production (not localhost)

Hey, first of all thanks for this cool api 😄 , it's a shame we can't get the lyrics directly from genius 😒

I'm getting this Network Error while accessing the api in production :
XMLHttpRequest cannot load http://api.genius.com/songs/3977187 due to access control checks.

I tested on a browser with disabled web security, and it still doesn't work BUT there is another error :
Mixed Content: The page at 'https://myapp.com/lyrics' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://api.genius.com/songs/333387'. This request has been blocked; the content must be served over HTTPS.

So I don't really know how to fix this...
Any ideas ?

Help to implement app [No issue]

Dear,
I'm a novice in all this, but reading I'm doing things.
I have a js app that gets the artist name and song name that plays on an online radio and stores them in currentArtist and currentSong variables
I want to combine your app to get the lyric.

this.refreshLyric = function (currentSong, currentArtist) {
		
		//testing API genius
		
		......
		
	}

Could you explain to me as a child what code should I put in my app so that it returns a lyrics variable with the lyrics of the song?
Best regards,
Juan

Please add support for optional genius api host address

I would like to use this library from browser.
In order to fight the CORS , improve performance and lower the load on actual API, I am setting up a CDN that will have the same domain name as my website but will redirect all calls to genius.com.

Is there a way to avoid CORS block error on deployed implementations?

Current Behavior

I have a React toy project which fetches current playback on Spotify and uses the song info to be put into the options parameter for getLyrics. I forked and modified the library where the access token is sent to the Genius API within the URL so the CORS block error won't happen on API requests.

However, I'm now facing the CORS block error on my Netlify deployment when the request is sent to a song lyric's page so I'm wondering if there's a way to solve this problem. Also, as can be seen in the image I also had modified the baseUrl in GetLyricsFromPath.js so that thingproxy is at front of the genius url, so it looks like below;

const baseUrl = 'https://thingproxy.freeboard.io/fetch/https://www.genius.com';

Both the original baseUrl and modified baseUrl returns a CORS error on my deployed web app, however with the modified baseUrl it works well on localhost.

In a nutshell,

  1. Using a proxy like thingproxy makes it work perfectly on localhost without using the Chrome disable web security flag method shown in the library readme, but not on production/deployment.
  2. Without using the proxy it only works on localhost when Chrome runs with the disable web security flag being used and does not work on deployment.

Steps to reproduce

Deploy build of React web app using the library with Netlify/Surge/etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.