Skip to content

Commit 3a2f2a2

Browse files
authored
feat(Nintendo Music): add new settings options (#10917)
* feat: add Nintendo Music presence * fix: eslint errors * fix: removed sr language * fix: removed unecessary comma * fix: code formatted correctly, added at least 1 empty line at the end of both files * fix: final if-elseif-else code formatting * fix: removed one blank line at line 106 * fix: changed the description to better describe the product. * fix: address reviewer suggestions * Added two new settings options * chore: resolved merge conflicts with main * style: fix lint errors by changing strings to single quotes * fix: resolve undefined saveData reference typo * removed *.zip from .gitignore * bumped the version in metadata * bumped higher version
1 parent f219f80 commit 3a2f2a2

2 files changed

Lines changed: 81 additions & 5 deletions

File tree

websites/N/Nintendo Music/metadata.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
"description": {
1010
"de": "Mit Nintendo Music kannst du überall eine Vielzahl von Nintendo-Melodien hören.",
1111
"en": "With Nintendo Music, you can listen to a variety of Nintendo tunes anywhere.",
12-
"es": "Con Nintendo Music, puedes escuchar una gran variedad de melodías de Nintendo en cualquier lugar.",
12+
"es": "Con Nintendo Music, puedes escuchar una gran variedad di melodías de Nintendo en cualquier lugar.",
1313
"it": "Con Nintendo Music, puoi ascoltare una varietà di brani Nintendo ovunque.",
1414
"nl": "Met Nintendo Music kun je overal naar een verscheidenheid aan Nintendo-melodieën luisteren.",
1515
"ru": "С Nintendo Music ты можешь слушать разнообразные мелодии Nintendo где угодно."
1616
},
1717
"url": "music.nintendo.com",
1818
"regExp": "^https?[:][/][/]music[.]nintendo[.]com[/]",
19-
"version": "1.1.0",
19+
"version": "1.2.0",
2020
"logo": "https://cdn.rcd.gg/PreMiD/websites/N/Nintendo%20Music/assets/logo.png",
2121
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/N/Nintendo%20Music/assets/thumbnail.png",
2222
"color": "#FC2C00",
@@ -39,6 +39,20 @@
3939
"icon": "fas fa-image",
4040
"value": true,
4141
"description": "Show the song artwork as the large image."
42+
},
43+
{
44+
"id": "displayFormat",
45+
"title": "Display Format",
46+
"icon": "fas fa-paragraph",
47+
"value": 0,
48+
"values": ["Song Name", "Soundtrack Name", "Nintendo Music"]
49+
},
50+
{
51+
"id": "marioKartTrackOrigin",
52+
"title": "Display Racetrack Console Origin",
53+
"icon": "fas fa-font",
54+
"value": false,
55+
"description": "For Mario Kart soundtracks, show which console a racetrack originates from if they don't already."
4256
}
4357
]
4458
}

websites/N/Nintendo Music/presence.ts

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,62 @@
1-
import { ActivityType } from 'premid'
1+
import { ActivityType, StatusDisplayType } from 'premid'
22

33
const presence = new Presence({
44
clientId: '1511505666664038460',
55
})
66
const NintendoMusicLogo = 'https://cdn.rcd.gg/PreMiD/websites/N/Nintendo%20Music/assets/logo.png'
77

8+
const TrackOriginList: Record<string, Record<string, string>> = {
9+
'Mario Kart World': {
10+
'Desert Hills': 'DS Desert Hills',
11+
'Shy Guy Bazaar': '3DS Shy Guy Bazaar',
12+
'Wario Stadium': 'N64 Wario Stadium',
13+
'Airship Fortress': 'DS Airship Fortress',
14+
'DK Pass': 'DS DK Pass',
15+
'Sky-High Sundae': 'SW Sky-High Sundae',
16+
'Wario\'s Galleon': '3DS Wario\'s Galleon',
17+
'Wario\'s Shipyard': '3DS Wario\'s Shipyard',
18+
'Koopa Troopa Beach': 'SNES Koopa Troopa Beach',
19+
'Peach Beach': 'GCN Peach Beach',
20+
'Dino Dino Jungle': 'GCN Dino Dino Jungle',
21+
'Moo Moo Meadows': 'Wii Moo Moo Meadows',
22+
'Choco Mountain': 'N64 Choco Mountain',
23+
'Toad\'s Factory': 'Wii Toad\'s Factory',
24+
'Mario Circuit': 'SNES Mario Circuit',
25+
'Desert Hills (Intro)': 'DS Desert Hills (Intro)',
26+
'Shy Guy Bazaar (Intro)': '3DS Shy Guy Bazaar (Intro)',
27+
'Wario Stadium (Intro)': 'N64 Wario Stadium (Intro)',
28+
'Airship Fortress (Intro)': 'DS Airship Fortress (Intro)',
29+
'DK Pass (Intro)': 'DS DK Pass (Intro)',
30+
'Sky-High Sundae (Intro)': 'SW Sky-High Sundae (Intro)',
31+
'Wario\'s Galleon (Intro)': '3DS Wario\'s Galleon (Intro)',
32+
'Wario\'s Shipyard (Intro)': '3DS Wario\'s Shipyard (Intro)',
33+
'Koopa Troopa Beach (Intro)': 'SNES Koopa Troopa Beach (Intro)',
34+
'Peach Beach (Intro)': 'GCN Peach Beach (Intro)',
35+
'Dino Dino Jungle (Intro)': 'GCN Dino Dino Jungle (Intro)',
36+
'Moo Moo Meadows (Intro)': 'Wii Moo Moo Meadows (Intro)',
37+
'Choco Mountain (Intro)': 'N64 Choco Mountain (Intro)',
38+
'Toad\'s Factory (Intro)': 'Wii Toad\'s Factory (Intro)',
39+
'Mario Circuit (Intro)': 'SNES Mario Circuit (Intro)',
40+
},
41+
}
42+
843
presence.on('UpdateData', async () => {
944
const { pathname } = document.location
1045
const title = document.title
1146
const audio = document.querySelector('audio')
1247
const mediaSession = navigator.mediaSession
1348
const isPlaying = mediaSession.playbackState === 'playing'
1449
const currentTime = audio?.currentTime ?? 0
15-
const duration = audio?.duration || 0 // NOTE: audio.duration is NaN before loadedmetadata fires
50+
const duration = audio?.duration || 0
1651
const now = Math.floor(Date.now() / 1000)
1752

1853
const albumArt = document.querySelector<HTMLImageElement>('#main-column img')?.src ?? NintendoMusicLogo
1954

20-
const [showTimestamps, showSongArt] = await Promise.all([
55+
const [showTimestamps, showSongArt, displayFormat, marioKartTrackOrigin] = await Promise.all([
2156
presence.getSetting<boolean>('showTimestamps'),
2257
presence.getSetting<boolean>('showSongArt'),
58+
presence.getSetting<number>('displayFormat'),
59+
presence.getSetting<boolean>('marioKartTrackOrigin'),
2360
])
2461

2562
const presenceData: PresenceData = {
@@ -99,6 +136,31 @@ presence.on('UpdateData', async () => {
99136
delete presenceData.endTimestamp
100137
}
101138

139+
if (marioKartTrackOrigin) {
140+
const soundtrackName = presenceData.state
141+
const songName = presenceData.details
142+
if (typeof soundtrackName === 'string' && typeof songName === 'string') {
143+
const gameKey = soundtrackName as keyof typeof TrackOriginList
144+
const gameTrack = TrackOriginList[gameKey]
145+
if (gameTrack && songName in gameTrack) {
146+
const mappedTrackValue = (gameTrack as Record<string, string>)[songName]
147+
presenceData.details = mappedTrackValue
148+
}
149+
}
150+
}
151+
152+
switch (displayFormat) {
153+
case 0:
154+
presenceData.statusDisplayType = StatusDisplayType.Details
155+
break
156+
case 1:
157+
presenceData.statusDisplayType = StatusDisplayType.State
158+
break
159+
case 2:
160+
presenceData.statusDisplayType = StatusDisplayType.Name
161+
break
162+
}
163+
102164
if (presenceData.details) {
103165
presence.setActivity(presenceData)
104166
}

0 commit comments

Comments
 (0)