Giter Site home page Giter Site logo

zyrouge / node-genius-lyrics Goto Github PK

View Code? Open in Web Editor NEW
63.0 3.0 12.0 1.11 MB

Simple lyrics fetcher that uses Genius. Also has official API implementations.

Home Page: https://genius-lyrics.js.org

License: MIT License

TypeScript 94.18% JavaScript 5.82%
genius-lyrics genius lyrics

node-genius-lyrics's Introduction

Genius Lyrics ๐ŸŽต

npm npm npm Documentation

๐Ÿค” Whats is this?

Just a simple lyrics fetcher that uses Genius. This also has official API implementations.

๐Ÿ’ป Installation

npm install genius-lyrics

โš™๏ธ Usage

const Genius = require("genius-lyrics");
const Client = new Genius.Client("top-secret-optional-key");

๐Ÿ“Ž Links

โœ๏ธ Examples

Requiring

JavaScript

const Genius = require("genius-lyrics");
const Client = new Genius.Client("top-secret-optional-key"); // Scrapes if no key is provided

TypeScript

import Genius from "genius-lyrics";
const Client = new Genius.Client("top-secret-optional-key"); // Scrapes if no key is provided

Fetching a Song and Lyrics

const searches = await Client.songs.search("faded");

// Pick first one
const firstSong = searches[0];
console.log("About the Song:\n", firstSong, "\n");

// Ok lets get the lyrics
const lyrics = await firstSong.lyrics();
console.log("Lyrics of the Song:\n", lyrics, "\n");

Fetching an Artist

const artist = await Client.artists.get(456537);
console.log("About the Artist:\n", artist, "\n");

node-genius-lyrics's People

Contributors

aozoradev avatar dependabot[bot] avatar mrpropre avatar mylloon avatar zyrouge 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

Watchers

 avatar  avatar  avatar

node-genius-lyrics's Issues

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.

album and artist is undefined

So i was making a lyrics command on my Discord bot using this package, and everytime i searched a song it will always return this:
Artist: [object Object]
Album: undefined
anu
Lyrics are fine though, as you can see.

And here's my code:

const Genius = require("genius-lyrics");
const Gclient = new Genius.Client
const { MessageEmbed } = require("discord.js");

module.exports = {
    info: {
        name: "lyrics",
        description: "Will return the lyrics of a specified song.",
        usage: "[song name]",
        cooldown: 10,
    },

    execute: async function (client, message, args, Discord) {

        var searchString = args.join(" ");
        if (!searchString) return message.reply("please specify a keyword, i am not able to read your thoughts.").then(msg => { msg.delete({ timeout: 5000 }) });

        const searches = await Gclient.songs.search(searchString);
        const firstSong = searches[0];
        const lyrics = await firstSong.lyrics();

        let lyricEmbed = new MessageEmbed()
            .setColor('BLUE')
            .setTitle(firstSong.title)
            .setURL(firstSong.url)
            .setThumbnail(firstSong.thumbnail)
            .setDescription(
                `Artist: ${firstSong.artist}\n`
                + `Album: ${firstSong.album}\n\n`
                + `${lyrics}`
            )
            .setTimestamp();
        message.channel.send(lyricEmbed);

    }
}

I'm an amateur, so i probably screwed up the code a little bit.

NoResultError for some specific queries

This library works wonderfully for most queries, but some are problematic. I have not found a cause for it yet, but it happens occasionally with some queries, it's always the same result, so it is consistent in that sense. This never gives results no matter how often I retry it, I can also try rewording it, it just does not show results when searching for this song in particular. Good to note, is that it's also the name of the album, so perhaps something is going wrong with that. I can fetch every single other song by the doors, just not this one.
image
image

tracklyrics.lyrics() is not a function

I am following the example in the README, although while using it in my code, my console says that tracklyrics.lyrics is not a function.
I am trying to make a command in Discord.js with it so whenever my bot plays a song, the users can get the lyrics of the current song that is playing.

