Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
415 commits
Select commit Hold shift + click to select a range
b44ba23
Change self.artist to self.name in Artist.save_lyrics
johnwmillr Dec 4, 2018
2a4fb8a
Merge pull request #72 from johnwmillr/fix-saving-artist-lyrics
johnwmillr Dec 4, 2018
40babee
Use proper get method on _body dict
johnwmillr Dec 7, 2018
c807f4c
Update to v1.0.1
johnwmillr Dec 7, 2018
39d2df2
Merge pull request #75 from johnwmillr/fix-save-artist-lyrics-again
johnwmillr Dec 7, 2018
5b3273d
Add assertion requiring python3 in setup.py
johnwmillr Dec 7, 2018
7cee564
Merge pull request #76 from johnwmillr/add-python2-setup-check
johnwmillr Dec 7, 2018
b08c19c
Allow search_artist to check all sections
johnwmillr Dec 8, 2018
572966f
Use search_genius_web in search_song
johnwmillr Dec 17, 2018
070e30c
Update to 1.1.0
johnwmillr Dec 17, 2018
297e84b
Remove 'or True' from search_song
johnwmillr Dec 17, 2018
0a119a4
Merge pull request #78 from johnwmillr/improve-search-flexibility
johnwmillr Dec 17, 2018
d5fa1da
Add two new projects to Examples section
johnwmillr Jan 1, 2019
2ac0300
Clean up README
johnwmillr Jan 1, 2019
fc9e2f6
Fix always-saving bug in command-line interface
johnwmillr Jan 1, 2019
740cf38
Change for to to in README
johnwmillr Jan 1, 2019
849705c
Use underscores in method names
johnwmillr Jan 6, 2019
5efdc57
Add documentation on Genius class parameters
johnwmillr Jan 6, 2019
236d5b6
Change `api` in README to `genius`
johnwmillr Jan 9, 2019
41f446c
Sort by popularity for CLI artist search
johnwmillr Jan 19, 2019
be0eed6
Refactor artist to make use of Song.save_lyrics() for all the songs i…
VitoMinheere Feb 7, 2019
ad67eea
Update tests to reflect changes in artist.save_lyrics
VitoMinheere Feb 8, 2019
19b2fcf
Remove erroneous print statements
johnwmillr Feb 9, 2019
13908f0
Clean up test file
johnwmillr Feb 9, 2019
d924917
Update version to 1.3.0
johnwmillr Feb 9, 2019
058ea6d
Fix tests with mutliple files
VitoMinheere Feb 12, 2019
8ae1470
merge
VitoMinheere Feb 12, 2019
93a1fe1
Merge pull request #84 from VitoMinheere/save_lyrics_refactor
johnwmillr Feb 14, 2019
391bb1a
Add sanitize filename function
johnwmillr Mar 2, 2019
2a4adbb
Improve file saving tests
johnwmillr Mar 2, 2019
da3bd0d
Update version to 1.3.1
johnwmillr Mar 2, 2019
9a78da9
Remove print statements
johnwmillr Mar 2, 2019
e8d7059
Merge pull request #88 from johnwmillr/make-filenames-safe
johnwmillr Mar 2, 2019
2de6708
Add AUR package info to README
johnwmillr Mar 11, 2019
a168c45
Merge pull request #90 from johnwmillr/add-AUR-package-info
johnwmillr Mar 11, 2019
46e74dc
Remove test failing due to genius.com change
johnwmillr Apr 3, 2019
aab4980
Update README.md
johnwmillr Apr 3, 2019
9969763
Sort respose on type for more accurate matching
HotGiardiniera Apr 5, 2019
dc55794
Update to version 1.4.0
johnwmillr Apr 8, 2019
f1bbe65
Merge pull request #91 from HotGiardiniera/song-search-ordering
johnwmillr Apr 8, 2019
f7a152f
Make 'popularity' default artist search sort
johnwmillr Apr 20, 2019
0988e70
Hide sanitize_filename method
johnwmillr Apr 20, 2019
5253952
Remove old song search method
johnwmillr Apr 20, 2019
d0b3948
Make dict merge py3.4 compatible
johnwmillr Apr 20, 2019
ca41e77
Check that lyrics section was found
johnwmillr Apr 20, 2019
e36482f
Merge pull request #95 from johnwmillr/add-success-check-for-lyrics-s…
johnwmillr Apr 20, 2019
387d878
Add test for Queen artist search
johnwmillr May 4, 2019
e03d864
added producer_artists to song.py
Jiafi May 30, 2019
bb7d3cf
changed property to be lower case
Jiafi May 30, 2019
18110b2
Fix double underscore typo
johnwmillr Jun 17, 2019
892031b
Add producer_artists test
johnwmillr Jun 17, 2019
79dd130
Update version to 1.5.2
johnwmillr Jun 17, 2019
49f7d57
Merge pull request #98 from Jiafi/master
johnwmillr Jun 17, 2019
810ce74
Added get_referents() and get_song_annotations()
ludehon Jul 18, 2019
72d00c5
Improve search sorting to grab most likely artist search result
johnwmillr Jul 18, 2019
3ca2b68
Merge branch 'master' into fix-switching-artist-bug
johnwmillr Jul 18, 2019
d0c380c
Merge pull request #103 from johnwmillr/fix-switching-artist-bug
johnwmillr Jul 18, 2019
4cb9e6d
Add tests for get_referents and get_annotation
johnwmillr Aug 5, 2019
047c25c
Add tsandefer's project to the README
johnwmillr Aug 12, 2019
2b04f55
Remove 'text_format' param from get_referents
johnwmillr Aug 24, 2019
1d135fc
Add test_get_song_annotations
johnwmillr Aug 24, 2019
e86b3c3
Update version to 1.7.0
johnwmillr Aug 24, 2019
81cd5c2
Merge branch 'master' into annotations
johnwmillr Aug 24, 2019
97ff429
Merge pull request #102 from ludehon/annotations
johnwmillr Aug 24, 2019
0e5a525
Add to_json() method
johnwmillr Oct 6, 2019
22a82bd
added 'ensure_ascii' as optional parameter to save_lyrics()-function …
floese Oct 13, 2019
ba4d192
Added boolean to get an artist features
danielcliu Nov 5, 2019
f5b5844
Add Jupyter notebooks to .gitignore
johnwmillr Nov 9, 2019
ebfba10
Split saving json and text into separate functions
johnwmillr Nov 9, 2019
d1d5bb5
Move sanitize_filename to utils file
johnwmillr Nov 9, 2019
a66a9fd
Move to_json and to_text to separate functions
johnwmillr Nov 9, 2019
14aec3b
Update tests for saving files
johnwmillr Nov 9, 2019
c891cd0
Update to 1.8.0
johnwmillr Nov 9, 2019
8ecf79d
Merge pull request #122 from johnwmillr/save-as-single-json-object
johnwmillr Nov 9, 2019
85de300
Add missing import in artist.py
johnwmillr Nov 9, 2019
9c38bfb
Searches should first look to exactly match requested name
danielcliu Nov 25, 2019
234865f
Cleaned up changes to tests
danielcliu Nov 25, 2019
d91b524
Removed unnecessary prints
danielcliu Nov 25, 2019
d6fc366
Cleaned up return from _get_item_from_search_response
danielcliu Nov 26, 2019
2180a03
Update to 1.7.1
johnwmillr Dec 11, 2019
8fef8f2
Merge branch 'master' into bug-fix/118-return-precise-requested-name
johnwmillr Dec 11, 2019
a65c0fb
Merge pull request #123 from danielcliu/bug-fix/118-return-precise-re…
johnwmillr Dec 11, 2019
1d58aa3
Merge pull request #1 from johnwmillr/master
danielcliu Dec 17, 2019
e5933ed
Updated readme and add test for include features
danielcliu Dec 17, 2019
3dd26eb
Merge branch 'master' into feature/119-artist-features
danielcliu Dec 17, 2019
e24df6d
Updated version
danielcliu Dec 17, 2019
62b721c
pass sanitize param to Song.to_*() methods in Song.save_lyrics()
AdamSpannbauer Feb 1, 2020
4fbfe80
Increase timeout on tests to 15 s
Apr 22, 2020
b28b02d
Increase sleep time on tests to 1.0 s
Apr 22, 2020
59c04e5
Update to 1.8.3
johnwmillr May 4, 2020
ba35dab
Update to 1.8.5
johnwmillr May 4, 2020
ee6f0c7
Merge branch 'master' into master
johnwmillr May 4, 2020
1789c3f
Merge pull request #131 from AdamSpannbauer/master
johnwmillr May 4, 2020
3e08a37
Added Genius's new div class
allerter May 21, 2020
69073c2
Update to 1.8.6
johnwmillr May 27, 2020
30a39f1
Merge pull request #142 from Allerter/patch-1
johnwmillr May 27, 2020
cf0f95d
download no songs when 0 is specified
uhlikfil Jul 8, 2020
4b0dc1e
Created RTD-style docs, documented classes and methods, added some us…
allerter Aug 20, 2020
78d90c6
Docs requirements file
allerter Aug 20, 2020
4e54ab0
update linking to class
allerter Aug 20, 2020
59ca33a
Revert "Docs requirements file"
allerter Aug 20, 2020
52e89ef
changed code-block color to sphinx's
allerter Aug 20, 2020
e59acec
Added Sphinx docs requirements file
allerter Aug 20, 2020
bcf27f8
changed docs highlight-language to python3
allerter Aug 20, 2020
d167dc5
sphinx docs requirements file
allerter Aug 20, 2020
9ff343f
added printing details when scraping lyrics fails
allerter Aug 22, 2020
99329ac
Update to 1.8.9
johnwmillr Aug 22, 2020
1ef42a1
Merge branch 'uhlikfil-master'
johnwmillr Aug 22, 2020
d7a4609
Require new_song to have a .featured_artists value if including_features
johnwmillr Aug 23, 2020
7682e19
Merge branch 'master' into feature/119-artist-features
johnwmillr Aug 23, 2020
c1f6f64
Merge pull request #124 from danielcliu/feature/119-artist-features
johnwmillr Aug 23, 2020
d71a956
Use regular expression for new_div's class name
eeishaan Aug 23, 2020
c87d6b5
added tox file
allerter Aug 23, 2020
8d7a4df
Merge branch 'master' into add-documentation
johnwmillr Aug 24, 2020
ed639a1
fixed typo in artist.add_song() parameters
allerter Aug 26, 2020
71f3cd9
added How It Works page,
allerter Aug 28, 2020
4086ae9
fixed issues displayed by tox -e lint
allerter Aug 28, 2020
010e755
added content to docs home page
allerter Aug 28, 2020
5723366
Update conf.py
johnwmillr Aug 29, 2020
6a5ac4e
Change 'name' to 'title' in lyrics search
johnwmillr Aug 29, 2020
67af407
Update how_it_works.rst
johnwmillr Aug 29, 2020
c0967f3
Update api.rst
johnwmillr Aug 29, 2020
362aedb
Update genius.rst
johnwmillr Aug 29, 2020
187e810
changed lyrics.get_text() separator to "\n"
allerter Aug 30, 2020
82e782c
added "Text Formatting" page
allerter Aug 31, 2020
690d16e
Add Read the Docs badge and link to README
johnwmillr Aug 31, 2020
03c8d06
Merge pull request #153 from Allerter/add-documentation
johnwmillr Aug 31, 2020
8687995
Update LICENSE to 2020
johnwmillr Aug 31, 2020
74eae9f
Fix docs link in README
johnwmillr Aug 31, 2020
421d8b9
added raising for status in HTTP requests,
allerter Sep 1, 2020
e3b07f2
added test for http error handler,
allerter Sep 2, 2020
43c50ba
added _validate_token function
allerter Sep 2, 2020
c8b18ad
Update LICENSE to 2020
johnwmillr Aug 31, 2020
4b225e1
Fix docs link in README
johnwmillr Aug 31, 2020
30ea9a7
added auth
allerter Sep 5, 2020
7c58b67
added voting methods for annotations
allerter Sep 6, 2020
56fd759
renamed client_access_token to access_token
allerter Sep 9, 2020
07a5368
added documentation for authorization,
allerter Sep 9, 2020
70c265a
fixed instance parse_redirected_url didn't work with 'token' flow
allerter Sep 9, 2020
e9bea81
added OAuth2 documentation,
allerter Sep 9, 2020
ef2c1bc
Merge remote-tracking branch 'origin/complete_api' into complete_api
allerter Sep 9, 2020
04ee8e7
Update to origin (#3)
allerter Sep 9, 2020
d2e99bb
removed Authenticating yourself from snippets,
allerter Sep 11, 2020
ca62bc7
Revert "removed Authenticating yourself from snippets,"
allerter Sep 11, 2020
b940565
added missing comma
allerter Sep 11, 2020
0b290ce
added more missing commas
allerter Sep 11, 2020
1622798
added missing word in sippets
allerter Sep 11, 2020
49733bf
changed get_user_auth_url to auth.url property,
allerter Sep 11, 2020
cb6477c
changed calling get_user_auth_url to url
allerter Sep 11, 2020
163e7ae
fixed client_only_app not in OAuth2 attributes
allerter Sep 11, 2020
40f01f7
fixed parse_redirected_url
allerter Sep 11, 2020
fd9f4f2
set None in POST body params when optional annotation parameteres are…
allerter Sep 11, 2020
4855d68
Improved _get_item_from_search_response
allerter Sep 12, 2020
722b962
removed using _result_is_match when comparing results
allerter Sep 12, 2020
2f39bae
revert to current _make_request
allerter Sep 16, 2020
4308267
fixed typo
allerter Sep 16, 2020
3dfd9fa
added some docs, fixed new methods' payload
allerter Sep 16, 2020
4f57ff4
fixed response for 204 response,
allerter Sep 16, 2020
a6a8cc9
fixed added test bugs
allerter Sep 16, 2020
e523027
fixed update_annotation and added its test,
allerter Sep 16, 2020
f51267d
added example redirect uri to snippets
allerter Sep 16, 2020
b16933b
Merge branch 'master' into patch-1
allerter Sep 19, 2020
cb3f5d1
Reversed changes of last commit
allerter Sep 19, 2020
6304fdb
Merge branch 'eeishaan-patch-1'
johnwmillr Sep 20, 2020
282f30d
Update to 2.0.1
johnwmillr Sep 20, 2020
0965546
Updated release_notes for 2.0.1
allerter Sep 22, 2020
4fb1792
Update to origin (#5)
allerter Sep 22, 2020
10caf04
Added PublicAPI
allerter Sep 22, 2020
5d81f00
Switched to using tox for Travis CI script
allerter Sep 22, 2020
6d771ed
Update .travis.yml
allerter Sep 22, 2020
c1df3c6
fixed flake8 errors
allerter Sep 22, 2020
fc321a6
Merge branch 'public_api' of https://github.com/Allerter/LyricsGenius…
allerter Sep 22, 2020
ebd27ca
fixed rest of flake8 errors
allerter Sep 22, 2020
430644a
added pytest to tox command
allerter Sep 22, 2020
698aeca
fixed import in tests
allerter Sep 22, 2020
9e6d319
fixed super?
allerter Sep 22, 2020
083f131
add tox to gitignore
allerter Sep 22, 2020
107222a
added Sender class,
allerter Sep 23, 2020
666ff2c
added base file
allerter Sep 23, 2020
1c5cbde
set public_api=True in public_methods requests
allerter Sep 23, 2020
235d30b
fixed video method,
allerter Sep 23, 2020
a0ce510
temp fix for initializing API's Sender,
allerter Sep 23, 2020
c988087
fixed calls of artist_songs throughout Genius and API
allerter Sep 23, 2020
0879889
fixed initializing Genius, etc
allerter Sep 24, 2020
cc1947c
update test_genius
allerter Sep 24, 2020
366198b
added public methods tests,
allerter Sep 24, 2020
e321e05
commit changes
allerter Sep 24, 2020
94d8c76
reverted back to assert for now
allerter Sep 24, 2020
3574ff8
fixed tests,
allerter Sep 24, 2020
ee50659
fixed voters misplaced parameter in request call
allerter Sep 24, 2020
22ef03f
changed _scrape_song_lyrics_from_url to lyrics,
allerter Sep 25, 2020
cfead7f
added some docs,
allerter Sep 25, 2020
767bfa6
Reformatted Artist to implement Artist.get_song
allerter Sep 25, 2020
d2a44eb
changed get_song to song,
allerter Sep 25, 2020
7b78a6f
switched to unittest for tox tests,
allerter Sep 25, 2020
6e59579
fixed ModuleNotFoundError in tests
allerter Sep 25, 2020
924e6da
added warning for unavailable methods
allerter Sep 26, 2020
26f2fbc
Update to origin (#6)
allerter Sep 26, 2020
30bd6c3
Merge branch 'master' into public_api
allerter Sep 26, 2020
4e42d4d
added Sender docs
allerter Sep 26, 2020
df16540
fixed release_notes formatting
allerter Sep 26, 2020
a4fb807
Merge branch 'master' into master
allerter Sep 26, 2020
7f96f79
Remove incorrect parameter to to_text()
allerter Sep 26, 2020
4c881b4
added ensure_ascii to all other methods
allerter Sep 26, 2020
b43d0d4
updated release_notes and version
allerter Sep 26, 2020
a9106f6
Fixed typo in release_notes
allerter Sep 26, 2020
02e456a
Delete GLOB-0.log
johnwmillr Sep 26, 2020
de26208
Use the Oxford comma
johnwmillr Sep 26, 2020
fe59bff
Add release date
johnwmillr Sep 26, 2020
04f0fb4
Merge pull request #113 from floese/master
johnwmillr Sep 26, 2020
63de0ad
Merge branch 'master' into http_error_handler
allerter Sep 26, 2020
d23fc18
added docs for request errors,
allerter Sep 26, 2020
1cd8dff
Make all base classes inherit from object
johnwmillr Sep 26, 2020
2f88ff8
Merge pull request #160 from Allerter/public_api
johnwmillr Sep 26, 2020
d798a97
Merge branch 'Allerter-public_api'
johnwmillr Sep 26, 2020
5311083
Merge branch 'non-song-filtering'
allerter Sep 26, 2020
f3ed9b2
Revert "Merge branch 'non-song-filtering'"
allerter Sep 26, 2020
fb652e8
Resolve conflicts between master and http_error_handler
johnwmillr Sep 27, 2020
9fdd7e6
Remove outdated tests
johnwmillr Sep 27, 2020
30269b5
Remove reference to outdated method
johnwmillr Sep 27, 2020
2ddd9d7
Merge pull request #156 from Allerter/http_error_handler
johnwmillr Sep 27, 2020
94129a9
Merge remote-tracking branch 'upstream/master'
allerter Sep 27, 2020
5f1ca61
Merge branch 'master' into non-song-filtering
allerter Sep 27, 2020
098ae19
updated to fit origin
allerter Sep 27, 2020
a7ce352
Revert "updated to fit origin"
allerter Sep 27, 2020
5581385
Merge branch 'master' into http_error_handler
allerter Sep 27, 2020
bb873eb
update to fit origin
allerter Sep 27, 2020
7e3d357
reorder imports
allerter Sep 27, 2020
329cd9b
add changes
allerter Sep 27, 2020
ab03bcc
Merge pull request #156 from Allerter/http_error_handler
johnwmillr Sep 27, 2020
790c8f3
Merge branch 'master' into non-song-filtering
johnwmillr Sep 27, 2020
a059514
Merge pull request #158 from Allerter/non-song-filtering
johnwmillr Sep 27, 2020
9eec430
Merge remote-tracking branch 'upstream/master'
allerter Sep 27, 2020
4a9e575
Merge branch 'master' into complete_api
allerter Sep 27, 2020
6e669f7
commit changes
allerter Sep 27, 2020
0b46aef
add text_format to API annotation methods
allerter Sep 27, 2020
ce26634
fixed prompt_user bug
allerter Sep 28, 2020
66868e9
fix flake8 error
allerter Sep 28, 2020
1605c6d
fixed bugs, added auth tests
allerter Sep 28, 2020
c150213
fix test_url error
allerter Sep 28, 2020
634786a
fix wrong function name
allerter Sep 28, 2020
8665216
removed test_url
allerter Sep 28, 2020
e3bfe06
Merge pull request #159 from Allerter/complete_api
johnwmillr Sep 29, 2020
f9c08ba
reconfigured types and added album, added retries and etc (#162)
allerter Nov 6, 2020
00e44c9
Fixed issue with printing unicode (#126)
DarrelDonald Nov 7, 2020
47109a3
Fixed issues in #126 (#170)
allerter Nov 8, 2020
4b89d42
v3.0 (#171)
allerter Feb 9, 2021
f6963b9
match index with type in _get_item_from_search_response
allerter Mar 7, 2021
9bfec98
improve docs for search methods
allerter Mar 7, 2021
e3afbbb
fixed test_search_song failing with changes
allerter Mar 7, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Bug report
about: Describe a bug associated with LyricsGenius

---

**Describe the bug**
Write a clear and concise description of what the bug is.

**Expected behavior**
Write a clear and concise description of what you expected to happen.

**To Reproduce**
Describe the steps required to reproduce the behavior.
1. Step one...
2. Step two...

Include the error message associated with the bug.

**Version info**
- Package version [`import lyricsgenius; print(lyricsgenius.__version__)`]
- OS: [e.g. macOS, Windows, etc.]

**Additional context**
Add any other context about the problem here.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea for improving LyricsGenius

---

**Is your feature request related to a problem? Please describe.**
Write a clear and concise description of what the problem is -- e.g. "I'm always frustrated when [...]"

**Describe the solution you'd like**
Write a clear and concise description of what you want to happen.

**Describe alternatives you've considered**
Write a clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
16 changes: 14 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
# OSX
# macOS
*.DS_Store

# API credentials
*.ini

# May not want to commit lyrics text files
*.txt
*.json

# Jupyter
/Notebooks
.ipynb_checkpoints/
*.ipynb

# Test files
.cache/
.tox
lyricsgenius.egg-info
fixtures

# Python module things
*.pyc
*.pyc

# Python cache stuff
*.egg-info
__pycache__
dist
build
.idea
13 changes: 2 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
language: python
python:
- "2.7"
before_install:
- openssl aes-256-cbc -K $encrypted_e334385ab253_key -iv $encrypted_e334385ab253_iv
-in credentials.ini.enc -out credentials.ini -d

install: pip install -r requirements.txt
install: pip install .[dev]

script: python -m unittest discover

notifications:
email:
- [email protected]
script: tox
2 changes: 1 addition & 1 deletion LICENSE → LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 John W. Miller
Copyright (c) 2020 John W. Miller

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
169 changes: 107 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,82 +1,127 @@
# Scraping song lyrics from Genius.com
# LyricsGenius: a Python client for the Genius.com API
[![Build Status](https://travis-ci.org/johnwmillr/LyricsGenius.svg?branch=master)](https://travis-ci.org/johnwmillr/LyricsGenius)
[![Documentation Status](https://readthedocs.org/projects/lyricsgenius/badge/?version=master)](https://lyricsgenius.readthedocs.io/en/latest/?badge=master)
[![PyPI version](https://badge.fury.io/py/lyricsgenius.svg)](https://pypi.org/project/lyricsgenius/)
[![Python version](https://img.shields.io/badge/python-3.x-brightgreen.svg)](https://pypi.org/project/lyricsgenius/)

[![Build Status](https://travis-ci.org/johnwmillr/GeniusAPI.svg?branch=master)](https://travis-ci.org/johnwmillr/GeniusAPI)
`lyricsgenius` provides a simple interface to the song, artist, and lyrics data stored on [Genius.com](https://www.genius.com).

The full documentation for `lyricsgenius` is available online at [Read the Docs](https://lyricsgenius.readthedocs.io/en/master/).

## Setup
This repository is intended to provide an easy interface for programatically accessing the song information stored on [Genius.com](https://www.genius.com). Check out [my blog post](http://www.johnwmillr.com/blog/2017/scraping-genius-lyrics) for a more thorough description of the package and its usage.
Before using this package you'll need to sign up for a (free) account that authorizes access to [the Genius API](http://genius.com/api-clients). The Genius account provides a `access_token` that is required by the package. See the [Usage section](https://github.com/johnwmillr/LyricsGenius#usage) below for examples.

## Installation
`lyricsgenius` requires Python 3.

Start by cloning this repo:
Use `pip` to install the package from PyPI:

```bash
git clone https://github.com/johnwmillr/GeniusAPI.git
pip install lyricsgenius
```

To use the Genius API you'll need to sign up for a (free) client that authorizes you to [access their API](http://genius.com/api-clients). Fill out the ```credentials.ini``` file using the API client info you were assigned.
Or, install the latest version of the package from GitHub:

```bash
pip install git+https://github.com/johnwmillr/LyricsGenius.git
```

## Usage
Import the package and initiate Genius:

You can read through the [Genius API docs](https://docs.genius.com/), but I've found it more helpful to start by looking at code folks have already written for the API. I found [this post](https://bigishdata.com/2016/09/27/getting-song-lyrics-from-geniuss-api-scraping) from @jackschultz and [this repository](https://github.com/jasonqng/genius-lyrics-search) from @JasonQNg real helpful while getting started, check their work out.
```python
import lyricsgenius
genius = lyricsgenius.Genius(token)
```

If you don't pass a token to the `Genius` class, `lyricsgenus` will look for an environment variable called `GENIUS_ACCESS_TOKEN` and attempt to use that for authentication.

## Scraping lyrics
I'm most interested in a simple interface for pulling song lyrics from the website. It'd be nice to be able to enter a song and artist name and have the lyrics saved to a text file. Maybe we'd be interested in getting all lyrics associated with a single artist.
```python
genius = Genius()
```

Genius doesn't actually provide a way to access the lyrics using their API directly ([they have to pay royalties on the lyrics](https://www.nytimes.com/2014/05/07/business/media/rap-genius-website-agrees-to-license-with-music-publishers.html?ref=oembed&_r=0)), but it doesn't take much more work to scrape the HTML after finding the song URLs we're interested in. The python functions below both start by using the Genius API to search for a song's URL and then scraping that URL for lyrics using [BeautifulSoup](https://www.crummy.com/software/BeautifulSoup/bs4/doc/).
Search for songs by a given artist:

## Usage
### Python module
```python
>>> import genius
>>> api = genius.Genius()
>>> artist = api.search_artist('Andy Shauf',max_songs=5)
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 = genius.search_artist("Andy Shauf", max_songs=3, sort="title")
print(artist.songs)
```
By default, the `search_artist()` only returns songs where the given artist is the primary artist.
However, there may be instances where it is desirable to get all of the songs that the artist appears on.
You can do this by setting the `include_features` argument to `True`.

### Command line
```python
artist = genius.search_artist("Andy Shauf", max_songs=3, sort="title", include_features=True)
print(artist.songs)
```
$ python genius/api.py --search_song 'Begin Again' 'Andy Shauf'
Searching for "Begin Again" by Andy Shauf...
Done.
"Begin Again" by Andy Shauf:
Begin again
This time you should take a bow at the very end
Its quite an act you put on
Wait til the cameras roll...

$ python genius/api.py --search_artist 'Lupe Fiasco'
Searching for Lupe Fiasco...

Song 1: "1st & 15th"
Song 2: "4 Real"
Song 3: "A Bathing Harry"
Song 4: "Absolute Freestyle"
Song 5: "Accept the Troubles"

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

Done.
Lupe Fiasco, 5 songs

Search for a single song by the same artist:

```python
song = artist.song("To You")
# or:
# song = genius.search_song("To You", artist.name)
print(song.lyrics)
```

Add the song to the artist object:

```python
artist.add_song(song)
# the Artist object also accepts song names:
# artist.add_song("To You")
```

Save the artist's songs to a JSON file:

```python
artist.save_lyrics()
```

Searching for an album and saving it:

```python
album = genius.search_album("The Party", "Andy Shauf")
album.save_lyrics()
```

There are various options configurable as parameters within the `Genius` class:

```python
genius.verbose = False # Turn off status messages
genius.remove_section_headers = True # Remove section headers (e.g. [Chorus]) from lyrics when searching
genius.skip_non_songs = False # Include hits thought to be non-songs (e.g. track lists)
genius.excluded_terms = ["(Remix)", "(Live)"] # Exclude songs with these words in their title
```

You can also call the package from the command line:

```bash
export GENIUS_ACCESS_TOKEN="my_access_token_here"
python3 -m lyricsgenius --help
```

Search for and save lyrics to a given song and album:

```bash
python3 -m lyricsgenius song "Begin Again" "Andy Shauf" --save
python3 -m lyricsgenius album "The Party" "Andy Shauf" --save
```

Search for five songs by 'The Beatles' and save the lyrics:

```bash
python3 -m lyricsgenius artist "The Beatles" --max-songs 5 --save
```

## Example projects

- [Trucks and Beer: A textual analysis of popular country music](http://www.johnwmillr.com/trucks-and-beer/)
- [Neural machine translation: Explaining the Meaning Behind Lyrics](https://github.com/tsandefer/dsi_capstone_3)
- [What makes some blink-182 songs more popular than others?](http://jdaytn.com/posts/download-blink-182-data/)
- [Sentiment analysis on hip-hop lyrics](https://github.com/Hugo-Nattagh/2017-Hip-Hop)
- [Does Country Music Drink More Than Other Genres?](https://towardsdatascience.com/does-country-music-drink-more-than-other-genres-a21db901940b)
- [49 Years of Lyrics: Why So Angry?](https://towardsdatascience.com/49-years-of-lyrics-why-so-angry-1adf0a3fa2b4)

## Contributing
Please contribute! If you want to fix a bug, suggest improvements, or add new features to the project, just [open an issue](https://github.com/johnwmillr/LyricsGenius/issues) or send me a pull request.
Binary file removed credentials.ini.enc
Binary file not shown.
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = src
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=src
set BUILDDIR=build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sphinx==3.3.0
sphinx-rtd-theme==0.5.0
Binary file added docs/src/404.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions docs/src/404.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.. image:: 404.png


Whoops!
========
The page you're looking for doesn't exist. Let's go
:ref:`home <index>`.

.. toctree::
:maxdepth: 1
:hidden:
:caption: Library

reference
release_notes

.. toctree::
:maxdepth: 1
:hidden:
:caption: Guide

setup
usage
contributing


.. _Genius.com: https://www.genius.com
Loading