Giter VIP home page Giter VIP logo

spotifyexporter's Introduction

SpotifyExporter

This repo contains a set of PowerShell Azure Functions which export Spotify user data (playlists and user library) to .csv files in Azure Blob Storage.

The SpotifyExporter application requires the creation of 3 secrets in order to configure the Azure Function to export your Spotify library:

  • Spotify Developer Application Client ID
  • Spotify Developer Application Client Secret
  • Spotify User OAuth 2 Refresh Token

Spotify Web API Authorization

Register Spotify Developer Application

Users must obtain a Client ID and Client Secret by registering a Spotify App, as well as an OAuth 2 Refresh token using the Authorization Code Flow.

If you don't know what to use as a Redirect URI, http://localhost:8080/spotifyexporter is a good default.

Once you have created your app, use the Client ID, Client Secret, and Redirect URI as the parameters for Get-SpotifyRefreshToken.ps1 in the following section.

Obtain Refresh Token for a Spotify user

  1. Download this repo to your local machine by clicking the Green Code button and choosing Download ZIP.
  2. Unzip SpotifyExporter.zip to any folder on your computer.
  3. Install or open PowerShell.
    • If you have a Windows computer, launch it by pressing Win + R and typing powershell.
    • If you have a MacOS computer, install PowerShell. Launch PowerShell by pressing Cmd + Space and typing PowerShell.
  4. Navigate to the folder where you extracted SpotifyExporter.zip using the cd command.
    • Example: cd ./Downloads/SpotifyExporter.
  5. Execute the Get-SpotifyRefreshToken.ps1 script using the values obtained from your Spotify Developer Application.
    • Example:
./auth/Get-SpotifyRefreshToken.ps1 -ClientId 'c0b51074872b4822b30fe887ce857b47' -ClientSecret '397c93a60153496abbc1458ac1978655' -RedirectUri 'http://localhost:8080/spotifyexporter'

The users's default web browser will open and request them to sign into Spotify, granting read access to their profile for the Spotify Developer Application they registered.

Users can also execute Get-SpotifyRefreshToken.ps1 with the -ManualAuth switch parameter to prevent the web browser automatically opening. This method will prompt the user to paste a URL into their web browser manually, and then paste the redirect URL into the PowerShell console.

After completing the login process, the user will receive an OAuth 2 Refresh Token in their PowerShell console. This Refresh Token should be treated as a secret and stored in a safe place. It will be required in the next step: Azure Resource Manager Custom Deployment.

Deploy SpotifyExporter resources to Azure

This application can be deployed directly to Azure as a PowerShell Function App.

Deploy to Azure

Provide the Spotify Client Id, Spotify Client Secret, and Spotify Refresh Token obtained above as the required parameters for the Azure Resource Manager Custom Deployment.

Sample Azure Template Deployment

  • To enable diagnostic logging to an Azure Log Analytics Workspace, set the Logs Enabled deployment parameter to true.
    • Incurs additional cost for log ingestion and storage.
  • To enable data export to a free-tier Azure Cosmos DB NoSQL Database, set the Cosmos Enabled deployment parameter to true.
  • To disable data export to Azure Storage as .csv files, set the Storage Export Enabled deployment parameter to false.

Contact and Contribute

If you run into any issues with this repo, please open an issue or pull request.

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.