This commit is contained in:
Lea 2024-05-19 17:51:40 +02:00
parent 20e08186d7
commit 7a9f3a4b2a
Signed by: Lea
GPG key ID: 1BAFFE8347019C42

View file

@ -11,6 +11,7 @@ let rpcClient = new RPC.Client({ transport: "ipc" });
rpcClient.login({ clientId: CLIENT_ID, scopes: [] })
type PlaybackData = {
isDeezer?: boolean,
artUrl?: string,
album?: string,
artist?: string[],
@ -58,10 +59,11 @@ async function run() {
switch(prop) {
case 'Metadata': {
if (!data?.["xesam:url"]?.value?.startsWith("https://www.deezer.com/")) {
data = { playing: false };
playbackData = { playing: false, isDeezer: false };
return;
}
playbackData.isDeezer = true;
playbackData.artUrl = data?.["mpris:artUrl"]?.value;
playbackData.length = Number(data?.["mpris:length"]?.value) / 1000;
playbackData.album = data?.["xesam:album"]?.value;
@ -98,7 +100,7 @@ async function run() {
}
console.log("Setting presence");
if (!playbackData.playing && !playbackData.paused) {
if ((!playbackData.playing && !playbackData.paused) || !playbackData.isDeezer) {
await rpcClient.clearActivity();
}
else {