Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@noise-machines/lyricist
Advanced tools
Readme
⭐️ Genius.com API client with lyrics scraper
Version 2.0 is a complete rewrite with async/await.
yarn add lyricist
or
npm install lyricist --save
Node 6 doesn't support async/await and will need to use the transpiled version (lyricist/node6), along with promises:
const Lyricist = require('lyricist/node6');
Note: Older versions of Node aren't currently supported. Open an issue if you'd like to see support for them
Get an access token at https://genius.com/api-clients.
const lyricist = new Lyricist(accessToken);
Use song()
to fetch a song by ID:
const song = await lyricist.song(714198);
console.log(song.title);
// output: Death with Dignity
lyricist.song(714198).then(song => console.log(song.title));
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()
.
lyricist.song(714198, { textFormat: 'html' }).then(song => console.log(song.description.html));
// output: <p>The first track off of Sufjan’s 2015 album...
The Genius API doesn't offer lyrics, but Lyricist can scrape Genius.com for you. Simply provide the fetchLyrics
option like this:
const song = await lyricist.song(714198, { fetchLyrics: true });
console.log(song.lyrics);
// output: Spirit of my silence I can hear you...
Use album()
to look up an album by ID. The Genius API doesn't allow you to search an album by title, but song() will return an album.id
:
const album = await lyricist.album(56682);
console.log(`${album.name} by ${album.artist.name}`);
// output: Lanterns by Son Lux
The Genius API doesn't provide tracklists, but Lyricist can scrape Genius.com and return the tracklist for you. Simply provide the fetchTracklist
option like this:
const album = await lyricist.album(56682, { fetchTracklist: true });
console.log(album.songs);
// output: [{ id: 502102, title: 'Alternate World', ... }, { id: 267773, title: 'Lost It To Trying', ... }, ...]
Use artist()
to look up an artist by ID:
const artist = await lyricist.artist(2);
console.log(artist.name);
// output: Jay Z
Use songsByArtist()
to list an artist's songs. Example usage:
const songs = await lyricist.songsByArtist(2);
songsByArtist()
will show 20 results per page by default, and can be as high as 50.
You can provide options as a second parameter. The available options are:
perPage
: Number (default: 20)page
: Number (default: 1)sort
String: 'title' or 'popularity' (default: 'title')Use search(query, { page = 1})
to search for songs using the Genius search endpoint. Genius' search endpoint doesn't seem to accept a perPage param.
Example:
const songs = await lyricist.search('Animal Collective', { page: 2 })
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.
Check the Genius.com API docs for more info.
FAQs
Fetches song lyrics using the Genius.com API and website.
The npm package @noise-machines/lyricist receives a total of 2 weekly downloads. As such, @noise-machines/lyricist popularity was classified as not popular.
We found that @noise-machines/lyricist demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.