Skip to content

Commit

Permalink
chore(YouTube Music): update various things (#9105)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timeraa authored Jan 6, 2025
1 parent 8be78e4 commit 0a637f9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 31 deletions.
2 changes: 1 addition & 1 deletion websites/Y/YouTube Music/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"vi_VN": "Một dịch vụ phát nhạc với các album, đĩa đơn, video, bản remix, và các tiết mục trực tiếp chính thức và hơn nữa cho Android, iOS và máy tính. Tất cả đều tại đây."
},
"url": "music.youtube.com",
"version": "3.0.24",
"version": "3.0.25",
"logo": "https://cdn.rcd.gg/PreMiD/websites/Y/YouTube%20Music/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/Y/YouTube%20Music/assets/thumbnail.png",
"color": "#E40813",
Expand Down
57 changes: 27 additions & 30 deletions websites/Y/YouTube Music/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ presence.on("UpdateData", async () => {
?.href.match(/v=([^&#]{5,})/)?.[1],
repeatMode = document
.querySelector('ytmusic-player-bar[slot="player-bar"]')
?.getAttribute("repeat-Mode_"),
?.getAttribute("repeat-mode"),
videoElement =
document.querySelector<HTMLVideoElement>("video.video-stream");

Expand Down Expand Up @@ -65,20 +65,17 @@ presence.on("UpdateData", async () => {
videoListenerAttached = false;
}

presenceData = null;
presenceData = {};

if (hidePaused && mediaSession?.playbackState !== "playing")
return presence.clearActivity();

if (["playing", "paused"].includes(mediaSession?.playbackState)) {
if (privacyMode) {
presenceData.type = ActivityType.Listening;
return presence.setActivity({
...(mediaSession.playbackState === "playing" && {
largeImageKey:
"https://cdn.rcd.gg/PreMiD/websites/Y/YouTube%20Music/assets/logo.png",
details: "Listening to music",
}),
type: ActivityType.Listening,
largeImageKey:
"https://cdn.rcd.gg/PreMiD/websites/Y/YouTube%20Music/assets/logo.png",
});
}

Expand Down Expand Up @@ -124,33 +121,34 @@ presence.on("UpdateData", async () => {
}

presenceData = {
type: ActivityType.Listening,
name: mediaSession.metadata.title,
largeImageKey: showCover
? mediaSession?.metadata?.artwork?.at(-1)?.src ??
"https://cdn.rcd.gg/PreMiD/websites/Y/YouTube%20Music/assets/1.png"
: "https://cdn.rcd.gg/PreMiD/websites/Y/YouTube%20Music/assets/1.png",
details: mediaSession.metadata.title,
state: [mediaSession.metadata.artist, mediaSession.metadata.album]
.filter(Boolean)
.join(" - "),
details: mediaSession.metadata.album,
state: mediaSession.metadata.artist,
...(showButtons && {
buttons,
}),
smallImageKey:
mediaSession.playbackState === "paused"
? Assets.Pause
: repeatMode === "ONE"
? Assets.RepeatOne
: repeatMode === "ALL"
? Assets.Repeat
: Assets.Play,
smallImageText:
mediaSession.playbackState === "paused"
? "Paused"
: repeatMode === "ONE"
? "On loop"
: repeatMode === "ALL"
? "Playlist on loop"
: "Playing",
...(mediaSession.playbackState === "paused" ||
(repeatMode && repeatMode !== "NONE")
? {
smallImageKey:
mediaSession.playbackState === "paused"
? Assets.Pause
: repeatMode === "ONE"
? Assets.RepeatOne
: Assets.Repeat,
smallImageText:
mediaSession.playbackState === "paused"
? "Paused"
: repeatMode === "ONE"
? "On loop"
: "Playlist on loop",
}
: null),
...(showTimestamps &&
mediaSession.playbackState === "playing" && {
startTimestamp: mediaTimestamps[0],
Expand All @@ -159,7 +157,6 @@ presence.on("UpdateData", async () => {
};
} else if (showBrowsing) {
if (privacyMode) {
presenceData.type = ActivityType.Listening;
return presence.setActivity({
largeImageKey:
"https://cdn.rcd.gg/PreMiD/websites/Y/YouTube%20Music/assets/logo.png",
Expand All @@ -173,6 +170,7 @@ presence.on("UpdateData", async () => {
}

presenceData = {
type: ActivityType.Playing,
largeImageKey:
"https://cdn.rcd.gg/PreMiD/websites/Y/YouTube%20Music/assets/logo.png",
details: "Browsing",
Expand Down Expand Up @@ -273,7 +271,6 @@ presence.on("UpdateData", async () => {
}
}

presenceData.type = ActivityType.Listening;
presence.setActivity(presenceData);
});

Expand Down

0 comments on commit 0a637f9

Please sign in to comment.