Socket
Socket
Sign inDemoInstall

genius-scraper

Package Overview
Dependencies
17
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    genius-scraper

a nodejs module to use to scrape lyrics from Genius + wrap the API


Version published
Weekly downloads
1
Maintainers
1
Install size
2.57 MB
Created
Weekly downloads
 

Readme

Source

genius-scraper

A node.js module that can be used in a backend to pull Genius API information with less bloat, and can be then used to scrape lyrics from Genius.

  • Phin
  • Cheerio

:computer: Installation

npm install genius-scraper

:book: Usage

Currently supplies three functions to interact with the Genius API/scrape lyrics.

getArtist(accessToken, artistName, fullObject = false)

Requires a Genius API access token. Pass the token and the artist name. If fullObject is true, it returns the full API object response from Genius, otherwise returns a small object in the format:

{
  name: "Britney Spears",
  id: 1052
 }

This function utilizes the Genius API endpoint at https://api.genius.com/search; the endpoint returns an object with the first 10 hits related to your search query (i.e., artistName). If any of the returned hits contain a primary artist name that matches the artistName parameter, this artist name and ID will be returned. If none of the primary artist names match the search query, then every artist name and ID will be returned as an array of objects. If no hits are found, null is returned.

getSongs(accessToken, artistID, fullObject = false)

Requires a Genius API token. Pass the token and an artist ID (can be obtained using getArtist). If fullObject is true, it returns an array of the full API object response from Genius for each song, otherwise returns an array of small objects representing each song by the artist in the format:

{
 title: "...Baby One More Time",
 id: 78169
 url: "https://genius.com/Britney-spears-baby-one-more-time-lyrics"
}

getLyrics(url)

Does not require a Genius API token. Pass a string containing the full URL for a Genius lyrics page. It will return a string containing the full lyrics for that song, formatted with new lines. If no lyrics are found at the given URL, it will return null.

:beers: License

genius-scraper is provided for free under the MIT license.

Keywords

FAQs

Last updated on 17 Jul 2021

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc