From 7ff0398324a1a28ab2d84b1b66ac0da9ba7fc78c Mon Sep 17 00:00:00 2001 From: Melanie Kat <318003+ZicklePop@users.noreply.github.com> Date: Wed, 17 Dec 2025 18:39:27 -0800 Subject: [PATCH] maloja support --- config.js | 6 ++++++ utils.js | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/config.js b/config.js index 424bd13..0146bf5 100644 --- a/config.js +++ b/config.js @@ -1,6 +1,7 @@ import { getJsonFeedItemContent, getJsonFeedItemTitle, + getMalojaScrobble, markdownLinkRegex, } from "./utils.js"; @@ -23,4 +24,9 @@ export const items = [ getLatest: async () => getJsonFeedItemContent("https://melkat.lol/feed.json"), }, + { + id: "maloja", + regex: markdownLinkRegex("scrobbles.melkat.dev"), + getLatest: async () => getMalojaScrobble("https://scrobbles.melkat.dev"), + }, ]; diff --git a/utils.js b/utils.js index 8229358..8e7b2aa 100644 --- a/utils.js +++ b/utils.js @@ -26,3 +26,14 @@ export async function getJsonFeedItemContent(feedUrl) { })?.trim(); return image ? `![${title}](${image}) ${title}` : title; } + +export async function getMalojaScrobble(malojaUrl) { + const res = await fetch(`${malojaUrl}/apis/mlj_1/scrobbles?perpage=1`); + const data = await res.json(); + const scrobble = data.list[0]; + const { + title, + album: { artists }, + } = scrobble.track; + return `${title}
by ${artists.join(", ")}`; +}