From d6a70f54369e19c2622be4291392fad790faccfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Sun, 19 Feb 2023 17:49:52 +0100 Subject: [PATCH] feat: show fav music from listory --- content/listory.md | 14 +++++- layouts/partials/extend_head.html | 32 ++++++++++++ layouts/shortcodes/current-day.html | 2 + layouts/shortcodes/listory-albums.html | 31 ++++++++++++ layouts/shortcodes/listory-genres.html | 30 ++++++++++++ static/listen.svg | 68 ++++++++++++++++++++++++++ 6 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 layouts/partials/extend_head.html create mode 100644 layouts/shortcodes/current-day.html create mode 100644 layouts/shortcodes/listory-albums.html create mode 100644 layouts/shortcodes/listory-genres.html create mode 100644 static/listen.svg diff --git a/content/listory.md b/content/listory.md index efcb94c..90cdb0e 100644 --- a/content/listory.md +++ b/content/listory.md @@ -3,4 +3,16 @@ title: "My Favorite Music" type: listory --- -> Work in Progress +Last Update: {{< current-day >}} + +The data on this page reflects my listens from Spotify. I track the data using a +self-hosted instance of [Listory](https://github.com/apricote/listory). All data +is coming from the listens of the 30 days prior to the last update time. + +### My favorite genres + +{{< listory-genres >}} + +### My favorite albums + +{{< listory-albums >}} diff --git a/layouts/partials/extend_head.html b/layouts/partials/extend_head.html new file mode 100644 index 0000000..c35365a --- /dev/null +++ b/layouts/partials/extend_head.html @@ -0,0 +1,32 @@ + diff --git a/layouts/shortcodes/current-day.html b/layouts/shortcodes/current-day.html new file mode 100644 index 0000000..56e1527 --- /dev/null +++ b/layouts/shortcodes/current-day.html @@ -0,0 +1,2 @@ + +{{ now.Format "2006-01-02T15:04:05" }} diff --git a/layouts/shortcodes/listory-albums.html b/layouts/shortcodes/listory-albums.html new file mode 100644 index 0000000..5d5d68d --- /dev/null +++ b/layouts/shortcodes/listory-albums.html @@ -0,0 +1,31 @@ +{{ $listoryApi := getenv "HUGO_LISTORY_HOST" }}{{ $listoryToken := getenv +"HUGO_LISTORY_TOKEN" }} {{ $res := getJSON +"https://listory.apricote.de/api/v1/reports/top-albums?timePreset=last_30_days" +(dict "Authorization" (printf "Bearer %s" $listoryToken) ) }} + +
    + {{ range first 5 $res.items }} +
  1. +
    +
    + {{ .album.name | title }} - {{ range .album.artists }}{{.name}}{{ end }} +
    +
    + {{ .count }} +
    +
    +
    +
  2. + {{ end }} +
diff --git a/layouts/shortcodes/listory-genres.html b/layouts/shortcodes/listory-genres.html new file mode 100644 index 0000000..6ad159f --- /dev/null +++ b/layouts/shortcodes/listory-genres.html @@ -0,0 +1,30 @@ +{{ $listoryApi := getenv "HUGO_LISTORY_HOST" }}{{ $listoryToken := getenv +"HUGO_LISTORY_TOKEN" }} {{ $res := getJSON +"https://listory.apricote.de/api/v1/reports/top-genres?timePreset=last_30_days" +(dict "Authorization" (printf "Bearer %s" $listoryToken) ) }} + +
    + {{ range first 5 $res.items }} +
  1. +
    +
    {{ .genre.name | title }}
    +
    + {{ .count }} +
    +
    +
    + {{ range first 3 .artists }}{{.artist.name}} {{ + end }} +
    +
  2. + {{ end }} +
diff --git a/static/listen.svg b/static/listen.svg new file mode 100644 index 0000000..821b748 --- /dev/null +++ b/static/listen.svg @@ -0,0 +1,68 @@ + + + + + + + + image/svg+xml + + + + + + + + +