This is how I am using the package:

const queue = await client.distube.getQueue(interaction.guildId);
const tracklyrics = queue.songs[0];
const lyrics = await tracklyrics.lyrics();

//Everything down below shouldn't be relevant to the error. 

//response.setAuthor({ name: "LYRICS", iconURL: user.avatarURL({ dynamic: true }) })
//response.setDescription("**_ Sent Lyrics to your DMs_**")
//user.send({ embeds: [new MessageEmbed().setColor("#2F3136").setAuthor({ name: "LYRICS", iconURL: //user.avatarURL({ dynamic: true }) }).setDescription(`${lyrics}`)] });
//return interaction.reply({ embeds: [response] });

error on lyrics request.

Hi,

i am getting this error when i try to search for lyrics for songs.
if i use

const genius = require("genius-lyrics");
const gClient = new genius.Client();

ERROR:

resolve Promise {
today at 11:32:08  '<!DOCTYPE html>\n' +
today at 11:32:08    '<html lang="en">\n' +
today at 11:32:08    '  <head>\n' +
today at 11:32:08    '    <meta charset="UTF-8">\n' +
today at 11:32:08    '    <meta http-equiv="X-UA-Compatible" content="IE=edge">\n' +
today at 11:32:08    '    <meta name="viewport" content="width=device-width, initial-scale=1.0">\n' +
today at 11:32:08    '    <title>Genius</title>\n' +
today at 11:32:08    '    <style>*{box-sizing:border-box}body{width:100%;margin:0;color:#fff;background:#000;font-family:Helvetica Neue,Arial,Helvetica,Geneva,sans-serif;font-size:20px;font-weight:700}a,a:active,a:focus{color:#3d85c6;text-decoration:none}a:hover{border-bottom:1px dotted}header{background-color:#ffff64;padding:10px;color:#000}header img{height:20px;display:block;margin:0 auto}main{max-width:860px;margin:0 auto}.text{text-align:center}.alert{margin:40px 20px}h1{font-size:7.5rem;text-transform:uppercase;font-weight:700;margin:0}@media screen and (max-width:420px){h1{font-size:3.5rem}}.distractions{margin:3rem auto 0;width:100%;max-width:700px}.iframe-container{width:100%;height:0;padding-top:56.25%;position:relative}.iframe-container iframe{max-width:100%;max-height:100%;position:absolute;top:0;left:0}</style>\n' +
today at 11:32:08    '    <style type="text/css">.cloudflare_content{margin-top:2rem}#recaptcha_widget{display:flex;justify-content:center}</style>\n' +
today at 11:32:08    '    <script type="text/javascript">!function(e,a){var t,n,i,l;a.__SV||((window.mixpanel=a)._i=[],a.init=function(e,t,n){function o(e,t){var n=t.split(".");2==n.length&&(e=e[n[0]],t=n[1]),e[t]=function(){e.push([t].concat(Array.prototype.slice.call(arguments,0)))}}var p=a;for(void 0!==n?p=a[n]=[]:n="mixpanel",p.people=p.people||[],p.toString=function(e){var t="mixpanel";return"mixpanel"!==n&&(t+="."+n),e||(t+=" (stub)"),t},p.people.toString=function(){return p.toString(1)+".people (stub)"},i="disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking start_batch_senders people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove".split(" "),l=0;l<i.length;l++)o(p,i[l]);var r="set set_once union unset remove delete".split(" ");p.get_group=function(){function e(e){t[e]=function(){call2_args=arguments,call2=[e].concat(Array.prototype.slice.call(call2_args,0)),p.push([n,call2])}}for(var t={},n=["get_group"].concat(Array.prototype.slice.call(arguments,0)),o=0;o<r.length;o++)e(r[o]);return t},a._i.push([e,t,n])},a.__SV=1.2,(t=e.createElement("script")).type="text/javascript",t.async=!0,t.src="undefined"!=typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\\/\\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js",(n=e.getElementsByTagName("script")[0]).parentNode.insertBefore(t,n))}(document,window.mixpanel||[]),mixpanel.init("77967c52dc38186cc1aadebdd19e2a82");</script>\n' +
today at 11:32:08    '    <script type="text/javascript">/* eslint-env browser */\n' +
today at 11:32:08    '/* globals mixpanel */\n' +
today at 11:32:08    '/* eslint-disable no-unused-vars */\n' +
today at 11:32:08    "const METRICS_URL = 'https://librato-collector.genius.com/v1/metrics';\n" +
today at 11:32:08    '\n' +
today at 11:32:08    'function sendToLibrato(body) {\n' +
today at 11:32:08    '  if (navigator.sendBeacon) {\n' +
today at 11:32:08    '    navigator.sendBeacon(\n' +
today at 11:32:08    '      METRICS_URL,\n' +
today at 11:32:08    "      new Blob([JSON.stringify(body)], {type: 'application/json'})\n" +
today at 11:32:08    '    );\n' +
today at 11:32:08    '  } else {\n' +
today at 11:32:08    '    fetch(\n' +
today at 11:32:08    '      METRICS_URL,\n' +
today at 11:32:08    '      {\n' +
today at 11:32:08    "        method: 'POST',\n" +
today at 11:32:08    '        body: JSON.stringify(body),\n' +
today at 11:32:08    "        headers: {'Content-Type': 'application/json'},\n" +
today at 11:32:08    '      }\n' +
today at 11:32:08    '    );\n' +
today at 11:32:08    '  }\n' +
today at 11:32:08    '}\n' +
today at 11:32:08    '\n' +
today at 11:32:08    'function count(name, {source}, extra = {}) {\n' +
today at 11:32:08    '  sendToLibrato({counters: [{name, value: 1, source}]});\n' +
today at 11:32:08    '  mixpanel.track(name, Object.assign({source}, extra));\n' +
today at 11:32:08    '}\n' +
today at 11:32:08    '</script>\n' +
today at 11:32:08    '      <script>\n' +
today at 11:32:08    '    //<![CDATA[\n' +
today at 11:32:08    '    (function(){\n' +
today at 11:32:08    '      window._cf_chl_opt={\n' +
today at 11:32:08    '        cvId: "2",\n' +
today at 11:32:08    '        cType: "interactive",\n' +
today at 11:32:08    '        cNounce: "74600",\n' +
today at 11:32:08    '        cRay: "73c9a3fabd12c26a",\n' +
today at 11:32:08    '        cHash: "189be7f9a3a983a",\n' +
today at 11:32:08    '        cUPMDTk: "\\/api\\/search\\/song?per_page=5&q=rihanna%20-%20pon%20de%20replay&__cf_chl_tk=fOPgVPWW7NM6w3jmDvICWHmycVdNdU7MsPZABwh5UxA-1660815128-0-gaNycGzNBxE",\n' +
today at 11:32:08    '        cFPWv: "b",\n' +
today at 11:32:08    '        cTTimeMs: "1000",\n' +
today at 11:32:08    '        cLt: "n",\n' +
today at 11:32:08    '        cRq: {\n' +
today at 11:32:08    '          ru: "aHR0cHM6Ly9nZW5pdXMuY29tL2FwaS9zZWFyY2gvc29uZz9wZXJfcGFnZT01JnE9cmloYW5uYSUyMC0lMjBwb24lMjBkZSUyMHJlcGxheQ==",\n' +
today at 11:32:08    '          ra: "TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzg4LjAuNDMyNC4xNTAgU2FmYXJpLzUzNy4zNg==",\n' +
today at 11:32:08    '          rm: "R0VU",\n' +
today at 11:32:08    '          d: "jVhBINojKwOFHt4nvnvZ8jFJ7UMi4r7of8Nty5dZ4oHCjjfBZDBl0dMo2hhMLudP9X7KWB/q2pIvzvBuqQ7WhFsl81ctWYhjNnyJVUuBd4HrkcQ45Vz++osmn5/VCpbzjn1eueU3Fxj+wMPuOAJ977F0/YUP1/SOHcTpX7iAPxVh7jBUAJ9XWlIC5VqirXG6q6z2RHNE1LdkGJQ7DkCbbJSprDhzAY5QvfHn4PgKcYAszjhH2KKFMZ/cLkrxAKklCqz4SI10IZMifF5Lsfroitv9P0thYezrEMfMtMn/GnvxXASSni1BAh+8dX9NYiUGeikGEYbh2XjenPnEi4SxQeA6yxUBdI40Nh1J4iy6tl1iLKr1o9Ahjr05ItPw5TCCr6LseH6wXmI5N7xWqpkVPKtFa8/K0WoZcmUYk0s3+t/CcJF1FHS1OLBntsX6uKumv7Q5uuohN8isI0ZXepUtYbxDt5QK2HJy17FBItzeGpMyXIp0jBA6Ki8bnNzkA2L9P8L6JLGUQllUqFqYxCR7t9AhQo0ozSbwdgRH/VGHQraQA0tB/TR5kYUd/9ziFM7y1njb6s8WF5pL0KdOjbJ6zWfE2Ke+ooknBwEQcfKExuo=",\n' +
today at 11:32:08    '          t: "MTY2MDgxNTEyOC43NTgwMDA=",\n' +
today at 11:32:08    '          m: "H+aENbopADlUeknaBOB1XDq3/Q6GTWXyDjhHMl961ak=",\n' +
today at 11:32:08    '          i1: "g8Mm82SWA51pYgZRKdXDzw==",\n' +
today at 11:32:08    '          i2: "010bOecHIAHTbpDi7uePGQ==",\n' +
today at 11:32:08    '          zh: "CjTVwn9XNZkq0esm2p7N7xf+k6qzISv05qP4sHAkLrw=",\n' +
today at 11:32:08    '          uh: "evELmLgWWGJMX3bEvf8PCqU8WIVnGBN9Gw33IeX85Ws=",\n' +
today at 11:32:08    '          hh: "32aD8UBAl18mYvSTL2321kh0bo8zGh3sVHE1rNoLb3A=",\n' +
today at 11:32:08    '        }\n' +
today at 11:32:08    '      };\n' +
today at 11:32:08    '    }());\n' +
today at 11:32:08    '    //]]>\n' +
today at 11:32:08    '    </script>\n' +
today at 11:32:08    '\n' +
today at 11:32:08    '</head>\n' +
today at 11:32:08    '  <body>\n' +
today at 11:32:08    '    <header>\n' +
today at 11:32:08    '      <img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTUiPjxwYXRoIGQ9Ik0xMS43IDIuOXMwLS4xIDAgMGMtLjgtLjgtMS43LTEuMi0yLjgtMS4yLTEuMSAwLTIuMS40LTIuOCAxLjEtLjIuMi0uMy40LS41LjZ2LjFjMCAuMS4xLjEuMS4xLjQtLjIuOS0uMyAxLjQtLjMgMS4xIDAgMi4yLjUgMi45IDEuMmgxLjZjLjEgMCAuMS0uMS4xLS4xVjIuOWMuMSAwIDAgMCAwIDB6bS0uMSA0LjZoLTEuNWMtLjggMC0xLjQtLjYtMS41LTEuNC4xIDAgMC0uMSAwLS4xLS4zIDAtLjYuMi0uOC40di4yYy0uNiAxLjguMSAyLjQuOSAyLjRoMS4xYy4xIDAgLjEuMS4xLjF2LjRjMCAuMS4xLjEuMS4xLjYtLjEgMS4yLS40IDEuNy0uOFY3LjZjLjEgMCAwLS4xLS4xLS4xeiIvPjxwYXRoIGQ9Ik0xMS42IDExLjlzLS4xIDAgMCAwYy0uMSAwLS4xIDAgMCAwLS4xIDAtLjEgMCAwIDAtLjguMy0xLjYuNS0yLjUuNS0zLjcgMC02LjgtMy02LjgtNi44IDAtLjkuMi0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LS4xYzAtLjEgMC0uMi0uMS0uMnoiLz48cGF0aCBkPSJNOTQuMSAzLjJjMCAuMS4xLjEuMS4xaC4yYzEuMSAwIDEuNy4zIDIuNC44LjMuMi42LjMgMSAuM3MuOC0uMiAxLjEtLjZjLjItLjMuMy0uNi4zLS45IDAtLjEgMC0uMS0uMS0uMS0uMiAwLS4zLS4xLS41LS4yLS44LS42LTEuNC0uOS0yLjYtLjktMS4yIDAtMiAuNi0yIDEuNC4xIDAgLjEgMCAuMS4xeiIvPjwvc3ZnPgo=" alt="Genius logo"/>\n' +
today at 11:32:08    '    </header>\n' +
today at 11:32:08    '    <main>\n' +
today at 11:32:08    '      <div class="text alert">\n' +
today at 11:32:08    '        <h1>Scrrrr!!</h1>\n' +
today at 11:32:08    `        <div class="dek">Sorry, we have to make sure you're a human before we can show you this page.</div>\n` +
today at 11:32:08    '        <div class="cloudflare_content">\n' +
today at 11:32:08    '          <form id="challenge-form" class="challenge-form interactive-form" action="/api/search/song?per_page=5&amp;q=rihanna%20-%20pon%20de%20replay&amp;__cf_chl_f_tk=fOPgVPWW7NM6w3jmDvICWHmycVdNdU7MsPZABwh5UxA-1660815128-0-gaNycGzNBxE" method="POST" enctype="application/x-www-form-urlencoded">\n' +
today at 11:32:08    "    <div id='cf-please-wait'>\n" +
today at 11:32:08    "      <div id='spinner'>\n" +
today at 11:32:08    '        <div id="cf-bubbles">\n' +
today at 11:32:08    '            <div class="bubbles"></div>\n' +
today at 11:32:08    '            <div class="bubbles"></div>\n' +
today at 11:32:08    '            <div class="bubbles"></div>\n' +
today at 11:32:08    '        </div>\n' +
today at 11:32:08    '      </div>\n' +
today at 11:32:08    '      <p data-translate="please_wait" id="cf-spinner-please-wait">Please stand by, while we are checking your browser...</p>\n' +
today at 11:32:08    '      <p data-translate="redirecting" id="cf-spinner-redirecting" style="display:none">Redirecting...</p>\n' +
today at 11:32:08    '      </div>\n' +
today at 11:32:08    '  <input type="hidden" name="md" value="JiefTw3tangFOXWeVICQVzLqotVbg.8PI3SNkN6LDuY-1660815128-0-AZEJ2QEqIlw8VFYyoU6HqTP3_MR_yAtA1kZ9iNta8nLG078qUxiyTeFaJ1WPJtUoLYH64sR8_rJFy_gQpapmRZdUODsPp8zms8h694qiSDKSi'... 5855 more characters
today at 11:32:08} undefined

