From 5d84653a1ad9d7f280e3644e841f875a6350db03 Mon Sep 17 00:00:00 2001 From: Inrixia Date: Wed, 26 Jun 2024 04:40:06 +1200 Subject: [PATCH] DiscordRPC - Fixes --- plugins/DiscordRPC/plugin.json | 2 +- plugins/DiscordRPC/src/index.ts | 16 +--------------- plugins/DiscordRPC/src/updateRPC.native.ts | 5 ++--- plugins/RealMAX/src/MaxTrack.ts | 3 +-- plugins/RealMAX/src/index.ts | 2 +- plugins/Shazam/src/index.ts | 2 +- plugins/_lib/api/tidal/index.ts | 1 + 7 files changed, 8 insertions(+), 23 deletions(-) diff --git a/plugins/DiscordRPC/plugin.json b/plugins/DiscordRPC/plugin.json index 7a362ec..681566a 100644 --- a/plugins/DiscordRPC/plugin.json +++ b/plugins/DiscordRPC/plugin.json @@ -1,6 +1,6 @@ { "name": "Discord RPC", "description": "Shows what song you're currently listening to on Discord.", - "author": "toonlink", + "author": "Inrixia", "main": "./src/index.js" } \ No newline at end of file diff --git a/plugins/DiscordRPC/src/index.ts b/plugins/DiscordRPC/src/index.ts index 129fbed..694d299 100644 --- a/plugins/DiscordRPC/src/index.ts +++ b/plugins/DiscordRPC/src/index.ts @@ -16,26 +16,12 @@ enum AudioQuality { Low = "HIGH", Lowest = "LOW", } -interface PlaybackContext { - actualAssetPresentation: string; - actualAudioMode: string; - actualAudioQuality: AudioQuality; - actualDuration: number; - actualProductId: string; - actualStreamType: unknown; - actualVideoQuality: unknown; - assetPosition: number; - bitDepth: number | null; - codec: string; - playbackSessionId: string; - sampleRate: number | null; -} export const onUnload = intercept("playbackControls/TIME_UPDATE", ([current]) => { onTimeUpdate(); }); const onTimeUpdate = async () => { const { playbackContext, playbackState, latestCurrentTime } = getPlaybackControl(); - if (playbackState === undefined || latestCurrentTime === undefined || playbackContext === undefined) return; + if (!playbackState || !latestCurrentTime || !playbackContext) return; const mediaItemId = playbackContext.actualProductId; if (mediaItemId === undefined) return; diff --git a/plugins/DiscordRPC/src/updateRPC.native.ts b/plugins/DiscordRPC/src/updateRPC.native.ts index 488e981..f9156b8 100644 --- a/plugins/DiscordRPC/src/updateRPC.native.ts +++ b/plugins/DiscordRPC/src/updateRPC.native.ts @@ -12,13 +12,12 @@ const formatLongString = (s?: string) => { const getMediaURLFromID = (id?: string, path = "/1280x1280.jpg") => (id ? "https://resources.tidal.com/images/" + id.split("-").join("/") + path : undefined); export const updateRPC = async (currentlyPlaying: TrackItem, playbackState: PlaybackState, currentTime: number, keepRpcOnPause: boolean) => { - const _rpcClient = await rpcClient.ensureRPC().catch((err) => console.error("Failed to connect to DiscordRPC", err)); + const _rpcClient = await rpcClient.ensureRPC(); if (_rpcClient === undefined) return; const activityState: Presence = { - buttons: [], + buttons: [{ url: `https://tidal.com/browse/track/${currentlyPlaying.id}`, label: "Play on Tidal" }], }; - if (currentlyPlaying.url) activityState.buttons?.push({ url: currentlyPlaying.url, label: "Play on Tidal" }); // Pause indicator if (playbackState === "NOT_PLAYING") { diff --git a/plugins/RealMAX/src/MaxTrack.ts b/plugins/RealMAX/src/MaxTrack.ts index b5114fa..70b58e6 100644 --- a/plugins/RealMAX/src/MaxTrack.ts +++ b/plugins/RealMAX/src/MaxTrack.ts @@ -1,5 +1,4 @@ -import { fetchIsrcIterable } from "@inrixia/lib/api/tidal/isrc"; -import { Resource } from "@inrixia/lib/api/tidal/types/ISRC"; +import { fetchIsrcIterable, Resource } from "@inrixia/lib/api/tidal"; import { ExtendedTrackItem } from "@inrixia/lib/Caches/ExtendedTrackItem"; import { TrackItemCache } from "@inrixia/lib/Caches/TrackItemCache"; import { ItemId, TrackItem } from "neptune-types/tidal"; diff --git a/plugins/RealMAX/src/index.ts b/plugins/RealMAX/src/index.ts index fdf565b..fd689a6 100644 --- a/plugins/RealMAX/src/index.ts +++ b/plugins/RealMAX/src/index.ts @@ -1,4 +1,4 @@ -import { ItemId, TrackItem } from "neptune-types/tidal"; +import { TrackItem } from "neptune-types/tidal"; import { TrackItemCache } from "@inrixia/lib/Caches/TrackItemCache"; import { actions, intercept, store } from "@neptune"; import { debounce } from "@inrixia/lib/debounce"; diff --git a/plugins/Shazam/src/index.ts b/plugins/Shazam/src/index.ts index 58c1edd..ef61067 100644 --- a/plugins/Shazam/src/index.ts +++ b/plugins/Shazam/src/index.ts @@ -7,7 +7,7 @@ import { DecodedSignature } from "shazamio-core"; import { interceptPromise } from "@inrixia/lib/intercept/interceptPromise"; import { fetchShazamData } from "./shazamApi/fetch"; -import { fetchIsrc } from "@inrixia/lib/api/tidal/isrc"; +import { fetchIsrc } from "@inrixia/lib/api/tidal"; import { Tracer } from "@inrixia/lib/trace"; const trace = Tracer("[Shazam]"); diff --git a/plugins/_lib/api/tidal/index.ts b/plugins/_lib/api/tidal/index.ts index 010b2ae..2c76b15 100644 --- a/plugins/_lib/api/tidal/index.ts +++ b/plugins/_lib/api/tidal/index.ts @@ -1,2 +1,3 @@ export * from "./auth"; export * from "./isrc"; +export * from "./types";