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--> <!--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"> <div class="playlist">
<a href="{{ $playlist.url }}"> <a href="{{ $playlist.external_urls.spotify }}">
<h3> <h3>
{{ $playlist.name }} {{ $playlist.name }}
</h3> </h3>
</a> </a>
<table class="table table-hover table-striped"> <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> <thead>
<tr> <tr>
<th scope="row">Track</th> <th scope="row">Track</th>
@ -20,19 +21,21 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{ range sort $playlist.tracks "name" }} {{ range sort $playlist.tracks.items "track.name" }}
<tr> {{ with .track }}
<td><a href="{{ .url }}">{{ .name }}</a></td> <tr>
<td> <td><a href="{{ .external_urls.spotify }}">{{ .name }}</a></td>
{{ range $i, $e := .artists }}{{ if $i }}, {{ end }}{{ .name }}{{ end }} <td>
</td> {{ range $i, $e := .artists }}{{ if $i }}, {{ end }}{{ .name }}{{ end }}
<td>{{ .album.name }}</td> </td>
<td> <td>{{ .album.name }}</td>
<audio controls class="mejs__player" data-plyr='{"controls": ["play", "progress"]}'> <td>
<source src="{{ .preview_url }}" type="audio/mpeg" /> <audio controls class="mejs__player" data-plyr='{"controls": ["play", "progress"]}'>
</audio> <source src="{{ .preview_url }}" type="audio/mpeg" />
</td> </audio>
</tr> </td>
</tr>
{{ end }}
{{ end }} {{ end }}
</tbody> </tbody>
</table> </table>