From 9741f29b239db6bd73cb3c33d93769ec7fb15423 Mon Sep 17 00:00:00 2001 From: johnwmillr Date: Tue, 20 Feb 2018 22:24:13 -0600 Subject: [PATCH] Update files for PyPI --- LICENSE => LICENSE.txt | 0 {genius => lyricsgenius}/__init__.py | 0 lyricsgenius/__main__.py | 37 ++++++++++++++++++++++++++++ {genius => lyricsgenius}/api.py | 0 {genius => lyricsgenius}/artist.py | 0 {genius => lyricsgenius}/song.py | 0 setup.cfg | 0 setup.py | 14 +++++------ 8 files changed, 44 insertions(+), 7 deletions(-) rename LICENSE => LICENSE.txt (100%) rename {genius => lyricsgenius}/__init__.py (100%) create mode 100644 lyricsgenius/__main__.py rename {genius => lyricsgenius}/api.py (100%) rename {genius => lyricsgenius}/artist.py (100%) rename {genius => lyricsgenius}/song.py (100%) create mode 100644 setup.cfg diff --git a/LICENSE b/LICENSE.txt similarity index 100% rename from LICENSE rename to LICENSE.txt diff --git a/genius/__init__.py b/lyricsgenius/__init__.py similarity index 100% rename from genius/__init__.py rename to lyricsgenius/__init__.py diff --git a/lyricsgenius/__main__.py b/lyricsgenius/__main__.py new file mode 100644 index 00000000..850d8787 --- /dev/null +++ b/lyricsgenius/__main__.py @@ -0,0 +1,37 @@ +# Command line usage: +# $python -m lyricsgenius --search_song 'Begin Again' 'Andy Shauf' +# $python -m lyricsgenius --search_artist 'Lupe Fiasco' 3 + +import sys +import os +import lyricsgenius as genius + +def main(args=None): + if args is None: + args = sys.argv[1:] + + client_access_token = os.environ.get("GENIUS_CLIENT_ACCESS_TOKEN", None) + assert client_access_token is not None, "Must declare environment variable: GENIUS_CLIENT_ACCESS_TOKEN" + api = genius.Genius(client_access_token) + + # There must be a standard way to handle "--" inputs on the command line + if sys.argv[1] == '--search-song': + if len(sys.argv) == 4: + song = api.search_song(sys.argv[2],sys.argv[3]) + elif len(sys.argv) == 3: + song = api.search_song(sys.argv[2]) + print('"{title}" by {artist}:\n {lyrics}'.format(title=song.title,artist=song.artist,lyrics=song.lyrics.replace('\n','\n '))) + elif sys.argv[1] == '--search-artist': + if len(sys.argv) == 4: + max_songs = int(sys.argv[3]) + else: + max_songs = 5 + artist = api.search_artist(sys.argv[2], max_songs=max_songs) + print("Saving {} lyrics...".format(artist.name)) + api.save_artist_lyrics(artist) + else: + print("Usage: python -m lyricsgenius [--search-song song_name] [--search-artist artist_name num_songs]") + return + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/genius/api.py b/lyricsgenius/api.py similarity index 100% rename from genius/api.py rename to lyricsgenius/api.py diff --git a/genius/artist.py b/lyricsgenius/artist.py similarity index 100% rename from genius/artist.py rename to lyricsgenius/artist.py diff --git a/genius/song.py b/lyricsgenius/song.py similarity index 100% rename from genius/song.py rename to lyricsgenius/song.py diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..e69de29b diff --git a/setup.py b/setup.py index 95df77fa..b8008422 100644 --- a/setup.py +++ b/setup.py @@ -11,16 +11,16 @@ requirements = f.read().splitlines() setup( - name='geniuslyrics', - version='0.0', - description='GeniusLyrics', + name='lyricsgenius', + version='0.1', + description='Download lyrics and metadata from Genius.com', long_description=README, classifiers=[ 'Programming Language :: Python', # TODO ], author='John W. Miller', - author_email='', - url='https://github.com/johnwmillr/GeniusAPI', + author_email='john.w.millr@gmail.com', + url='https://github.com/johnwmillr/lyricsgenius', keywords='genius api music lyrics artists albums songs', packages=find_packages(), include_package_data=True, @@ -28,6 +28,6 @@ install_requires=requirements, entry_points={ 'console_scripts': [ - 'genius-api = genius.api:main'] + 'lyricsgenius = lyricsgenius.__main__:main'] }, -) \ No newline at end of file +)