mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2025-05-11 05:23:09 +02:00
Merge 21edcd6ad5e4d88b4a54bf653e5275b8ce97c55d into 91156e5936d6dd1344a669221d9cc62255393e57
This commit is contained in:
commit
00da50f261
31
package-lock.json
generated
31
package-lock.json
generated
@ -13,7 +13,7 @@
|
|||||||
"@types/swagger-jsdoc": "^6.0.4",
|
"@types/swagger-jsdoc": "^6.0.4",
|
||||||
"axios": "^1.7.7",
|
"axios": "^1.7.7",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"discord-rpc": "^4.0.1",
|
"discord-rpc": "github:sKiLdUsT/RPC#types",
|
||||||
"electron-store": "^8.2.0",
|
"electron-store": "^8.2.0",
|
||||||
"express": "^4.21.1",
|
"express": "^4.21.1",
|
||||||
"hotkeys-js": "^3.13.7",
|
"hotkeys-js": "^3.13.7",
|
||||||
@ -25,7 +25,6 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@mastermindzh/prettier-config": "^1.0.0",
|
"@mastermindzh/prettier-config": "^1.0.0",
|
||||||
"@types/cors": "^2.8.17",
|
"@types/cors": "^2.8.17",
|
||||||
"@types/discord-rpc": "^4.0.8",
|
|
||||||
"@types/express": "^4.17.21",
|
"@types/express": "^4.17.21",
|
||||||
"@types/node": "^20.14.10",
|
"@types/node": "^20.14.10",
|
||||||
"@types/request": "^2.48.12",
|
"@types/request": "^2.48.12",
|
||||||
@ -1230,21 +1229,6 @@
|
|||||||
"@types/ms": "*"
|
"@types/ms": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/discord-rpc": {
|
|
||||||
"version": "4.0.8",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/discord-rpc/-/discord-rpc-4.0.8.tgz",
|
|
||||||
"integrity": "sha512-1tZf217Natkj+TziNXRRLwNmdm5GNa1bnrQr8VWowquo/Su5hMjdhobj8URxW1COMk2da28XCU1ahsYCAlxirA==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@types/events": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@types/events": {
|
|
||||||
"version": "3.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.3.tgz",
|
|
||||||
"integrity": "sha512-trOc4AAUThEz9hapPtSd7wf5tiQKvTtu5b371UxXdTuqzIh0ArcRspRP0i0Viu+LXstIQ1z96t1nsPxT9ol01g==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/@types/express": {
|
"node_modules/@types/express": {
|
||||||
"version": "4.17.21",
|
"version": "4.17.21",
|
||||||
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz",
|
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz",
|
||||||
@ -3388,8 +3372,8 @@
|
|||||||
},
|
},
|
||||||
"node_modules/discord-rpc": {
|
"node_modules/discord-rpc": {
|
||||||
"version": "4.0.1",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/discord-rpc/-/discord-rpc-4.0.1.tgz",
|
"resolved": "git+ssh://git@github.com/sKiLdUsT/RPC.git#1c5b6842fa586a1b7b339a50fa5ec1c4cf6c8867",
|
||||||
"integrity": "sha512-HOvHpbq5STRZJjQIBzwoKnQ0jHplbEWFWlPDwXXKm/bILh4nzjcg7mNqll0UY7RsjFoaXA7e/oYb/4lvpda2zA==",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"ws": "^7.3.1"
|
"ws": "^7.3.1"
|
||||||
@ -6162,6 +6146,7 @@
|
|||||||
"version": "2.7.0",
|
"version": "2.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
|
||||||
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
|
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"whatwg-url": "^5.0.0"
|
"whatwg-url": "^5.0.0"
|
||||||
},
|
},
|
||||||
@ -8575,7 +8560,8 @@
|
|||||||
"node_modules/tr46": {
|
"node_modules/tr46": {
|
||||||
"version": "0.0.3",
|
"version": "0.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||||
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
|
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
|
||||||
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/truncate-utf8-bytes": {
|
"node_modules/truncate-utf8-bytes": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
@ -8862,12 +8848,14 @@
|
|||||||
"node_modules/webidl-conversions": {
|
"node_modules/webidl-conversions": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||||
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
|
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
|
||||||
|
"license": "BSD-2-Clause"
|
||||||
},
|
},
|
||||||
"node_modules/whatwg-url": {
|
"node_modules/whatwg-url": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||||
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
|
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tr46": "~0.0.3",
|
"tr46": "~0.0.3",
|
||||||
"webidl-conversions": "^3.0.0"
|
"webidl-conversions": "^3.0.0"
|
||||||
@ -8946,6 +8934,7 @@
|
|||||||
"version": "7.5.10",
|
"version": "7.5.10",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz",
|
||||||
"integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==",
|
"integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==",
|
||||||
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8.3.0"
|
"node": ">=8.3.0"
|
||||||
},
|
},
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
"@types/swagger-jsdoc": "^6.0.4",
|
"@types/swagger-jsdoc": "^6.0.4",
|
||||||
"axios": "^1.7.7",
|
"axios": "^1.7.7",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"discord-rpc": "^4.0.1",
|
"discord-rpc": "github:sKiLdUsT/RPC#types",
|
||||||
"electron-store": "^8.2.0",
|
"electron-store": "^8.2.0",
|
||||||
"express": "^4.21.1",
|
"express": "^4.21.1",
|
||||||
"hotkeys-js": "^3.13.7",
|
"hotkeys-js": "^3.13.7",
|
||||||
@ -56,7 +56,6 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@mastermindzh/prettier-config": "^1.0.0",
|
"@mastermindzh/prettier-config": "^1.0.0",
|
||||||
"@types/cors": "^2.8.17",
|
"@types/cors": "^2.8.17",
|
||||||
"@types/discord-rpc": "^4.0.8",
|
|
||||||
"@types/express": "^4.17.21",
|
"@types/express": "^4.17.21",
|
||||||
"@types/node": "^20.14.10",
|
"@types/node": "^20.14.10",
|
||||||
"@types/request": "^2.48.12",
|
"@types/request": "^2.48.12",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Client, Presence } from "discord-rpc";
|
import * as DRPC from "discord-rpc";
|
||||||
import { app, ipcMain } from "electron";
|
import { app, ipcMain } from "electron";
|
||||||
import { globalEvents } from "../constants/globalEvents";
|
import { globalEvents } from "../constants/globalEvents";
|
||||||
import { settings } from "../constants/settings";
|
import { settings } from "../constants/settings";
|
||||||
@ -10,7 +10,9 @@ import { settingsStore } from "./settings";
|
|||||||
|
|
||||||
const clientId = "833617820704440341";
|
const clientId = "833617820704440341";
|
||||||
|
|
||||||
export let rpc: Client;
|
export let rpc: DRPC.Client;
|
||||||
|
|
||||||
|
const ACTIVITY_LISTENING = 2;
|
||||||
|
|
||||||
const observer = () => {
|
const observer = () => {
|
||||||
if (rpc) {
|
if (rpc) {
|
||||||
@ -33,8 +35,10 @@ const updateActivity = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getActivity = (): Presence => {
|
const getActivity = (): DRPC.Presence => {
|
||||||
const presence: Presence = { ...defaultPresence };
|
const presence: DRPC.Presence = { ...defaultPresence };
|
||||||
|
|
||||||
|
presence.type = ACTIVITY_LISTENING;
|
||||||
|
|
||||||
if (mediaInfo.status === MediaStatus.paused) {
|
if (mediaInfo.status === MediaStatus.paused) {
|
||||||
presence.details =
|
presence.details =
|
||||||
@ -50,6 +54,7 @@ const getActivity = (): Presence => {
|
|||||||
settingsStore.get<string, string>(settings.discord.usingText) ?? "Playing media on TIDAL";
|
settingsStore.get<string, string>(settings.discord.usingText) ?? "Playing media on TIDAL";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return presence;
|
return presence;
|
||||||
|
|
||||||
function getFromStore() {
|
function getFromStore() {
|
||||||
@ -98,10 +103,11 @@ const getActivity = (): Presence => {
|
|||||||
const currentSeconds = convertDurationToSeconds(mediaInfo.current);
|
const currentSeconds = convertDurationToSeconds(mediaInfo.current);
|
||||||
const durationSeconds = convertDurationToSeconds(mediaInfo.duration);
|
const durationSeconds = convertDurationToSeconds(mediaInfo.duration);
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const now = (date.getTime() / 1000) | 0;
|
const now = Math.floor(date.getTime() / 1000);
|
||||||
const remaining = date.setSeconds(date.getSeconds() + (durationSeconds - currentSeconds));
|
const startTimestamp = now - currentSeconds;
|
||||||
presence.startTimestamp = now;
|
const endTimestamp = startTimestamp + durationSeconds;
|
||||||
presence.endTimestamp = remaining;
|
presence.startTimestamp = startTimestamp;
|
||||||
|
presence.endTimestamp = endTimestamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -110,7 +116,7 @@ const getActivity = (): Presence => {
|
|||||||
* Set up the discord rpc and listen on globalEvents.updateInfo
|
* Set up the discord rpc and listen on globalEvents.updateInfo
|
||||||
*/
|
*/
|
||||||
export const initRPC = () => {
|
export const initRPC = () => {
|
||||||
rpc = new Client({ transport: "ipc" });
|
rpc = new DRPC.Client({ transport: "ipc" });
|
||||||
rpc.login({ clientId }).then(
|
rpc.login({ clientId }).then(
|
||||||
() => {
|
() => {
|
||||||
rpc.on("ready", () => {
|
rpc.on("ready", () => {
|
||||||
|
39
src/types/discord-rpc.d.ts
vendored
Normal file
39
src/types/discord-rpc.d.ts
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
declare module 'discord-rpc' {
|
||||||
|
export class Client {
|
||||||
|
constructor(options: { transport: 'ipc' });
|
||||||
|
on(event: string, listener: (...args: any[]) => void): this;
|
||||||
|
login(options: { clientId: string }): Promise<void>;
|
||||||
|
setActivity(presence: Presence): Promise<void>;
|
||||||
|
clearActivity(): Promise<void>;
|
||||||
|
destroy(): Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Presence {
|
||||||
|
state?: string;
|
||||||
|
details?: string;
|
||||||
|
startTimestamp?: number;
|
||||||
|
endTimestamp?: number;
|
||||||
|
largeImageKey?: string;
|
||||||
|
largeImageText?: string;
|
||||||
|
smallImageKey?: string;
|
||||||
|
smallImageText?: string;
|
||||||
|
partyId?: string;
|
||||||
|
partySize?: number;
|
||||||
|
partyMax?: number;
|
||||||
|
matchSecret?: string;
|
||||||
|
spectateSecret?: string;
|
||||||
|
joinSecret?: string;
|
||||||
|
instance?: boolean;
|
||||||
|
type?: number;
|
||||||
|
buttons?: Array<{ label: string; url: string }>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ActivityTypes: {
|
||||||
|
PLAYING: 0,
|
||||||
|
STREAMING: 1,
|
||||||
|
LISTENING: 2,
|
||||||
|
WATCHING: 3,
|
||||||
|
CUSTOM: 4,
|
||||||
|
COMPETING: 5
|
||||||
|
};
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user