Skip to content

Commit

Permalink
DiscordRPC - Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Inrixia committed Jun 25, 2024
1 parent 5de20ab commit 5d84653
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 23 deletions.
2 changes: 1 addition & 1 deletion plugins/DiscordRPC/plugin.json
Original file line number Diff line number Diff line change
@@ -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"
}
16 changes: 1 addition & 15 deletions plugins/DiscordRPC/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions plugins/DiscordRPC/src/updateRPC.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
3 changes: 1 addition & 2 deletions plugins/RealMAX/src/MaxTrack.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion plugins/RealMAX/src/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion plugins/Shazam/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]");
Expand Down
1 change: 1 addition & 0 deletions plugins/_lib/api/tidal/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./auth";
export * from "./isrc";
export * from "./types";

0 comments on commit 5d84653

Please sign in to comment.