Fix Last.fm listening fetch parameters

This commit is contained in:
svemagie
2026-03-08 06:26:14 +01:00
parent e54624f7c0
commit b3525b6944
2 changed files with 16 additions and 16 deletions
+8 -8
View File
@@ -12,10 +12,10 @@ const LASTFM_USERNAME = process.env.LASTFM_USERNAME || "";
/** /**
* Fetch from Indiekit's public Last.fm API endpoint * Fetch from Indiekit's public Last.fm API endpoint
*/ */
async function fetchFromIndiekit(endpoint) { async function fetchFromIndiekit(path) {
const urls = [ const urls = [
`${INDIEKIT_URL}/lastfmapi/api/${endpoint}`, `${INDIEKIT_URL}/lastfmapi/api/${path}`,
`${INDIEKIT_URL}/lastfm/api/${endpoint}`, `${INDIEKIT_URL}/lastfm/api/${path}`,
]; ];
for (const url of urls) { for (const url of urls) {
@@ -25,11 +25,11 @@ async function fetchFromIndiekit(endpoint) {
duration: "15m", duration: "15m",
type: "json", type: "json",
}); });
console.log(`[lastfmActivity] Indiekit ${endpoint} success via ${url}`); console.log(`[lastfmActivity] Indiekit ${path} success via ${url}`);
return data; return data;
} catch (error) { } catch (error) {
console.log( console.log(
`[lastfmActivity] Indiekit API unavailable for ${endpoint} at ${url}: ${error.message}` `[lastfmActivity] Indiekit API unavailable for ${path} at ${url}: ${error.message}`
); );
} }
} }
@@ -44,9 +44,9 @@ export default async function () {
// Fetch all data from Indiekit API // Fetch all data from Indiekit API
const [nowPlaying, scrobbles, loved, stats] = await Promise.all([ const [nowPlaying, scrobbles, loved, stats] = await Promise.all([
fetchFromIndiekit("now-playing"), fetchFromIndiekit("now-playing"),
fetchFromIndiekit("scrobbles"), fetchFromIndiekit("scrobbles?period=alltime&limit=10"),
fetchFromIndiekit("loved"), fetchFromIndiekit("loved?limit=10"),
fetchFromIndiekit("stats"), fetchFromIndiekit("stats?period=alltime"),
]); ]);
// Check if we got data // Check if we got data
+8 -8
View File
@@ -12,10 +12,10 @@ const LASTFM_USERNAME = process.env.LASTFM_USERNAME || "";
/** /**
* Fetch from Indiekit's public Last.fm API endpoint * Fetch from Indiekit's public Last.fm API endpoint
*/ */
async function fetchFromIndiekit(endpoint) { async function fetchFromIndiekit(path) {
const urls = [ const urls = [
`${INDIEKIT_URL}/lastfmapi/api/${endpoint}`, `${INDIEKIT_URL}/lastfmapi/api/${path}`,
`${INDIEKIT_URL}/lastfm/api/${endpoint}`, `${INDIEKIT_URL}/lastfm/api/${path}`,
]; ];
for (const url of urls) { for (const url of urls) {
@@ -25,11 +25,11 @@ async function fetchFromIndiekit(endpoint) {
duration: "15m", duration: "15m",
type: "json", type: "json",
}); });
console.log(`[lastfmActivity] Indiekit ${endpoint} success via ${url}`); console.log(`[lastfmActivity] Indiekit ${path} success via ${url}`);
return data; return data;
} catch (error) { } catch (error) {
console.log( console.log(
`[lastfmActivity] Indiekit API unavailable for ${endpoint} at ${url}: ${error.message}` `[lastfmActivity] Indiekit API unavailable for ${path} at ${url}: ${error.message}`
); );
} }
} }
@@ -44,9 +44,9 @@ export default async function () {
// Fetch all data from Indiekit API // Fetch all data from Indiekit API
const [nowPlaying, scrobbles, loved, stats] = await Promise.all([ const [nowPlaying, scrobbles, loved, stats] = await Promise.all([
fetchFromIndiekit("now-playing"), fetchFromIndiekit("now-playing"),
fetchFromIndiekit("scrobbles"), fetchFromIndiekit("scrobbles?period=alltime&limit=10"),
fetchFromIndiekit("loved"), fetchFromIndiekit("loved?limit=10"),
fetchFromIndiekit("stats"), fetchFromIndiekit("stats?period=alltime"),
]); ]);
// Check if we got data // Check if we got data