Merge branch 'main' of git@github.com:cdransf/coryd.dev.git

This commit is contained in:
Cory Dransfeldt 2024-05-27 16:23:27 -07:00
commit 3f0549a08c
13 changed files with 149 additions and 1200 deletions

View file

@ -1,3 +1,3 @@
{
"timestamp": 1716753812315
"timestamp": 1716840220620
}

View file

@ -13447,9 +13447,9 @@
},
"https://coryd.dev/now?ts=2024-21#artists": {
"id": "aHR0cHM6Ly9jb3J5ZC5kZXYvbm93P3RzPTIwMjQtMjEjYXJ0aXN0cw==",
"title": "🎧: My top artists for the week: Fugazi @ 20 plays, fleshwater @ 16 plays, NoMeansNo @ 14 plays, American Football @ 4 plays",
"title": "🎧: My top artists for the week: Disillusion @ 36 plays, Glassing @ 35 plays, Nucleus @ 30 plays, NoMeansNo @ 30 plays, Built to Spill @ 27 plays, blink-182 @ 24 plays, Gravenchalice @ 22 plays, Fugazi @ 20 plays",
"url": "https://coryd.dev/now?ts=2024-21#artists",
"content_text": "🎧: My top artists for the week: Fugazi @ 20 plays, fleshwater @ 16 plays, NoMeansNo @ 14 plays, American Football @ 4 plays #Music https://coryd.dev/now?ts=2024-21#artists",
"content_text": "🎧: My top artists for the week: Disillusion @ 36 plays, Glassing @ 35 plays, Nucleus @ 30 plays, NoMeansNo @ 30 plays, Built to Spill @ 27 plays, blink-182 @ 24 plays, Gravenchalice @ 22 plays, Fugazi @ 20 plays #Music https://coryd.dev/now?ts=2024-21#artists",
"date_published": "Mon, 20 May 2024 00:00:00 GMT",
"toots": [
"https://social.lol/users/cory/statuses/112470524335862859"
@ -13697,5 +13697,60 @@
"https://social.lol/users/cory/statuses/112509177840235810"
],
"lastTootTimestamp": 1716753812307
},
"https://coryd.dev/now?ts=2024-22#artists": {
"id": "aHR0cHM6Ly9jb3J5ZC5kZXYvbm93P3RzPTIwMjQtMjIjYXJ0aXN0cw==",
"title": "🎧: My top artists for the week: Fawn Limbs @ 50 plays, blink-182 @ 45 plays, Home Is Where @ 38 plays, Deftones @ 36 plays, Cloud Rat @ 33 plays, The Get Up Kids @ 32 plays, Spawn of Possession @ 31 plays, Ataraxy @ 29 plays",
"url": "https://coryd.dev/now?ts=2024-22#artists",
"content_text": "🎧: My top artists for the week: Fawn Limbs @ 50 plays, blink-182 @ 45 plays, Home Is Where @ 38 plays, Deftones @ 36 plays, Cloud Rat @ 33 plays, The Get Up Kids @ 32 plays, Spawn of Possession @ 31 plays, Ataraxy @ 29 plays #Music https://coryd.dev/now?ts=2024-22#artists",
"date_published": "Mon, 27 May 2024 00:00:00 GMT",
"toots": [
"https://social.lol/users/cory/statuses/112510161462605024"
],
"lastTootTimestamp": 1716768821218
},
"https://coryd.dev/music?ts=2024-22": {
"id": "aHR0cHM6Ly9jb3J5ZC5kZXYvbXVzaWM/dHM9MjAyNC0yMg==",
"title": "🎧: My top artists for the week: Fawn Limbs @ 50 plays, blink-182 @ 45 plays, Home Is Where @ 38 plays, Deftones @ 36 plays, Cloud Rat @ 33 plays, The Get Up Kids @ 32 plays, Spawn of Possession @ 31 plays, Ataraxy @ 29 plays",
"url": "https://coryd.dev/music?ts=2024-22",
"content_text": "🎧: My top artists for the week: Fawn Limbs @ 50 plays, blink-182 @ 45 plays, Home Is Where @ 38 plays, Deftones @ 36 plays, Cloud Rat @ 33 plays, The Get Up Kids @ 32 plays, Spawn of Possession @ 31 plays, Ataraxy @ 29 plays https://coryd.dev/music?ts=2024-22",
"date_published": "Mon, 27 May 2024 00:00:00 GMT",
"toots": [
"https://social.lol/users/cory/statuses/112510639001676450"
],
"lastTootTimestamp": 1716776107843
},
"https://coryd.dev/watching/movies/424139": {
"id": "aHR0cHM6Ly9jb3J5ZC5kZXYvd2F0Y2hpbmcvbW92aWVzLzQyNDEzOQ==",
"title": "🎥: Halloween (⭐️⭐️⭐️)",
"url": "https://coryd.dev/watching/movies/424139",
"content_text": "🎥: Halloween (⭐️⭐️⭐️) #Movies #Watched https://coryd.dev/watching/movies/424139",
"date_published": "Mon, 27 May 2024 13:30:00 GMT",
"toots": [
"https://social.lol/users/cory/statuses/112514840693592035"
],
"lastTootTimestamp": 1716840220612
},
"https://coryd.dev/music?ts=2024-22#artists": {
"id": "aHR0cHM6Ly9jb3J5ZC5kZXYvbXVzaWM/dHM9MjAyNC0yMiNhcnRpc3Rz",
"title": "🎧: My top artists for the week: Fawn Limbs @ 50 plays, blink-182 @ 45 plays, Home Is Where @ 38 plays, Deftones @ 36 plays, Cloud Rat @ 33 plays, The Get Up Kids @ 32 plays, Spawn of Possession @ 31 plays, Ataraxy @ 29 plays",
"url": "https://coryd.dev/music?ts=2024-22#artists",
"content_text": "🎧: My top artists for the week: Fawn Limbs @ 50 plays, blink-182 @ 45 plays, Home Is Where @ 38 plays, Deftones @ 36 plays, Cloud Rat @ 33 plays, The Get Up Kids @ 32 plays, Spawn of Possession @ 31 plays, Ataraxy @ 29 plays #Music https://coryd.dev/music?ts=2024-22#artists",
"date_published": "Mon, 27 May 2024 00:00:00 GMT",
"toots": [
"https://social.lol/users/cory/statuses/112514335397152728"
],
"lastTootTimestamp": 1716832510391
},
"https://coryd.dev/music?ts=2024-21#artists": {
"id": "aHR0cHM6Ly9jb3J5ZC5kZXYvbXVzaWM/dHM9MjAyNC0yMSNhcnRpc3Rz",
"title": "🎧: My top artists for the week: Disillusion @ 36 plays, Glassing @ 35 plays, Nucleus @ 30 plays, NoMeansNo @ 30 plays, Built to Spill @ 27 plays, blink-182 @ 24 plays, Gravenchalice @ 22 plays, Fugazi @ 20 plays",
"url": "https://coryd.dev/music?ts=2024-21#artists",
"content_text": "🎧: My top artists for the week: Disillusion @ 36 plays, Glassing @ 35 plays, Nucleus @ 30 plays, NoMeansNo @ 30 plays, Built to Spill @ 27 plays, blink-182 @ 24 plays, Gravenchalice @ 22 plays, Fugazi @ 20 plays #Music https://coryd.dev/music?ts=2024-21#artists",
"date_published": "Mon, 20 May 2024 00:00:00 GMT",
"toots": [
"https://social.lol/users/cory/statuses/112514370833752430"
],
"lastTootTimestamp": 1716833051116
}
}

