1
Fork 0

Upgrade spotify shortcode to new API

This commit is contained in:
Jake Howard 2018-01-14 21:10:29 +00:00
parent 12ab03e05d
commit ef2d1a5704
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 21 additions and 18 deletions

View file

@ -6,5 +6,5 @@ At the arena, we had music playing in the background, through the competition st
<!--more-->
{{% spotify "spotify:user:theorangeone97:playlist:4ZaS9NTwF1erqqpE1IxHlP" %}}
{{% spotify "theorangeone97" "4ZaS9NTwF1erqqpE1IxHlP" %}}

View file

@ -1,16 +1,17 @@
{{ $ident := .Get 0 }}
{{ $user := .Get 0 }}
{{ $playlist_id := .Get 1 }}
{{ $playlist := getJSON "http://spotify-public-proxy.theorangeone.net/playlist/" $ident }}
{{ $playlist := getJSON "http://spotify-public-proxy.theorangeone.net/v1/users/" $user "/playlists/" $playlist_id }}
<div class="playlist">
<a href="{{ $playlist.url }}">
<a href="{{ $playlist.external_urls.spotify }}">
<h3>
{{ $playlist.name }}
</h3>
</a>
<table class="table table-hover table-striped">
<caption><a href="{{ $playlist.url }}">View playlist on Spotify</a></caption>
<caption><a href="{{ $playlist.external_urls.spotify }}">View playlist on Spotify</a></caption>
<thead>
<tr>
<th scope="row">Track</th>
@ -20,19 +21,21 @@
</tr>
</thead>
<tbody>
{{ range sort $playlist.tracks "name" }}
<tr>
<td><a href="{{ .url }}">{{ .name }}</a></td>
<td>
{{ range $i, $e := .artists }}{{ if $i }}, {{ end }}{{ .name }}{{ end }}
</td>
<td>{{ .album.name }}</td>
<td>
<audio controls class="mejs__player" data-plyr='{"controls": ["play", "progress"]}'>
<source src="{{ .preview_url }}" type="audio/mpeg" />
</audio>
</td>
</tr>
{{ range sort $playlist.tracks.items "track.name" }}
{{ with .track }}
<tr>
<td><a href="{{ .external_urls.spotify }}">{{ .name }}</a></td>
<td>
{{ range $i, $e := .artists }}{{ if $i }}, {{ end }}{{ .name }}{{ end }}
</td>
<td>{{ .album.name }}</td>
<td>
<audio controls class="mejs__player" data-plyr='{"controls": ["play", "progress"]}'>
<source src="{{ .preview_url }}" type="audio/mpeg" />
</audio>
</td>
</tr>
{{ end }}
{{ end }}
</tbody>
</table>