maloja support
This commit is contained in:
parent
b7820a4739
commit
7ff0398324
2 changed files with 17 additions and 0 deletions
|
|
@ -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"),
|
||||
},
|
||||
];
|
||||
|
|
|
|||
11
utils.js
11
utils.js
|
|
@ -26,3 +26,14 @@ export async function getJsonFeedItemContent(feedUrl) {
|
|||
})?.trim();
|
||||
return 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}<br />by ${artists.join(", ")}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue