Giter Site home page Giter Site logo

spotifylyrics's Introduction

Note: this project is now obsolete as Spotify has first party support for lyrics in their desktop and mobile apps.

SpotifyLyrics

Display lyrics for your currently playing Spotify track within a Streamlit webapp.

Preview

Setup and Requirements

This project was built and tested with Python 3.9 on Windows and Mac. The primary external modules used are streamlit, spotipy, lyricsgenius, and python-dotenv. You will need your own Spotify and Genius.com app tokens.

If you're not familiar with setting up a virtual environment and pip installing packages, follow the guide below:

  1. Download this project
  2. Create a Python virtual environment called \venv within the project directory. Open terminal/cmd, cd into this directory, and create the virtual environment:
    • Streamlit is recommended to run in a virtual environment and behaves strangely when the global environment is used
    • Windows: python -m venv venv
    • Mac: python3 -m venv venv
  3. Activate the new virtual environment:
    • Windows: venv\Scripts\activate.bat
    • Mac: source ./bin/activate
  4. Install dependencies using pip: pip install -r setup\requirements.txt, and allow several seconds to complete

Next, we need to acquire our tokens and store them locally in an environment file:

  1. In the project directory, rename the .env_sample file to .env and open with a text editor
  2. To set the SPOTIPY_CLIENT_ID and SPOTIPY_CLIENT_SECRET values, visit https://developer.spotify.com/dashboard/applications and create a new app
    • Ensure the redirect URI matches between the app you create and the .env file
    • https://google.com should be fine
  3. To set the GENIUS_TOKEN value, browse to https://genius.com/api-clients and create a new app
  4. Save the file

Launching App and First Time Use

To launch the application, Windows users can double-click the start.bat file in the project's root directory.

To launch manually, ensure your terminal has the virtual environment active and the current directory is the project's directory, then issue this command: streamlit run main.py.

On first launch, (or whenever the .cache file is not found), you will need to sign in to Spotify. When Streamlit is launched, your default browser will open a new Streamlit window. A secondary tab will open, prompting to sign in to Spotify. After signing in, you will be forwarded to the redirect URI with a code appended (e.g. https://www.google.com/?code=xxxxx). Copy this entire url and paste in your terminal, where you should see a prompt like the following: Enter the URL you were redirected to: . After hitting enter, you should now be authenticated.

spotifylyrics's People

Contributors

twrogers1 avatar

Watchers

 avatar  avatar

spotifylyrics's Issues

Handle HTTP timeout

Timeout: Request timed out: HTTPSConnectionPool(host='genius.com', port=443): Read timed out. (read timeout=5)

Traceback:

File "/Users//Python-venv/python39/lib/python3.9/site-packages/streamlit/script_runner.py", line 350, in _run_script
exec(code, module.dict)
File "/Users//Desktop/Py Scripts/GitHub/SpotifyLyrics/main.py", line 91, in
main()
File "/Users//Desktop/Py Scripts/GitHub/SpotifyLyrics/main.py", line 70, in main
genius.fetch_lyrics(track.artist, track.song)
File "/Users//Desktop/Py Scripts/GitHub/SpotifyLyrics/APIs/lyrics.py", line 81, in fetch_lyrics
lyrics = self.lyrics(song_url=song_url)
File "/Users//Python-venv/python39/lib/python3.9/site-packages/lyricsgenius/genius.py", line 132, in lyrics
self._make_request(path, web=True).replace('
', '\n'),
File "/Users//Python-venv/python39/lib/python3.9/site-packages/lyricsgenius/api/base.py", line 84, in _make_request
raise Timeout(error)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.