Comparing version 2.1.2 to 2.2.0
@@ -7,7 +7,10 @@ # Change Log | ||
## [2.2.0] - 2017-07-21 | ||
- Added support for `text_format` option (thanks @Scriptim!) | ||
## [2.1.0] - 2017-06-10 | ||
- Fixed scraping for new Genius.com layout | ||
- Split ES6/5 versions of code. No traspiling required for Node 7+ | ||
- Split ES6/5 versions of code. No transpiling required for Node 7+ | ||
## [2.0.0] - 2015-04-27 | ||
- Complete rewrite with async/await and new API |
@@ -32,6 +32,6 @@ const fetch = require('node-fetch'); | ||
async song(id, { fetchLyrics = 123 } = {}) { | ||
async song(id, { fetchLyrics = false, textFormat = 'dom' } = {}) { | ||
if (!id) throw new Error('No ID was provided to lyricist.song()'); | ||
const { song } = await this._request(`songs/${id}`); | ||
const { song } = await this._request(`songs/${id}?text_format=${textFormat}`); | ||
@@ -47,6 +47,6 @@ const lyrics = fetchLyrics ? await this._scrapeLyrics(song.url) : null; | ||
async album(id, { fetchTracklist = false } = {}) { | ||
async album(id, { fetchTracklist = false, textFormat = 'dom' } = {}) { | ||
if (!id) throw new Error('No ID was provided to lyricist.album()'); | ||
const { album } = await this._request(`albums/${id}`); | ||
const { album } = await this._request(`albums/${id}?text_format=${textFormat}`); | ||
@@ -60,5 +60,5 @@ const tracklist = fetchTracklist ? await this._scrapeTracklist(album.url) : null; | ||
async artist(id, opts) { | ||
async artist(id, { textFormat = 'dom' } = {}) { | ||
if (!id) throw new Error('No ID was provided to lyricist.artist()'); | ||
const { artist } = await this._request(`artists/${id}`); | ||
const { artist } = await this._request(`artists/${id}?text_format=${textFormat}`); | ||
return artist; | ||
@@ -65,0 +65,0 @@ } |
@@ -92,3 +92,3 @@ const Lyricist = require('./'); | ||
const result = await lyricist.artist(2); | ||
expect(result.name).toEqual('Jay Z'); | ||
expect(result.api_path).toEqual('/artists/2'); | ||
}); | ||
@@ -95,0 +95,0 @@ }) |
@@ -46,3 +46,3 @@ 'use strict'; | ||
song(id, { fetchLyrics = 123 } = {}) { | ||
song(id, { fetchLyrics = false, textFormat = 'dom' } = {}) { | ||
var _this2 = this; | ||
@@ -53,3 +53,3 @@ | ||
var _ref2 = yield _this2._request(`songs/${id}`); | ||
var _ref2 = yield _this2._request(`songs/${id}?text_format=${textFormat}`); | ||
@@ -69,3 +69,3 @@ const song = _ref2.song; | ||
album(id, { fetchTracklist = false } = {}) { | ||
album(id, { fetchTracklist = false, textFormat = 'dom' } = {}) { | ||
var _this3 = this; | ||
@@ -76,3 +76,3 @@ | ||
var _ref3 = yield _this3._request(`albums/${id}`); | ||
var _ref3 = yield _this3._request(`albums/${id}?text_format=${textFormat}`); | ||
@@ -90,3 +90,3 @@ const album = _ref3.album; | ||
artist(id, opts) { | ||
artist(id, { textFormat = 'dom' } = {}) { | ||
var _this4 = this; | ||
@@ -97,3 +97,3 @@ | ||
var _ref4 = yield _this4._request(`artists/${id}`); | ||
var _ref4 = yield _this4._request(`artists/${id}?text_format=${textFormat}`); | ||
@@ -100,0 +100,0 @@ const artist = _ref4.artist; |
{ | ||
"name": "lyricist", | ||
"version": "2.1.2", | ||
"version": "2.2.0", | ||
"description": "Fetches song lyrics using the Genius.com API and website.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -46,2 +46,10 @@ # Lyricist 🎤 | ||
## Set text_format | ||
The Genius API lets you specify how the response text is formatted. Supported formatting options are `dom` (default), `plain` and `html`. See https://docs.genius.com/#/response-format-h1 for further information. The `textFormat` option is supported by `song()`, `album()` and `artist()`. | ||
```js | ||
lyricist.song(714198, { textFormat: 'html' }).then(song => console.log(song.description.html)); | ||
// output: <p>The first track off of Sufjan’s 2015 album... | ||
``` | ||
## Get song lyrics | ||
@@ -61,3 +69,3 @@ The Genius API doesn't offer lyrics, but Lyricist can scrape Genius.com for you. Simply provide the `fetchLyrics` option like this: | ||
const album = await lyricist.album(56682); | ||
console.log('%s by %s', album.name, album.artist.name); | ||
console.log(`${album.name} by ${album.artist.name}`); | ||
@@ -104,3 +112,3 @@ // output: Lanterns by Son Lux | ||
## Warning ⚠️ | ||
Take care when fetching lyrics. Use caching and rate-limit your app's requests as much as possible. | ||
Take care when fetching lyrics. This feature isn't officially supported by the Genius API, so use caching and rate-limit your app's requests as much as possible. | ||
@@ -107,0 +115,0 @@ ## Genius API Docs |
Sorry, the diff of this file is not supported yet
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
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
122745
115