genius-lyrics-api
Advanced tools
Comparing version 2.0.3 to 3.0.0
@@ -1,3 +0,5 @@ | ||
exports.getLyrics = require('./lib/GetLyrics'); | ||
exports.getLyricsFromPath = require('./lib/GetLyricsFromPath'); | ||
exports.searchLyrics = require('./lib/SearchLyrics'); | ||
exports.getLyrics = require('./lib/getLyrics'); | ||
exports.getAlbumArt = require('./lib/getAlbumArt'); | ||
exports.getSong = require('./lib/getSong'); | ||
exports.searchSong = require('./lib/searchSong'); | ||
exports.getSongById = require('./lib/getSongById'); |
@@ -1,2 +0,3 @@ | ||
const checkOptions = (apiKey, title, artist) => { | ||
const checkOptions = (options) => { | ||
let { apiKey, title, artist } = options; | ||
switch ('undefined') { | ||
@@ -3,0 +4,0 @@ case typeof apiKey: |
@@ -5,3 +5,3 @@ MIT License | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
of this software and associated documentation files (the "genius-lyrics-api"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
@@ -8,0 +8,0 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
{ | ||
"name": "genius-lyrics-api", | ||
"version": "2.0.3", | ||
"version": "3.0.0", | ||
"main": "index.js", | ||
"author": "Faisal Arshed", | ||
"author": { | ||
"name": "Faisal Arshed", | ||
"url": "https://github.com/farshed" | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "Garlicvideos", | ||
"url": "https://github.com/Garlicvideos" | ||
} | ||
], | ||
"license": "MIT", | ||
@@ -18,4 +27,6 @@ "dependencies": { | ||
"lyrics", | ||
"album-art", | ||
"scraper", | ||
"genius-lyrics", | ||
"genius-album-art", | ||
"genius-api", | ||
@@ -22,0 +33,0 @@ "lyrics-scraper" |
# 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 package that provides a convenient wrapper around [Genius API](https://genius.com/developers) for searching and scraping song lyrics.<br/>It doesn't use any native node dependencies and thus, can be used on the frontend. | ||
A package that leverages [Genius API](https://genius.com/developers) to search and fetch/scrape song lyrics and album art.<br/>It doesn't use any native node dependencies and therefore, can be used on the client-side. | ||
@@ -30,3 +30,3 @@ ## Installation | ||
const options = { | ||
apiKey: 'XXXXXXXXXXXXXXXXXXXXXXX', // genius developer access token | ||
apiKey: 'XXXXXXXXXXXXXXXXXXXXXXX', | ||
title: 'Blinding Lights', | ||
@@ -37,3 +37,11 @@ artist: 'The Weeknd', | ||
getLyrics(options).then(lyrics => console.log(lyrics)); | ||
getLyrics(options).then((lyrics) => console.log(lyrics)); | ||
getSong(options).then((song) => | ||
console.log(` | ||
${song.id} | ||
${song.url} | ||
${song.albumArt} | ||
${song.lyrics}`) | ||
); | ||
``` | ||
@@ -43,6 +51,39 @@ | ||
> :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. Follow the instructions [here](https://stackoverflow.com/questions/3102819/disable-same-origin-policy-in-chrome). | ||
> :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 | ||
``` | ||
type options { | ||
title: string; | ||
artist: string; | ||
apiKey: string; // Genius developer access token | ||
optimizeQuery?: boolean; // Setting this to true will optimize the query for best results | ||
} | ||
``` | ||
🚨 All properties in the options object are required except `optimizeQuery`. If `title` or `artist` is unknown, pass an empty string. | ||
``` | ||
type song { | ||
id: number; // Genius song id | ||
url: string; // Genius webpage URL for the song | ||
lyrics: string; // Song lyrics | ||
albumArt: string; // URL of the album art image (jpg/png) | ||
} | ||
``` | ||
``` | ||
type searchResult { | ||
id: number; // Genius song id | ||
url: string; // Genius webpage URL for the song | ||
title: string; // Song title | ||
albumArt: string; // URL of the album art image (jpg/png) | ||
} | ||
``` | ||
## Methods | ||
@@ -52,34 +93,29 @@ | ||
### `getLyrics(options)` | ||
### `getLyrics(options | url)` | ||
Automatically get the lyrics from genius.com using the `title` & `artist` fields.<br/> | ||
Accepts [options](#types) or the url to a Genius song. <br/> | ||
Returns a promise that resolves to a string containing lyrics. Returns `null` if no lyrics are found. | ||
#### Arguments | ||
### `getSong(options)` | ||
```js | ||
const options = { | ||
apiKey: string, // Genius Developer API key/Access Token | ||
title: string, // Title of the song | ||
artist: string, // Name of the artist | ||
optimizeQuery: boolean // Whether to remove redundant words from "title" & "artist" before searching. "false" by default. | ||
}; | ||
``` | ||
Accepts an [options](#types) object. <br/> | ||
Returns a promise that resolves to an object of type [song](#types). Returns `null` if song is not found. | ||
All properties in the `options` object are required except `optimizeQuery`. If either of the `title` or `artist` is unknown, pass an empty string as its value. | ||
### `getAlbumArt(options)` | ||
### `searchLyrics(options)` | ||
Accepts an [options](#types) object. <br/> | ||
Returns a promise that resolves to a string containing a url to the song's album art. Returns `null` if no url is found. | ||
Search lyrics from genius.com using the `title` & `artist` fields.<br/> | ||
Returns a promise that resolves to an array of search results. Returns `null` if no matches are found. | ||
### `searchSong(options)` | ||
Receives the same arguments as `getLyrics`. | ||
Accepts an [options](#types) object. <br/> | ||
Returns a promise that resolves to an object of type [searchResult](#types). Returns `null` if no matches are found. | ||
### `getLyricsFromPath(path: string)` | ||
### `getSongById(id: (number | string))` | ||
Get the lyrics of a song using the `path` property present in the search results of `searchLyrics` method.<br/> | ||
Returns a promise that resolves to a string containing lyrics. | ||
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 the ⭐️ button. Cheers! | ||
If you find this package useful, hit that sweet sweet ⭐️ button. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
164
118
9586
11
1