feat(jellyfinRichPresence): Add Dynamic ActivityType & Override (#288)

* feat(jellyfinRichPresence): add dynamic ActivityType, aswell as an override

* Update pnpm-lock.yaml

* Fixes

* Fix Default

---------

Co-authored-by: thororen <78185467+thororen1234@users.noreply.github.com>
This commit is contained in:
h4rl 2025-06-11 22:41:13 +02:00 committed by GitHub
parent 7c661139d5
commit dd6920d20a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -65,6 +65,33 @@ const settings = definePluginSettings({
description: "Jellyfin user ID obtained from your user profile URL",
type: OptionType.STRING,
},
overrideRichPresenceType: {
description: "Override the rich presence type",
type: OptionType.SELECT,
options: [
{
label: "Off",
value: false,
default: true,
},
{
label: "Listening",
value: 2,
},
{
label: "Playing",
value: 0,
},
{
label: "Streaming",
value: 1,
},
{
label: "Watching",
value: 3
},
],
},
});
const applicationId = "1381368130164625469";
@ -169,9 +196,24 @@ export default definePlugin({
},
async getActivity(): Promise<Activity | null> {
let richPresenceType;
const mediaData = await this.fetchMediaData();
if (!mediaData) return null;
if (settings.store.overrideRichPresenceType) {
richPresenceType = settings.store.overrideRichPresenceType;
} else {
switch (mediaData.type) {
case "Audio":
richPresenceType = 2;
break;
default:
richPresenceType = 3;
break;
}
}
const largeImage = mediaData.imageUrl;
const assets: ActivityAssets = {
large_image: largeImage ? await getApplicationAsset(largeImage) : await getApplicationAsset("jellyfin"),
@ -208,7 +250,7 @@ export default definePlugin({
assets,
timestamps,
type: 3,
type: richPresenceType,
flags: 1,
};
}