zyrouge / node-genius-lyrics

Simple lyrics fetcher that uses Genius. Also has official API implementations.
https://genius-lyrics.js.org
MIT License
61 stars 12 forks source link

error on lyrics request. #34

Closed cyb3rgh05t closed 1 year ago

cyb3rgh05t commented 1 year ago

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,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTUiPjxwYXRoIGQ9Ik0xMS43IDIuOXMwLS4xIDAgMGMtLjgtLjgtMS43LTEuMi0yLjgtMS4yLTEuMSAwLTIuMS40LTIuOCAxLjEtLjIuMi0uMy40LS41LjZ2LjFjMCAuMS4xLjEuMS4xLjQtLjIuOS0uMyAxLjQtLjMgMS4xIDAgMi4yLjUgMi45IDEuMmgxLjZjLjEgMCAuMS0uMS4xLS4xVjIuOWMuMSAwIDAgMCAwIDB6bS0uMSA0LjZoLTEuNWMtLjggMC0xLjQtLjYtMS41LTEuNC4xIDAgMC0uMSAwLS4xLS4zIDAtLjYuMi0uOC40di4yYy0uNiAxLjguMSAyLjQuOSAyLjRoMS4xYy4xIDAgLjEuMS4xLjF2LjRjMCAuMS4xLjEuMS4xLjYtLjEgMS4yLS40IDEuNy0uOFY3LjZjLjEgMCAwLS4xLS4xLS4xeiIvPjxwYXRoIGQ9Ik0xMS42IDExLjlzLS4xIDAgMCAwYy0uMSAwLS4xIDAgMCAwLS4xIDAtLjEgMCAwIDAtLjguMy0xLjYuNS0yLjUuNS0zLjcgMC02LjgtMy02LjgtNi44IDAtLjkuMi0xLjcuNS0yL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EgMC0uMi0uMS0uMnoiLz48cGF0aCBkPSJNOTQuMSAzLjJjMCAuMS4xLjEuMS4xaC4yYzEuMSAwIDEuNy4zIDIuNC44LjMuMi42LjMgMSAuM3MuOC0uMiAxLjEtLjZjLjItLjMuMy0uNi4zLS45IDAtLjEgMC0uMS0uMS0uMS0uMiAwLS4zLS4xLS41LS4yLS44LS42LTEuNC0uOS0yLjYtLjktMS4yIDAtMiAuNi0yIDEuNC4xIDAgLjEgMCAuMS4xeiIvPjwvc3ZnPgo=" 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?

zyrouge commented 1 year ago

The first one, it seems like couldflare is intercepting the request. Currently the library cannot bypass it. You could use proxy to bypass it if you want to.

Second one, the token provided must be a valid genius client's token. Since, you specified an invalid token, thus the error.

cyb3rgh05t commented 1 year ago

allright thanks