lastfm fix

This commit is contained in:
Soph :3 2024-08-03 00:18:56 +03:00
parent c0658e9f40
commit 5f57bb6e84
Signed by: sophie
GPG key ID: EDA5D222A0C270F2

View file

@ -43,10 +43,14 @@ const lastFM = {
); );
}, },
getRecentTracks: async (user) => { getRecentTracks: async (user) => {
const request = await Utils.fetch( try {
lastFM.constructUrl("User.getrecenttracks", { user, limit: 1 }) const request = await Utils.fetch(
); lastFM.constructUrl("User.getrecenttracks", { user, limit: 1 })
return await request.json(); );
return await request.json();
} catch {
return undefined;
}
}, },
}; };
@ -82,9 +86,10 @@ export function LastfmWidget(monitor = 0) {
}); });
Utils.interval( Utils.interval(
2150, 5000,
() => { () => {
lastFM.getRecentTracks("yourfriendoss").then((z) => { lastFM.getRecentTracks("yourfriendoss").then((z) => {
if(!z) return;
const track = z.recenttracks.track[0]; const track = z.recenttracks.track[0];
if (!track) return; if (!track) return;
nowplayingLabel.set_label( nowplayingLabel.set_label(