• This repository has been archived on 07/Jun/2024
  • Stars
    star
    100
  • Rank 339,869 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Genius.com API client with lyrics scraping 🎶🎤👨‍🎤

Lyricist 🎤

⭐️ Genius.com API client with lyric scraping

Installation

yarn add lyricist

or

npm install lyricist

API Key

Get an access token at https://genius.com/api-clients

const lyricist = new Lyricist(accessToken);

Look up a song by ID

Use song() to fetch a song by ID:

const song = await lyricist.song(714198);
console.log(song.title);

// output: Death with Dignity

or with promises

lyricist.song(714198).then(song => console.log(song.title));

Get song lyrics

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...

Look up an album

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

Get an album's tracklist

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', ... }, ...]

Look up an artist

Use artist() to look up an artist by ID:

const artist = await lyricist.artist(2);
console.log(artist.name);

// output: Jay Z

Get songs by an artist

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')

Example:

const songs = await lyricist.songsByArtist(2, { page: 2, perPage: 50 });

Search songs by artist name/title

Use search() to search for songs:

const songs = await lyricist.search('Virtual Insanity - Jamiroquai');
console.log(songs);

/* output: (Array of all matching songs)
[
  {
    annotation_count: 1,
    api_path: '/songs/1952220',
    full_title: 'Virtual insanity - remastered by Jamiroquai',
    header_image_thumbnail_url: 'https://images.genius.com/cd9bd5e1d6d23c9a8b044843831d4b3c.300x300x1.png',
    header_image_url: 'https://images.genius.com/cd9bd5e1d6d23c9a8b044843831d4b3c.820x820x1.png',
    id: 1952220,
    ...
  },
  ...
]
*/

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().

const song = lyricist.song(714198, { textFormat: 'html' });
console.log(song.description.html);

// output: <p>The first track off of Sufjan’s 2015 album...

Warning ⚠️

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.

Node 6

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');

Future updates will likely remove this support for old versions of Node

Genius API Docs

Check the Genius.com API docs for more info.

More Repositories

1

styled-map

✨A super simple way to map props to styles with Styled Components ⚠️ See README.md
JavaScript
593
star
2

PreTTI

Improving Text-to-Image Models with Large Language Models
20
star
3

OpenMusicLM

Update: Ignore this repo, check out @lucidrains' implementation https://github.com/lucidrains/musiclm-pytorch
15
star
4

callbaxx

[Satire]🔥 JS utility library to bring classic callback style programming to synchronous code — ES6? More like ES Sucks.
JavaScript
9
star
5

add-graphql-subscriptions

Helper function for use with subscription-transport-ws
JavaScript
6
star
6

banana-riffusion

Python
5
star
7

defuse

1
star
8

scf4

1
star
9

lipx

Image proxy and cache — ⚠️ Archived, do not use
TypeScript
1
star
10

async-styled-components-issue-example

JavaScript
1
star
11

bananaml-serverless-stable-diffusion-v2

test
1
star
12

scottinallca.ps

HTML
1
star
13

redis-dataloader-next

⚠️ Work in progress
1
star
14

misc-notebooks

Misc Colab/Jupyter notebooks
Jupyter Notebook
1
star
15

yikesify

Yikesify.com React App (Don't worry about it)
TypeScript
1
star
16

sonar.js-old

JS client for the private Sonar API [No longer functional]
TypeScript
1
star
17

sonar.js

Client for Sonar's private API (reverse engineered) — this codebase is a hacky mess // No longer functional due to API changes, no further work will be done on this project // Initially created in Jan 2021 for https://github.com/scf4/sonargram
TypeScript
1
star
18

sonargram

Bot to take snapshots of rooms on Sonar and give user a share link // Monorepo, contains bot/web app/api // Created early 2021/code is a mess // No longer functional // Examples: https://twitter.com/bnj/status/1397676636686798848
TypeScript
1
star
19

typescript-node-template

Simple starter template for a Node.js project with TypeScript
JavaScript
1
star