if i use:

const genius = require("genius-lyrics");
const gClient = new genius.Client("top-secret-optional-key");

ERROR:

  "error":"invalid_token","error_description":"The access token provided is expired, revoked, malformed or invalid for other reasons."}'

what can i do to fix it?

IPV6 support

Both the scraping and the regular API stop working when a device supports IPV6:
image
The api url is converted to an IPV6 address instead of the working IPV4 one, could we have an option to always use IPV4 for the API?

.lyrics() sometimes returns extra newlines

Hello @zyrouge

/lyrics() function sometimes returns extra newlines. In the current version of genius-lyrics there is the same treatment for .lyrics and .Lyrics__Container divs. But with .lyrics you don't need to add extra treatment because line breaks are already appended. This behavior is avoided in #19 because there is no extra treatment when using .lyrics.

Normal behavior :
image

Bug :
image

Thank you in advance.

Sometimes a newline is missing between different blocks of a song

For example, the response for ABBA - gimme gimme gimme is as follow:

[Verse 1]
Half-past twelve
And I'm watching the late show in my flat, all alone
How I hate to spend the evening on my own
Autumn winds
Blowing outside the window as I look around the room
And it makes me so depressed to see the gloom

[Pre-Chorus]
There's not a soul out there
No one to hear my prayer
[Chorus]
Gimme, gimme, gimme a man after midnight
Won't somebody help me chase the shadows away?
Gimme, gimme, gimme a man after midnight
Take me through the darkness to the break of the day

