2017 © Pedro Peláez
 

library spotify

A sweet Spotify suite built on Soda CMS

image

soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  • Monday, May 7, 2018
  • by Chaddles23
  • Repository
  • 4 Watchers
  • 0 Stars
  • 1,855 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 20 Versions
  • 22 % Grown

The README.md

Soda Spotify

A sweet spotify platform for Made in Katana, (*1)

Installation

1) Firstly follow the instructions to install Soda CMS at: https://github.com/soda-framework/cms, (*2)

2) Install Soda Spotify, (*3)

#!json
composer require soda-framework/spotify

3) Install these packages using NPM. These are needed for compiling the Vue Components in this package., (*4)

"vue-template-es2015-compiler": "1.3.1",
"vue": "^2.1.10",
"vue-template-compiler": "^2.1.10"
"axios": ""

4) Integrate Soda Spotify into laravel by adding Soda\Spotify\Providers\SpotifyServiceProvider::class in the providers array in /config/app.php, (*5)

    'providers' => [
        Soda\Providers\SodaServiceProvider::class,
        Soda\Spotify\Providers\SpotifyServiceProvider::class,
    ]

5) Run the database migrations php artisan migrate to generate the necessary tables., (*6)

6) In the CMS, go to the Spotify > Settings tab and specify the Package and Action that each created playlist should use. You can also specify the Playlist Title and Playlist Image (optional) for a playlist created on a user account., (*7)

Usage

Saving a Playlist

Include this file to create a link that will create a playlist on a users account., (*8)

#!php
@include('soda-spotify::save',compact('playlist'))

Or, you can pass in custom text/views/html to be displayed., (*9)

#!php
@include('soda-spotify::save',['playlist'=>$playlist, 'save_text'=>'Save Playlist', 'saved_text'=>'Playlist Saved'])

You can specify the Title and Image the created playlist will have by going to the Spotify > Settings tab and in the cms and editing the Playlist Title and Playlist Image (optional)., (*10)

This action will send them to Spotify and log them in. They will be sent back to the /playlist/ID page with, (*11)

#!php
$_GET['from_spotify']

present., (*12)

If this parameter is present AND the playlist has not already been listed as added (session), then it will add the playlist to the users account before sending them back to the playlist on the site., (*13)

Tracks

You need to include the Tracks component in your Javascript using Vue. e.g., (*14)

#!js
var Vue = require('vue');
var Tracks = require('../../../../../vendor/mik/spotify/resources/js/Components/Tracks.vue'); // path to the Tracks component
require('../vueConfig.js');

if( $('#playlist').length ) {
    var playlist_vm = new Vue({
        el: '#playlist',
        data: {
            token: document.head.querySelector("[name=csrf-token]").content,
        },
        created: function(){
            var me = this;
        },
        methods: {

        },
        components: {
            Tracks
        }
    });
}

Displaying the Player Interface, (*15)

#!php
@include('soda-spotify::tracks',compact('playlist'))

Or, you can pass in custom text act act as a title. e.g., (*16)

#!php
@include('soda-spotify::tracks',['playlist'=>$playlist, 'title'=>'Now Playing'])

Routes

Save Playlist

#!php
route('spotify.login',['url'=>URL_TO_RETURN_AFTER_LOGIN])

Get Playlist Tracks

#!php
route('spotify.api.tracks',['id'=>PLAYLIST_ID])

Response Screen Shot 2017-02-01 at 11.55.19 am.png, (*17)

Storing Track Data

Tracks need to be stored in the database in the JSON with the structure:

#!json

[{
    "id": "12D0n7hKpPcjuUpcbAKjjr",
    "name": "Don't Like.1",
    "preview_url": "https:\/\/p.scdn.co\/mp3-preview\/fef716a78bda6c3ce06f3a7b12d4ad5e47035984?cid=da37dbff0615468591361d57d2118b05",
    "uri": "spotify:track:12D0n7hKpPcjuUpcbAKjjr",
    "url": "https:\/\/open.spotify.com\/track\/12D0n7hKpPcjuUpcbAKjjr",
    "artists": [{
        "id": "5K4W6rqBFWDnAN6FQUkS6x",
        "name": "Kanye West",
        "uri": "spotify:artist:5K4W6rqBFWDnAN6FQUkS6x",
        "url": "https:\/\/open.spotify.com\/artist\/5K4W6rqBFWDnAN6FQUkS6x"
    }, {
        "id": "15iVAtD3s3FsQR4w1v6M0P",
        "name": "Chief Keef",
        "uri": "spotify:artist:15iVAtD3s3FsQR4w1v6M0P",
        "url": "https:\/\/open.spotify.com\/artist\/15iVAtD3s3FsQR4w1v6M0P"
    }],
}]

There is a function to convert an array of Spotify Created tracks JSON to this format, (*18)

#!php
Soda\Spotify\Components\Helpers::reduceResults($tracks); // $tracks is an array of Spotify Created track objects

Creating a Playlist

#!php
$playlist = \Soda\Spotify\Controllers\PlaylistController::create_seeded_playlist($seeds);

$seeds is an array of seeds as defined in https://developer.spotify.com/web-api/get-recommendations/., (*19)

e.g., (*20)

#!php
$seeds = [
    'target_valence'=>0.5,
    'seed_tracks'=>ARRAY_OF_SPOTIFY_TRACK_IDS
];

Important: You MUST have any one of seed_genres, seed_tracks or seed_artists., (*21)

The Versions

07/05 2018

dev-master

9999999-dev https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework

07/05 2018

1.1.0

1.1.0.0 https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework

28/03 2018

1.0.17

1.0.17.0 https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework

12/02 2018

1.0.16

1.0.16.0 https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework

01/02 2018

1.0.15

1.0.15.0 https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework

07/11 2017

1.0.14

1.0.14.0 https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework

18/10 2017

1.0.13

1.0.13.0 https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework

16/10 2017

1.0.12

1.0.12.0 https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework

16/10 2017

1.0.11

1.0.11.0 https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework

16/10 2017

1.0.10

1.0.10.0 https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework

13/10 2017

1.0.9

1.0.9.0 https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework

09/10 2017

1.0.8

1.0.8.0 https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework

29/09 2017

1.0.7

1.0.7.0 https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework

25/09 2017

1.0.6

1.0.6.0 https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework

20/09 2017

1.0.5

1.0.5.0 https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework

14/09 2017

1.0.4

1.0.4.0 https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework

12/09 2017

1.0.3

1.0.3.0 https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework

30/08 2017

1.0.2

1.0.2.0 https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework

30/08 2017

1.0.1

1.0.1.0 https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework

30/08 2017

1.0.0

1.0.0.0 https://github.com/soda-framework/spotify

A sweet Spotify suite built on Soda CMS

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ryan Brereton-Canham
by Jarrad Littleford
by Caleb Chadwick

framework spotify soda soda-framework