Giter VIP home page Giter VIP logo

spotify-track-color's Introduction

spotify-track-color

This is a Firebase Cloud Function that extracts the main color from the track currently being played on Spotify.

Setup

  • Create a new project on https://developer.spotify.com/
  • Create a new project on http://console.firebase.google.com/
  • Clone this repository
  • Run firebase init to associate the directory into your Firebase project
  • Copy the .env.example file into a new .env file and replace the placeholder values with information from your Spotify project

Usage

To use the function, simply make a POST request to the endpoint with the desired parameters. Be sure to set the secret_key in the request headers (the same secret key from your .env file).

Parameters

The function accepts two optional parameters in the request body: from and colors.

from

The from parameter allows you to select the algorithm for the color selection. You can specify one of the following values:

  • album: this is the default option, it extracts the dark proeminent color from the track album image
  • lyrics: determines a color based on feeling analysis from the track lyrics, falling back to album color if no lyrics are found for the track

colors

The colors parameter allows you to restrict the response to a set of colors. The response will be the color from the array which is closest to the track color. It must be specified as an array of hexadecimal color codes (e.g. #ff0000).

Example request body

{
  "from": "album",
  "colors": ["#ff0000", "#00ff00", "#0000ff"]
}

Response

The function will return a JSON object with the color property, as in the example below:

{
  "color": "#0000ff"
}

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.