diff --git a/websites/N/Nintendo Music/metadata.json b/websites/N/Nintendo Music/metadata.json index d59d9e11a7de..ceb06180399a 100644 --- a/websites/N/Nintendo Music/metadata.json +++ b/websites/N/Nintendo Music/metadata.json @@ -9,14 +9,14 @@ "description": { "de": "Mit Nintendo Music kannst du überall eine Vielzahl von Nintendo-Melodien hören.", "en": "With Nintendo Music, you can listen to a variety of Nintendo tunes anywhere.", - "es": "Con Nintendo Music, puedes escuchar una gran variedad de melodías de Nintendo en cualquier lugar.", + "es": "Con Nintendo Music, puedes escuchar una gran variedad di melodías de Nintendo en cualquier lugar.", "it": "Con Nintendo Music, puoi ascoltare una varietà di brani Nintendo ovunque.", "nl": "Met Nintendo Music kun je overal naar een verscheidenheid aan Nintendo-melodieën luisteren.", "ru": "С Nintendo Music ты можешь слушать разнообразные мелодии Nintendo где угодно." }, "url": "music.nintendo.com", "regExp": "^https?[:][/][/]music[.]nintendo[.]com[/]", - "version": "1.1.0", + "version": "1.2.0", "logo": "https://cdn.rcd.gg/PreMiD/websites/N/Nintendo%20Music/assets/logo.png", "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/N/Nintendo%20Music/assets/thumbnail.png", "color": "#FC2C00", @@ -39,6 +39,20 @@ "icon": "fas fa-image", "value": true, "description": "Show the song artwork as the large image." + }, + { + "id": "displayFormat", + "title": "Display Format", + "icon": "fas fa-paragraph", + "value": 0, + "values": ["Song Name", "Soundtrack Name", "Nintendo Music"] + }, + { + "id": "marioKartTrackOrigin", + "title": "Display Racetrack Console Origin", + "icon": "fas fa-font", + "value": false, + "description": "For Mario Kart soundtracks, show which console a racetrack originates from if they don't already." } ] } diff --git a/websites/N/Nintendo Music/presence.ts b/websites/N/Nintendo Music/presence.ts index ce0146198fd6..ce9130ccbe6f 100644 --- a/websites/N/Nintendo Music/presence.ts +++ b/websites/N/Nintendo Music/presence.ts @@ -1,10 +1,45 @@ -import { ActivityType } from 'premid' +import { ActivityType, StatusDisplayType } from 'premid' const presence = new Presence({ clientId: '1511505666664038460', }) const NintendoMusicLogo = 'https://cdn.rcd.gg/PreMiD/websites/N/Nintendo%20Music/assets/logo.png' +const TrackOriginList: Record> = { + 'Mario Kart World': { + 'Desert Hills': 'DS Desert Hills', + 'Shy Guy Bazaar': '3DS Shy Guy Bazaar', + 'Wario Stadium': 'N64 Wario Stadium', + 'Airship Fortress': 'DS Airship Fortress', + 'DK Pass': 'DS DK Pass', + 'Sky-High Sundae': 'SW Sky-High Sundae', + 'Wario\'s Galleon': '3DS Wario\'s Galleon', + 'Wario\'s Shipyard': '3DS Wario\'s Shipyard', + 'Koopa Troopa Beach': 'SNES Koopa Troopa Beach', + 'Peach Beach': 'GCN Peach Beach', + 'Dino Dino Jungle': 'GCN Dino Dino Jungle', + 'Moo Moo Meadows': 'Wii Moo Moo Meadows', + 'Choco Mountain': 'N64 Choco Mountain', + 'Toad\'s Factory': 'Wii Toad\'s Factory', + 'Mario Circuit': 'SNES Mario Circuit', + 'Desert Hills (Intro)': 'DS Desert Hills (Intro)', + 'Shy Guy Bazaar (Intro)': '3DS Shy Guy Bazaar (Intro)', + 'Wario Stadium (Intro)': 'N64 Wario Stadium (Intro)', + 'Airship Fortress (Intro)': 'DS Airship Fortress (Intro)', + 'DK Pass (Intro)': 'DS DK Pass (Intro)', + 'Sky-High Sundae (Intro)': 'SW Sky-High Sundae (Intro)', + 'Wario\'s Galleon (Intro)': '3DS Wario\'s Galleon (Intro)', + 'Wario\'s Shipyard (Intro)': '3DS Wario\'s Shipyard (Intro)', + 'Koopa Troopa Beach (Intro)': 'SNES Koopa Troopa Beach (Intro)', + 'Peach Beach (Intro)': 'GCN Peach Beach (Intro)', + 'Dino Dino Jungle (Intro)': 'GCN Dino Dino Jungle (Intro)', + 'Moo Moo Meadows (Intro)': 'Wii Moo Moo Meadows (Intro)', + 'Choco Mountain (Intro)': 'N64 Choco Mountain (Intro)', + 'Toad\'s Factory (Intro)': 'Wii Toad\'s Factory (Intro)', + 'Mario Circuit (Intro)': 'SNES Mario Circuit (Intro)', + }, +} + presence.on('UpdateData', async () => { const { pathname } = document.location const title = document.title @@ -12,14 +47,16 @@ presence.on('UpdateData', async () => { const mediaSession = navigator.mediaSession const isPlaying = mediaSession.playbackState === 'playing' const currentTime = audio?.currentTime ?? 0 - const duration = audio?.duration || 0 // NOTE: audio.duration is NaN before loadedmetadata fires + const duration = audio?.duration || 0 const now = Math.floor(Date.now() / 1000) const albumArt = document.querySelector('#main-column img')?.src ?? NintendoMusicLogo - const [showTimestamps, showSongArt] = await Promise.all([ + const [showTimestamps, showSongArt, displayFormat, marioKartTrackOrigin] = await Promise.all([ presence.getSetting('showTimestamps'), presence.getSetting('showSongArt'), + presence.getSetting('displayFormat'), + presence.getSetting('marioKartTrackOrigin'), ]) const presenceData: PresenceData = { @@ -99,6 +136,31 @@ presence.on('UpdateData', async () => { delete presenceData.endTimestamp } + if (marioKartTrackOrigin) { + const soundtrackName = presenceData.state + const songName = presenceData.details + if (typeof soundtrackName === 'string' && typeof songName === 'string') { + const gameKey = soundtrackName as keyof typeof TrackOriginList + const gameTrack = TrackOriginList[gameKey] + if (gameTrack && songName in gameTrack) { + const mappedTrackValue = (gameTrack as Record)[songName] + presenceData.details = mappedTrackValue + } + } + } + + switch (displayFormat) { + case 0: + presenceData.statusDisplayType = StatusDisplayType.Details + break + case 1: + presenceData.statusDisplayType = StatusDisplayType.State + break + case 2: + presenceData.statusDisplayType = StatusDisplayType.Name + break + } + if (presenceData.details) { presence.setActivity(presenceData) }