GithubHelp home page GithubHelp logo

cheehwatang / spotify-readme Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tthn0/spotify-readme

0.0 0.0 0.0 49 KB

A dynamic, customizable, and real-time Spotify now-playing widget made for GitHub markdown files!

Home Page: https://tthn0.vercel.app/api

License: GNU General Public License v3.0

Python 39.56% HTML 60.44%

spotify-readme's Introduction

Spotify Readme

Badge Badge Badge

A dynamic, customizable, and real-time Spotify now-playing widget for your README files that syncs with the song you’re currently playing. If you're not currently playing a song, it'll display one of your recent songs! Feel free to ask for help or make any PRs/issues/suggestions πŸ˜„

Previews

Default

/api

Preview

Spinning CD Effect

/api?spin=true

Preview

Include Scan Code

/api?scan=true

Preview

Rainbow Equalizer

/api?rainbow=true

Preview

Dark Theme

/api?theme=dark

Preview

Setup/Deployment

1. Spotify's API

  • Head over to the Spotify developer portal.
    • Create a Spotify application.
      • In the App name & App description fields, you may put whatever you want.
      • Agree with Spotify's TOS and click Create.
    • Take note of the Client ID & Client Secret.
    • Click Edit Settings.
      • Add http://localhost/callback/ to Redirect URIs.

2. Intermediary Steps

https://accounts.spotify.com/authorize?client_id={CLIENT_ID}&response_type=code&scope=user-read-currently-playing,user-read-recently-played&redirect_uri=http://localhost/callback/
  • Copy and paste the above link into your browser.

    • Replace {CLIENT_ID} with the Client ID you got from your Spotify application.
    • Vist the URL.
      • Log in if you're not already signed in.
      • Click Agree.
  • After you get redirected to a blank page, retrieve the URL from your browser's URL bar. It should be in the following format: http://localhost/callback/?code={CODE}.

    • Take note of the {CODE} portion of the URL.
  • Head over to base64.io.

    • Create a string in the form of {CLIENT_ID}:{CLIENT_SECRET} and encode it to base 64.
    • Take note of the encoded base 64 string.
  • If you're on Windows or don't have the curl command, head over to httpie.io/cli/run.

    • Press enter.
    • Clear the pre-filled command.
  • If you're on Linux or Mac with the curl command, open up your preferred terminal.

  • Run the following command (replace {BASE_64} and {CODE} with their respective values):

    curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: Basic {BASE_64}" -d "grant_type=authorization_code&redirect_uri=http://localhost/callback/&code={CODE}" https://accounts.spotify.com/api/token
    
  • If you did everything correctly, you should get a response in the form of a JSON object.

    • Take note of the refresh_token's value.

3. Host on Vercel

  • Fork this repository.
  • Head over to Vercel and create an account if you don't already have one.
    • Add a new project on Vercel.
      • Link your GitHub account if you haven't done so already.
      • Make sure Vercel has access to the forked respository.
      • Import the forked respository into your project.
        • Give it a meaningful project name.
        • Keep the default options for the other settings.
        • Add the following environment variables along with their appropriate values:
          • CLIENT_ID
          • CLIENT_SECRET
          • REFRESH_TOKEN
        • Click Deploy.
        • Click Continue to Dashboard.
          • Find the Domains field and take note of the URL.
            • Example: {PROJECT_NAME}.vercel.app.

4. Add to your GitHub

  • In any markdown file, add the following (replace {PROJECT_NAME} with the name you gave your Vercel project):

    <a href="https://github.com/tthn0/Spotify-Readme">
      <img src="https://{PROJECT_NAME}.vercel.app/api" alt="Current Spotify Song">
    </a>
  • Please leave the anchor tag hyperlink reference to this GitHub repo to retain creator credit and for other users to find!

Customization

To customize the widget, add query parameters to the endpoint. There are many possible combinations! See how it pairs with other widgets on my own README! (If you're on mobile and have a small screen, use a desktop browser or change the zoom level to zoom out.)

Parameter Default Values
spin false false, true
scan false false, true
theme light light, dark
rainbow false false, true

Note

This wasn't a completely original idea. This was inspired by novatorem's project that was supposed to be for me only. Since others have asked for the source code, I decided to make this a public repo. I also incorporated the latest two PR's from the orignal project into this one and made it easy to customize!

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.