From 17abbd3e3ecbe56699aabd795d91cfcf4432a5c8 Mon Sep 17 00:00:00 2001 From: Mushrrom Date: Sat, 9 Sep 2023 12:22:41 +1000 Subject: [PATCH] LastFM: Add setting for using name + artist as activity name (#1713) Co-authored-by: V --- src/plugins/lastfm.tsx | 44 ++++++++++++++++++++++++++++++++++++++---- src/utils/constants.ts | 4 ++++ 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/plugins/lastfm.tsx b/src/plugins/lastfm.tsx index a55f4615..66be06aa 100644 --- a/src/plugins/lastfm.tsx +++ b/src/plugins/lastfm.tsx @@ -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, diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 400fcaa4..424c9aae 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -366,6 +366,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ RuukuLada: { name: "RuukuLada", id: 119705748346241027n, + }, + blahajZip: { + name: "blahaj.zip", + id: 683954422241427471n, } } satisfies Record);