[Verse 2]
Movie stars
Find the end of the rainbow with a fortune to win
It's so different from the world I'm living in
Tired of TV
I open the window and I gaze into the night
But there's nothing there to see, no one in sight

[Pre-Chorus]
There's not a soul out there
No one to hear my prayer

[Chorus]
Gimme, gimme, gimme a man after midnight
Won't somebody help me chase the shadows away?
Gimme, gimme, gimme a man after midnight
Take me through the darkness to the break of the day

[Bridge]
Gimme, gimme, gimme a man after midnight
Gimme, gimme, gimme a man after midnight

[Interlude]

[Pre-Chorus]
There's not a soul out there
No one to hear my prayer

[Chorus]
Gimme, gimme, gimme a man after midnight
Won't somebody help me chase the shadows away?
Gimme, gimme, gimme a man after midnight
Take me through the darkness to the break of the day
Gimme, gimme, gimme a man after midnight
Won't somebody help me chase the shadows away?
Gimme, gimme, gimme a man after midnight
Take me through the darkness to the break of the day

There is a very obvious line break missing between the first pre-chorus and the chorus. This started happening after 3120822, before that I had no such issue and the results always had the correct amount of newlines.

removeChorus regex is not working (?) here's a fix

Hi, great lib, very easy to use and the doc is very nice too!

