LastFM: Add setting for using name + artist as activity name (#1713)

Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
Mushrrom 2023-09-09 12:22:41 +10:00 committed by GitHub
parent 25a1d934c6
commit 17abbd3e3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 4 deletions

View File

@ -72,6 +72,12 @@ const enum ActivityFlag {
INSTANCE = 1 << 0,
}
const enum NameFormat {
StatusName = "status-name",
ArtistFirst = "artist-first",
SongFirst = "song-first",
}
const applicationId = "1108588077900898414";
const placeholderId = "2a96cbd8b46e442fc41c2b86b821562f";
@ -117,10 +123,29 @@ const settings = definePluginSettings({
default: true,
},
statusName: {
description: "text shown in status",
description: "custom status text",
type: OptionType.STRING,
default: "some music",
},
nameFormat: {
description: "Show name of song and artist in status name",
type: OptionType.SELECT,
options: [
{
label: "Use custom status name",
value: NameFormat.StatusName,
default: true
},
{
label: "Use format 'artist - song'",
value: NameFormat.ArtistFirst
},
{
label: "Use format 'song - artist'",
value: NameFormat.SongFirst
}
],
},
useListeningStatus: {
description: 'show "Listening to" status instead of "Playing"',
type: OptionType.BOOLEAN,
@ -140,13 +165,13 @@ const settings = definePluginSettings({
value: "placeholder"
}
],
}
},
});
export default definePlugin({
name: "LastFMRichPresence",
description: "Little plugin for Last.fm rich presence",
authors: [Devs.dzshn, Devs.RuiNtD],
authors: [Devs.dzshn, Devs.RuiNtD, Devs.blahajZip],
settingsAboutComponent: () => (
<>
@ -267,9 +292,20 @@ export default definePlugin({
url: `https://www.last.fm/user/${settings.store.username}`,
});
const statusName = (() => {
switch (settings.store.nameFormat) {
case NameFormat.ArtistFirst:
return trackData.artist + " - " + trackData.name;
case NameFormat.SongFirst:
return trackData.name + " - " + trackData.artist;
default:
return settings.store.statusName;
}
})();
return {
application_id: applicationId,
name: settings.store.statusName,
name: statusName,
details: trackData.name,
state: trackData.artist,

View File

@ -366,6 +366,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
RuukuLada: {
name: "RuukuLada",
id: 119705748346241027n,
},
blahajZip: {
name: "blahaj.zip",
id: 683954422241427471n,
}
} satisfies Record<string, Dev>);