View file

@ -37,8 +37,7 @@ export const allContent = (collection) => {
const {
collections: { posts, links },
books,
movies: { movies },
weeklyArtistChart
movies: { movies }
} = data
const parseDate = (date) => {
if (!date) return null
@ -76,7 +75,6 @@ export const allContent = (collection) => {
addContent(links, '🔗', item => item.data.title, item => item.data.date)
addContent(books.filter(book => book.status === 'finished'), '📖', item => `${item.title}${item.rating ? ' (' + item.rating + ')' : ''}`, item => item.date)
addContent(movies, '🎥', item => `${item.title}${item.rating ? ' (' + item.rating + ')' : ''}`, item => item.lastWatched)
addContent(weeklyArtistChart, '🎧', item => item.title, item => item.date)
return aggregateContent.sort((a, b) => {
const dateA = a.date ? DateTime.fromISO(a.date) : DateTime.fromMillis(0)

View file

@ -6,21 +6,11 @@
publish = "_site"
edge_functions = "api"
###
# PLUGINS
###
[[plugins]]
package = "netlify-plugin-webmentions"
[plugins.inputs]
baseUrl = "https://coryd.dev"
feedPath = "feeds/posts"
limit = 1
###
# IMAGES
###
[images]
remote_images = ["https://f001.backblazeb2.com/file/coryd-dev/.*", "https://image.tmdb.org/.*", "https://books.google.com/.*", "https://covers.openlibrary.org/*"]
remote_images = ["https://f001.backblazeb2.com/file/coryd-dev/.*", "https://books.google.com/.*"]
###
# URLs

1110
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{
"name": "coryd.dev",
"version": "17.4.7",
"version": "17.4.11",
"description": "The source for my personal site. Built using 11ty.",
"type": "module",
"scripts": {
@ -27,7 +27,7 @@
"@daviddarnes/mastodon-post": "^1.3.0",
"@zachleat/webcare-webshare": "^1.0.3",
"minisearch": "^6.3.0",
"youtube-video-element": "^1.1.3"
"youtube-video-element": "^1.1.5"
},
"devDependencies": {
"@11ty/eleventy": "3.0.0-alpha.10",
@ -45,7 +45,6 @@
"markdown-it": "^14.1.0",
"markdown-it-anchor": "^9.0.1",
"markdown-it-footnote": "^4.0.0",
"netlify-plugin-webmentions": "^1.1.1",
"sanitize-html": "^2.13.0",
"sharp": "^0.33.4",
"slugify": "^1.6.6",

View file

@ -1,5 +1,6 @@
import { createClient } from '@supabase/supabase-js'
import { DateTime } from 'luxon'
import { sanitizeMediaString, parseCountryField } from '../../config/utilities/index.js'
const SUPABASE_URL = process.env.SUPABASE_URL
const SUPABASE_KEY = process.env.SUPABASE_KEY
@ -15,7 +16,7 @@ export default async function () {
image,
release_date,
release_link,
artists (name_string, genre, mbid)
artists (name_string, genre, mbid, country)
`)
.gt('release_date', today)
@ -30,6 +31,7 @@ export default async function () {
title: album['name'],
date: DateTime.fromISO(album['release_date']).toLocaleString(DateTime.DATE_FULL),
url: album['release_link'],
artist_url: `https://coryd.dev/music/artists/${sanitizeMediaString(album['artists']['name_string'])}-${sanitizeMediaString(parseCountryField(album['artists']['country']))}`,
genre: album['artists']['genre'],
mbid: album['artists']['mbid'],
timestamp: DateTime.fromISO(album['release_date']).toSeconds()

View file

@ -1,130 +0,0 @@
import { createClient } from '@supabase/supabase-js';
import { DateTime } from 'luxon'
const SUPABASE_URL = process.env.SUPABASE_URL
const SUPABASE_KEY = process.env.SUPABASE_KEY
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY)
const aggregateData = (data) => {
const aggregation = {}
data.forEach(item => {
const key = item['artist_name']
if (!aggregation[key]) {
aggregation[key] = {
name: item['artist_name'],
genre: item['artists']['genre'],
mbid: item['artists']['mbid'],
plays: 0
}
}
aggregation[key].plays++
})
return Object.values(aggregation).sort((a, b) => b.plays - a.plays).slice(0, 8)
}
const formatData = (data) => {
let content = 'My top artists for the week: '
let description = '<p>My top artists for the last week:</p><ul>'
data.forEach((artist, index) => {
content += `${artist['name']} @ ${artist['plays']} play${parseInt(artist['plays']) > 1 ? 's' : ''}`
description+= `<li>${artist['name']} @ ${artist['plays']}${artist['genre']}</li>`
if (index !== data.length - 1) content += ', '
})
description += '</ul>'
return { content, description }
}
export default async function() {
try {
const now = DateTime.now();
const startOfWeek = now.minus({ days: 7 }).startOf('day')
const endOfWeek = now.endOf('day')
const startOfWeekSeconds = startOfWeek.toSeconds()
const endOfWeekSeconds = endOfWeek.toSeconds()
const weekNumber = now.toFormat('kkkk-WW')
let { data: recentCharts } = await supabase
.from('weekly_charts')
.select('*')
.order('date', { ascending: false })
.limit(10);
if (now.weekday !== 1) return recentCharts.map(chart => {
const formattedData = formatData(JSON.parse(chart['data']))
return {
title: formattedData['content'],
description: formattedData['description'],
url: `https://coryd.dev/music?ts=${chart['week']}`,
date: chart['date']
}
})
if (recentCharts.some(chart => chart['week'] === weekNumber)) {
return recentCharts.map(chart => {
const formattedData = formatData(JSON.parse(chart['data']))
return {
title: formattedData['content'],
description: formattedData['description'],
url: `https://coryd.dev/music?ts=${chart['week']}`,
date: chart['date']
}
})
}
let { data: listens, error } = await supabase
.from('listens')
.select(`
listened_at,
track_name,
artist_name,
artists(mbid, genre)
`)
.gte('listened_at', startOfWeekSeconds)
.lte('listened_at', endOfWeekSeconds)
if (error) throw error
const aggregatedData = aggregateData(listens)
const artistNames = aggregatedData.map(artist => artist.name)
let { data: artistsData, error: artistsError } = await supabase
.from('artists')
.select('name_string, genre, mbid')
.in('name_string', artistNames)
if (artistsError) throw artistsError
const topArtists = aggregatedData.map(artist => {
return {
name: artist.name,
genre: artist?.genre || '',
plays: artist.plays,
mbid: artist?.mbid || ''
}
})
const { error: insertError } = await supabase
.from('weekly_charts')
.insert([{ week: weekNumber, date: now.toISODate(), data: JSON.stringify(topArtists) }])
if (insertError) throw insertError
const formattedData = formatData(topArtists)
const recentChartData = recentCharts.map(chart => {
const formattedData = formatData(JSON.parse(chart['data']))
return {
title: formattedData['content'],
description: formattedData['description'],
url: `https://coryd.dev/now?ts=${chart['week']}#artists`,
date: chart['date']
}
})
return [
{
title: formattedData['content'],
description: formattedData['description'],
url: `https://coryd.dev/now?ts=${weekNumber}#artists`,
date: now.toISODate()
},
...recentChartData
]
} catch (error) {
console.error('Error:', error.message)
}
}

View file

@ -11,10 +11,10 @@
{{ album.title }}
</a>
<span> by </span>
<a href="https://musicbrainz.org/artist/{{ album.mbid }}">
<a href="{{ album.artist_url }}">
{{ album.artist }}
</a>
<span> • {{ album.genre }}</span>
<span> • <a href="https://coryd.dev/music/genres/{{ album.genre | slugify | downcase }}">{{ album.genre }}</a></span>
</li>
{% endfor %}
</ul>

View file

@ -144,6 +144,10 @@
}
}
}
& .footnotes {
padding-bottom: 0;
}
}
@media screen and (min-width: 768px) {

View file

@ -1,13 +0,0 @@
---
layout: null
eleventyExcludeFromCollections: true
permalink: /feeds/weekly-artist-chart
---
{% render "partials/feeds/rss.liquid"
permalink:"/feeds/weekly-artist-chart"
title:"Weekly artist chart • Cory Dransfeldt"
description:"The top 8 artists I've listened to this week."
data:weeklyArtistChart
updated:weeklyArtistChart[0].date
site:site
%}

View file

@ -13,5 +13,4 @@ These are web feeds, also known as [RSS](https://en.wikipedia.org/wiki/RSS) or [
- Links ([RSS](https://feedpress.me/coryd-links) • [JSON](https://feedpress.me/coryd-links.json)): links I've liked.
- Books ([RSS](https://feedpress.me/coryd-books) • [JSON](https://feedpress.me/coryd-books.json)): books I'm currently reading.
- Movies ([RSS](https://feedpress.me/coryd-movies) • [JSON](https://feedpress.me/coryd-books.json)): movies I've watched recently.
- Artist charts ([RSS](https://feedpress.me/coryd-artist-charts) • [JSON](https://feedpress.me/coryd-artist-charts.json)): charts of the artists I've listened to each week.
- All ([RSS](https://feedpress.me/coryd-all) • [JSON](https://feedpress.me/coryd-all.json)): all of the posts and activity from my site.

View file

@ -13,7 +13,6 @@ schema: music
<p>This is everything I've been listening to recently — it's collected in a database as I listen to it and displayed here. <a href="https://coryd.dev/posts/2024/improving-my-self-hosted-scrobbling-implementation/">You can read more about the technical details, if you'd like.</a></p>
<p>I mostly listen to {{ genres | sortByPlaysDescending: "total_plays" | genreStrings: "name" | mediaLinks: "genre", 5 }}. This week I've listened to <strong class="highlight-text">{{ music.week.artists.size }} artists</strong>, <strong class="highlight-text">{{ music.week.albums.size }} albums</strong> and <strong class="highlight-text">{{ music.week.totalTracks }} tracks</strong>.</p>
{% render "partials/widgets/now-playing.liquid" %}
{% render "partials/banners/rss.liquid", url: "https://feedpress.me/coryd-artist-charts", text: "I also have a feed of weekly artist charts I generate from this data" %}
<hr class="large-spacing" />
<div class="section-header-wrapper">
<h2 id="artists" class="section-header no-top-margin flex-centered">