Maybe I'm mistaken but the removeChorus option doesn't work? I tried it and it didn't have any effect.

Checking the line removing the chorus there

return lyrics.replace(/^\[[^\]]+\]$/g, "");

the regex matching the chorus there is:
/^\[[^\]]+\]$/g

This doesn't seem to match anything (testing in regex101 with lyrics from Genius).

After a few tries, I found that this would seems to be a good regex to apply:

/^\[(?:Chorus|Post-Chorus|Pre-Chorus)[\s\S]*?(?:\n\n|(?=[\n]?$(?![\n])))/gm

It matches Chorus, Post-Chorus and Pre-Chorus blocks. I tried replacing the one in the code with this, and it actually stripes the Chorus blocks.

This part : (?=[\n]?$(?![\n])) is needed to match a Chorus|Post-Chorus|Pre-Chorus block that is at the very end of the lyrics (without a blank line after it).

A great option would be to be able to keep one chorus (and post-chorus etc.) but remove the duplicates, maybe just replacing them by [Chorus] only. This could probably be done in Regex too, but I guess doing it using string manipulation in JavaScript might be more readable and more flexible.

SyntaxError: await is only valid in async functions and the top level bodies of modules

I am running the example code given from node-genius-lyrics after installing the package through npm

const Genius = require("genius-lyrics");
const Client = new Genius.Client(myClientID);

const searches = await Client.songs.search("faded");

// Pick first one
const firstSong = searches[0];
console.log("About the Song:\n", firstSong, "\n");

// Ok lets get the lyrics
const lyrics = await firstSong.lyrics();
console.log("Lyrics of the Song:\n", lyrics, "\n");

But error occur:

const searches = await Client.songs.search("faded");
                 ^^^^^

SyntaxError: await is only valid in async functions and the top level bodies of modules
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1153:20)
    at Module._compile (node:internal/modules/cjs/loader:1205:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47

Node.js v20.9.0

May I know how to fix this error? Any help would be appreciated.

error: No result was found

Sometimes when we try to get lyrics with .lyrics() function, it gives us this error: No result was found but if we try the same song after some time, it gives us the result. Maybe this is a bug.

Is it possible to make it run without node (in browser)?

Hi! I'm building a browser extension which displays lyrics from Genius in another website. When I try to import this library I get the following error: TypeError: $bGKbb.versions.node is undefined. It will be nice to make this module run in browsers too.

403 - Error, wrong url?

Im having issues when trying to get the songs from an artist, im always getting an 403 Error with the message "Action forbidden for current scope".

I think it's because the url called looks like this: api.genius.com/songs?page=1&per_page=20&sort=title,
But shouldn't it look more like this api.genius.com/artist/1234567/songs?page=1&per_page=20&sort=title ?

const data = await this.client.api.get(
`/songs?page=${nOptions.page}&per_page=${nOptions.perPage}&sort=${nOptions.sort}`
);
const parsed = JSON.parse(data);

I changed this block to use the correct url and fixed access to the response like this:

...
const data = await this.client.api.get(
      `/artists/${this.id}/songs?page=${nOptions.page}&per_page=${nOptions.perPage}&sort=${nOptions.sort}`
);
const parsed = JSON.parse(data).response; // Added the .response
...

And it works for me.
Did i found a bug or am i just missing something?

Lyrics not working

This is my initialization:

const lyrics = new Genius.Client(process.env.GENIUSTOKEN);

this is my command:

lyrics.songs.search("Omfori Skidder Skidder Skidder").then(async x => {
          return x?.length ? await x[0].lyrics() : null;
}); 

This is the output:

Error: No result was found

It is because this happens when u fetch the uri:
https://milrato.com/codeshare/code/63a41dd1b7ad972a43f9380a

But when I open it in the BROWSER of the SERVER where I'M making the request of, it does not show cloudflare:
image

Please make it possible to change browser origin headers.
So I can use the ones from my BROWSER (Firefox, linux, etc.) (defaultUserAgent )
because I'd need: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0

  • maybe cookies could help?

cause lyrics you scrape

error handling

I can't find any documentation on how to handle errors in my app when an artist/song is not found.

Any support on this issue would be kindly appreciated.

HTML parsing error due to captcha

I got this error when I tried to use this module without the API key, which scrapes the genius lyrics.

undefined:1
<!DOCTYPE html>
^

SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at SongsClient.<anonymous> (/home/runner/terminal/node_modules/genius-lyrics/dist/songs/client.js:47:37)
    at Generator.next (<anonymous>)
    at fulfilled (/home/runner/terminal/node_modules/genius-lyrics/dist/songs/client.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
const Genius = require("genius-lyrics");
const Client = new Genius.Client();
(async () => {
const searches = await Client.songs.search("faded");


const firstSong = searches[0];
console.log("About the Song:\n", firstSong, "\n");
console.log(firstSong)
})();

TypeError: Cannot read properties of undefined (reading 'hits')

at SongsClient.<anonymous> (H:\discordbot\mrdia-main\node_modules\genius-lyrics\dist\songs\client.js:43:42)
at Generator.next (<anonymous>)
at fulfilled (H:\discordbot\mrdia-main\node_modules\genius-lyrics\dist\songs\client.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

error when search for arabic songs

hello, i'm trying to search for arabic songs like ุฏุง ู„ูˆ ุงุชุณุงุจ or 3 ุฏู‚ุงุช i'm getting this error
(GeniusLyrics) TypeError [ERR_UNESCAPED_CHARACTERS]: Request path contains unescaped characters

Error on calling

Error: Request failed with status code 403
    at createError (/home/runner/api/node_modules/genius-lyrics/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/home/runner/api/node_modules/genius-lyrics/node_modules/axios/lib/core/settle.js:17:12)
    at IncomingMessage.handleStreamEnd (/home/runner/api/node_modules/genius-lyrics/node_modules/axios/lib/adapters/http.js:260:11)
    at IncomingMessage.emit (events.js:326:22)
    at endReadableNT (_stream_readable.js:1241:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  config: {
    url: 'https://genius.com/Bohemia-same-beef-lyrics',
    method: 'get',
....

this used to work yesterday but now it is not

Uncatchable error

Hi,
I have problem with error "NoResultError: No result was found"
If its unable to find a lyric it returns a error message which can't be catched and terminates the node process.
For example I tried this input "Aim Vision - Have You Seen The Moon Tonight?" and it gives the error mentioned above.

How can I solve that error?

Thanks,
Martin Skalicky

switch to node-html-parser from cheerio

tldr; Switch to node-html-parser for better performance.

Genius Lyrics is used by @discord-player/extractor and parsing lyrics usually seems to block the thread (which seems to be caused by cheerio). node-html-parser states that Per the design, it intends to parse massive HTML files in lowest price, thus the performance is the top priority.. Benchmark results show that node-html-parser is very fast compared to cheerio.

How can I get the lyrics of a song that I have acquired with ID?

I apologize for this very rudimentary question.
Could you please tell me how to get the lyrics of a single song from the ID?


I am trying to display a list of songs from the keywords entered by the user, and then display the lyrics of the song the user selects from the list.
The API is as follows.
getSongsAPI

import Genius from "genius-lyrics";
const Client = new Genius.Client("API key");

const getSongs = async ({ query: { keyword } }, res) => {
  const songs = await Client.songs.search(keyword);
  return res.status(200).json(songs);
};

I was able to get a list of lyrics with the above API.
For each of the list of returned songs, we have planted a click event as shown below.

const getLyric = async ({currentTarget: { id } => {
  const res = await fetch("/api/getLyric/?id=" + id);
  const lyric = await res.json();
  console.log(lyric);
};

...
<li onClick={getLyric} id={song.id}>{song.title}</li>

getLyricAPI

import Genius from "genius-lyrics";
const Client = new Genius.Client("API key");

const getLyric = async ({ query: { id } }, res) => {
  const song = await Client.songs.get(Number(id));
  const lyric = await song.lyrics();
  return res.status(200).json(lyric);
};

The getLyricAPI expects to return lyrics, but it returns an array as shown in the image below.
res

Got an error and success response at the same time

My code is look like this

const Genius = require("genius-lyrics");
const gclient = new Genius.Client('super-secret');

module.export = {//something to export//}

async function getLyrics(lyrics) {
    const searches = await gclient.songs.search(lyrics);
    const first = searches[0]
    return first
}
getLyrics('noma - brain power').then(async(res)=>{
    console.log(res.lyrics())
    
        //     message.reply([
    //         {
    //             type: "image",
    //             originalContentUrl:res.image,
    //             previewImageUrl:res.image
    //         },
    //         {
    //             type:"text",
    //             text:`${res.artist.name} - ${res.title}
                
    // ${res.lyrics()}`
    //         }
    //     ])  
})

for a messaging bot app and somehow if i uncomment the message.reply() part it give me an error but successfully fetched the data via console.log() hence i got an error and success response, i also check if the previous version (2.9.4) works and it did works but after few request i got the same cloudflare error LMAO but this time i couldn't get success response at all.

got no problem when i tested on my local before running it using Replit

Do you have any idea what is happened?

Error while trying to get lyrics

it threw a SyntaxError while trying to get lyrics from the API

SyntaxError: Unexpected token < in JSON at position 0

IMG_0862

Code:

const lyricsClient = new lyricsFetch.Client()
      const lyricsInput = interaction.options.getString('query');

      try {
      const lyricsSearches = await lyricsClient.songs.search(lyricsInput);
      const lyricsResult = lyricsSearches[0];
      const audioLyrics = await lyricsResult.lyrics();
      } catch(e) 

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.