Socket
Socket
Sign inDemoInstall

genius-lyrics-api

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

genius-lyrics-api - npm Package Compare versions

Comparing version 3.2.0 to 3.2.1

9

lib/getSongById.js

@@ -12,6 +12,4 @@ const axios = require('axios');

if (!id) throw 'No id was provided';
if (!apiKey) throw 'No apiKey was provided';
try {
// const headers = {
// Authorization: 'Bearer ' + apiKey
// };
let {

@@ -21,6 +19,3 @@ data: {

}
} = await axios.get(
`${url}${id}&access_token=${apiKey}`
// { headers }
);
} = await axios.get(`${url}${id}?access_token=${apiKey}`);
let lyrics = await extractLyrics(song.url);

@@ -27,0 +22,0 @@ return {

const axios = require('axios');
const cio = require('cheerio-without-node-native');
const cheerio = require('cheerio-without-node-native');

@@ -10,14 +10,15 @@ /**

let { data } = await axios.get(url);
const $ = cio.load(data);
const $ = cheerio.load(data);
let lyrics = $('div[class="lyrics"]').text().trim();
if (!lyrics) {
lyrics = ''
lyrics = '';
$('div[class^="Lyrics__Container"]').each((i, elem) => {
if($(elem).text().length !== 0) {
let snippet = $(elem).html()
.replace(/<br>/g, '\n')
.replace(/<(?!\s*br\s*\/?)[^>]+>/gi, '');
if ($(elem).text().length !== 0) {
let snippet = $(elem)
.html()
.replace(/<br>/g, '\n')
.replace(/<(?!\s*br\s*\/?)[^>]+>/gi, '');
lyrics += $('<textarea/>').html(snippet).text().trim() + '\n\n';
}
})
});
}

@@ -24,0 +25,0 @@ if (!lyrics) return null;

{
"name": "genius-lyrics-api",
"version": "3.2.0",
"version": "3.2.1",
"main": "index.js",

@@ -17,3 +17,3 @@ "author": {

"dependencies": {
"axios": "^0.21.4",
"axios": "^1.6.7",
"cheerio-without-node-native": "0.20.2"

@@ -20,0 +20,0 @@ },

# genius-lyrics-api [![npm version](https://img.shields.io/npm/v/genius-lyrics-api.svg?style=flat)](https://www.npmjs.com/package/genius-lyrics-api)
A JavaScript package that leverages [Genius API](https://genius.com/developers) to search and fetch song lyrics and album art.<br/>It doesn't use any native node dependencies and therefore, can be used on the client-side.
A JavaScript package for non-browser environments that leverages [Genius API](https://genius.com/developers) to find (and scrape) song lyrics and album covers.<br/>

@@ -31,4 +31,4 @@ ## Installation

apiKey: 'XXXXXXXXXXXXXXXXXXXXXXX',
title: 'Blinding Lights',
artist: 'The Weeknd',
title: 'Posthumous Forgiveness',
artist: 'Tame Impala',
optimizeQuery: true

@@ -40,8 +40,3 @@ };

getSong(options).then((song) =>
console.log(`
${song.id}
${song.title}
${song.url}
${song.albumArt}
${song.lyrics}`)
console.log(`${song.id} - ${song.title} - ${song.url} - ${song.albumArt} - ${song.lyrics}`)
);

@@ -52,6 +47,2 @@ ```

> :warning: You may get a CORS block error while testing on localhost. To bypass this, you need to disable Same-Origin Policy in your browser. You may follow the instructions [here](https://stackoverflow.com/questions/3102819/disable-same-origin-policy-in-chrome).
<br>
## Types

@@ -64,4 +55,4 @@

apiKey: string; // Genius developer access token
optimizeQuery?: boolean; // Setting this to true will optimize the query for best results
authHeader?: boolean; // Whether to include auth header in the search request. 'false' by default.
optimizeQuery?: boolean; // (optional, default: false) If true, perform some cleanup to maximize the chance of finding a match
authHeader?: boolean; // (optional, default: false) Whether to include auth header in the search request
}

@@ -71,3 +62,3 @@

🚨 All properties in the options object are required except `optimizeQuery` and `authHeader`. If `title` or `artist` is unknown, pass an empty string.
🚨 If `title` or `artist` is unknown, pass an empty string.

@@ -118,9 +109,5 @@ ```

### `getSongById(id: (number | string))`
### `getSongById(id: (number | string), access_token: string)`
Accepts a valid Genius song ID. IDs can be found using the `searchSong` method. <br/>
Returns a promise that resolves to an object of type [song](#types).
## Support
If you find this package useful, hit that sweet sweet ⭐️ button.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc