Skip to main content

Download lyrics and metadata from Genius.com

Project description

Scraping song lyrics from Genius.com

Build Status PyPI version Python version

Setup

This repository is intended to provide an easy interface for programatically accessing the song information stored on Genius.com. Check out my blog post for a more thorough description of the package and its usage.

To use the Genius API you'll need to sign up for a (free) client that authorizes you to access their API. You'll need to supply your client_access_token from Genius when using this module. See Usage below for an example.

Installation

LyricsGenius requires Python 3.

The easiest way to start using this package is to install it via PyPI using pip:

$pip install lyricsgenius

If you'd prefer to clone the repository and install it yourself, follow these steps:

  1. Clone this repo: $git clone https://github.com/johnwmillr/LyricsGenius.git
  2. Enter the cloned directory: $cd LyricsGenius
  3. Install using pip: $pip install .

Usage

>>> import lyricsgenius as genius
>>> api = genius.Genius('my_client_access_token_here')
>>> artist = api.search_artist('Andy Shauf', max_songs=3)
Searching for Andy Shauf...

Song 1: "Alexander All Alone"
Song 2: "Begin Again"
Song 3: "Comfortable With Silence"

Reached user-specified song limit (3).
Found 3 songs.

Done.
>>> print(artist)
Andy Shauf, 3 songs
>>> song = api.search_song('To You',artist.name)
Searching for "To You" by Andy Shauf...
Done.
>>> print(song)
"To You" by Andy Shauf:
    Jeremy can we talk a minute
    I've got some things that I need to
    Get off of my chestI know that we h...
>>> artist.add_song(song)
>>> print(artist)
Andy Shauf, 4 songs
>>> artist.save_lyrics() # Saves artist's lyrics to a JSON file

You can also call the package from the command line. When ran from the command line, the package expects to find an environment variable with your Genius client access token.

$export GENIUS_CLIENT_ACCESS_TOKEN="my_client_access_token_here"
$python3 -m lyricsgenius --search-song 'Begin Again' 'Andy Shauf'
$python3 -m lyricsgenius --search-artist 'Lupe Fiasco' 3

Example projects

I'd love to have more examples to list here! Let me know if you've made use of this wrapper for one of your own projects, and I'll list it here.

Contributing

Please contribute! I'd love to have collaborators on this project. If you want to add features, suggest improvements, or have other comments, just make a pull request or raise an issue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lyricsgenius-0.9.3.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lyricsgenius-0.9.3-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file lyricsgenius-0.9.3.tar.gz.

File metadata

  • Download URL: lyricsgenius-0.9.3.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.19.8 CPython/2.7.15

File hashes

Hashes for lyricsgenius-0.9.3.tar.gz
Algorithm Hash digest
SHA256 f1c45d36818e5681fc0023742f74e2128937791476af864a672ff9198f3185c9
MD5 24284a8173312d78b1ea6ee45cc13a00
BLAKE2b-256 5034d21175c48581945eb9e443f9253b08f6d030ab9f9049d088c036c7587de9

See more details on using hashes here.

File details

Details for the file lyricsgenius-0.9.3-py3-none-any.whl.

File metadata

  • Download URL: lyricsgenius-0.9.3-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.19.8 CPython/2.7.15

File hashes

Hashes for lyricsgenius-0.9.3-py3-none-any.whl
Algorithm Hash digest
SHA256 164cd198a136c5087907764628d24d7a2385bb30a16ec1b86a4394b7b2be0421
MD5 74930f9bc2d0b0e43e14b1e185ce5ea1
BLAKE2b-256 d906f998273c0e7f6cd11e0347b5483651746b645467b955e4848578db872d2a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page