Swap to multiple streaming platforms

This commit is contained in:
JP Hastings-Spital 2024-10-21 11:40:32 +01:00
parent 1c2181dfb5
commit 29199c7c55
8 changed files with 70 additions and 22 deletions

View file

@ -8,4 +8,4 @@ tags:
---
likes Bop 'Enjoy The Moment' (Thinnen Remix) [Remix Competition Winner] by Med School Music
{{< soundcloud path="/tracks/986177" artist="Med School Music" title="Bop 'Enjoy The Moment'" url="https://songwhip.com/medschoolmusic/bop-enjoy-the-moment-remix-competition-winner">}}
{{< music "66a4bf39-d0f4-4006-b649-21808845b3bf" >}}

View file

@ -2,7 +2,9 @@
"title": "Get A Wiggle On",
"artist": "HENGE",
"musicbrainz": "https://musicbrainz.org/recording/013efa85-b7f5-4f95-809b-ff47c53726a9",
"spotify": "https://open.spotify.com/track/62sJsTpsZ81vLnJQ0xuqWY",
"applemusic": "https://music.apple.com/gbus/song/1668860445",
"youtubemusic": "https://music.youtube.com/watch?v=1BQviCBPMSk"
"links": [
"https://open.spotify.com/track/62sJsTpsZ81vLnJQ0xuqWY",
"https://music.apple.com/gb/song/1668860445",
"https://music.youtube.com/watch?v=1BQviCBPMSk"
]
}

View file

@ -2,7 +2,9 @@
"title": "Peach",
"artist": "salute",
"musicbrainz": "https://musicbrainz.org/recording/31387690-27f2-4966-95e3-eaf83192378e",
"spotify": "https://open.spotify.com/track/5cGZN0P1QnSfhCFBCHtp2N",
"applemusic": "https://music.apple.com/gb/album/peach/1676610854?i=1676611187",
"youtubemusic": "https://music.youtube.com/watch?v=4SOeAzErjxM"
"links": [
"https://open.spotify.com/track/5cGZN0P1QnSfhCFBCHtp2N",
"https://music.apple.com/gb/album/peach/1676610854?i=1676611187",
"https://music.youtube.com/watch?v=4SOeAzErjxM"
]
}

View file

@ -0,0 +1,12 @@
{
"title": "Enjoy the Moment (Thinnen remix)",
"artist": "BOP",
"musicbrainz": "https://musicbrainz.org/recording/66a4bf39-d0f4-4006-b649-21808845b3bf",
"links": [
"https://open.spotify.com/track/09kytpdyU1kz9kMXTh2xsf",
"https://soundcloud.com/medschoolmusic/bop-enjoy-the-moment-thinnen-remix-competition-winner",
"https://music.apple.com/gb/song/1686476816",
"https://music.youtube.com/watch?v=JjNtkLIiC18"
],
"soundcloudtrackid": "986177"
}

View file

@ -3,7 +3,9 @@
"artist": "Borodin Quartet",
"composer": "Alexander Borodin",
"musicbrainz": "https://musicbrainz.org/recording/bfbd2167-db3a-469a-a0a3-3fdeacbd4344",
"spotify": "https://open.spotify.com/track/7Hi4r3EULEJfLrwli8iw5Q",
"applemusic": "https://music.apple.com/gb/album/string-quartet-no-2-in-d-major-iii-nocturne-andante/1452699105?i=1452699113",
"youtubemusic": "https://music.youtube.com/watch?v=T1aZdvRWEcc&si=HVI4SivmbVCa9Jev"
"links": [
"https://open.spotify.com/track/7Hi4r3EULEJfLrwli8iw5Q",
"https://music.apple.com/gb/album/string-quartet-no-2-in-d-major-iii-nocturne-andante/1452699105?i=1452699113",
"https://music.youtube.com/watch?v=T1aZdvRWEcc"
]
}

View file

@ -2,7 +2,9 @@
"album": "Kaleidoscope",
"artist": "Kelis",
"musicbrainz": "https://musicbrainz.org/release/e0de1616-0514-43b3-a2ce-9e7cf0fc1e64",
"spotify": "https://open.spotify.com/album/33viW1sFm3sCCmzs7FZ9MI",
"applemusic": "https://music.apple.com/gb/album/kaleidoscope-expanded-edition/1712490712",
"youtubemusic": "https://music.youtube.com/playlist?list=OLAK5uy_kkW-cvsQIeox0qb4BREdvllFVaIZy9A30"
"links": [
"https://open.spotify.com/album/33viW1sFm3sCCmzs7FZ9MI",
"https://music.apple.com/gb/album/kaleidoscope-expanded-edition/1712490712",
"https://music.youtube.com/playlist?list=OLAK5uy_kkW-cvsQIeox0qb4BREdvllFVaIZy9A30"
]
}

View file

@ -3,16 +3,38 @@
{{- $displayArtist := .composer | default .artist -}}
{{- $displayTitle := .title | default .album -}}
{{- $musicbrainz := .musicbrainz -}}
{{- with .spotify -}}
{{- $klass := "" -}}
{{- $embed := "" -}}
{{- range .links -}}
{{- $u := urls.Parse . -}}
<figure class="embed audio spotify">
<iframe src="https://open.spotify.com/embed{{ $u.Path }}" height="80" frameBorder="0" allowfullscreen="" allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture" loading="lazy"></iframe>
<figcaption>
🎶 {{ $displayArtist }}{{ with $displayTitle }}{{ if $displayArtist }}: {{ end }}<em>{{ . }}</em>{{ end }}<br/>
{{ with $musicbrainz }}<a href="{{ . }}" target="_blank" style="font-style:italic;">Listen elsewhere</a>{{ end }}
</figcaption>
</figure>
{{- if eq $u.Hostname "sopen.spotify.com" -}}
{{- $klass = "spotify" -}}
{{- $embed = printf "<iframe src='https://open.spotify.com/embed%s' height='80' frameBorder='0' allowfullscreen=' allow='autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture' loading='lazy'></iframe>" $u.Path -}}
{{- break -}}
{{- else if eq $u.Hostname "smusic.apple.com" -}}
{{- $klass = "apple-music" -}}
{{- $embed = printf "<iframe allow='autoplay *; encrypted-media *; fullscreen *; clipboard-write' frameborder='0' height='160' style='width:100%%;max-width:660px;overflow:hidden;border-radius:10px;' sandbox='allow-forms allow-popups allow-same-origin allow-scripts allow-storage-access-by-user-activation allow-top-navigation-by-user-activation' src='https://embed.music.apple.com%s'></iframe>" $u.Path -}}
{{- break -}}
{{- else if and (eq $u.Hostname "soundcloud.com") (isset $data "soundcloudtrackid") -}}
{{- $klass = "soundcloud" -}}
{{- $embed = printf "<iframe src='https://w.soundcloud.com/player/?url=https%%3A//api.soundcloud.com/tracks/%s&auto_play=false&hide_related=true&show_comments=false&show_user=false&show_reposts=false&show_teaser=false&visual=false' loading='lazy' scrolling='no' frameborder='no' allow='autoplay'></iframe>" $data.soundcloudtrackid -}}
{{- break -}}
{{- end -}}
{{- end -}}
<figure class="embed audio {{$klass}}">
{{ $embed | safeHTML }}
<figcaption>
🎶 {{ $displayArtist }}{{ with $displayTitle }}{{ if $displayArtist }}: {{ end }}<em>{{ . }}</em>{{ end }}<br/>
{{ with $musicbrainz }}<a href="{{ . }}" target="_blank" style="font-style:italic;">Listen elsewhere</a>{{ end }}
</figcaption>
</figure>
{{- else -}}
{{ errorf "Missing musicbrainz data for %s" (.Get 0) }}
{{- end -}}

View file

@ -29,7 +29,13 @@ Things I might work on within my personal blog's software.
- [ ] Remove lychee failing links
- [ ] Import Facebook posts
- [ ] Songwhip is dead 😭 replace with something else
- Musicbrainz will be good eg. [using release IDs](https://musicbrainz.org/ws/2/recording/013efa85-b7f5-4f95-809b-ff47c53726a9?inc=artist-credits%20url-rels&fmt=json) — but doesn't appear to have composer info (eg. [here](https://musicbrainz.org/ws/2/recording/bfbd2167-db3a-469a-a0a3-3fdeacbd4344?inc=artist-credits%20url-rels&fmt=json))
- [x] Approach complete. Use Musicbrainz
- Annoyingly soundcloud URLs don't include the data needed to create an embed, so have to add that manually
- [ ] Auto-import from UUID [using release IDs](https://musicbrainz.org/ws/2/recording/013efa85-b7f5-4f95-809b-ff47c53726a9?inc=artist-credits%20artist-rels%20url-rels&fmt=json) — more complex to get composer info (eg. [here](https://musicbrainz.org/ws/2/recording/bfbd2167-db3a-469a-a0a3-3fdeacbd4344?inc=artist-credits%20artist-rels%20url-rels%20work-rels%20work-level-rels&fmt=json))
- `composer: .relations[type=performance].work.relations[type=composer].name`
- `title: .title` (Or album, if path is `/release` not `/recording`)
- `artist: .artist-credit.name`
- `links: .relations[type="free streaming"|"streaming"].url.resource`
### Done ✓