diff --git a/package.json b/package.json index e65e1b0a..88633f65 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vencord", "private": "true", - "version": "1.10.1", + "version": "1.10.2", "description": "The cutest Discord client mod", "homepage": "https://github.com/Vendicated/Vencord#readme", "bugs": { diff --git a/src/components/PluginSettings/index.tsx b/src/components/PluginSettings/index.tsx index 38ddc4a9..c3b6e908 100644 --- a/src/components/PluginSettings/index.tsx +++ b/src/components/PluginSettings/index.tsx @@ -292,10 +292,10 @@ export default function PluginSettings() { if (!pluginFilter(p)) continue; - const isRequired = p.required || depMap[p.name]?.some(d => settings.plugins[d].enabled); + const isRequired = p.required || p.isDependency || depMap[p.name]?.some(d => settings.plugins[d].enabled); if (isRequired) { - const tooltipText = p.required + const tooltipText = p.required || !depMap[p.name] ? "This plugin is required for Vencord to function." : makeDependencyList(depMap[p.name]?.filter(d => settings.plugins[d].enabled)); diff --git a/src/plugins/_core/supportHelper.tsx b/src/plugins/_core/supportHelper.tsx index de8e37c7..432896fc 100644 --- a/src/plugins/_core/supportHelper.tsx +++ b/src/plugins/_core/supportHelper.tsx @@ -142,7 +142,7 @@ export default definePlugin({ required: true, description: "Helps us provide support to you", authors: [Devs.Ven], - dependencies: ["CommandsAPI", "UserSettingsAPI", "MessageAccessoriesAPI"], + dependencies: ["UserSettingsAPI", "MessageAccessoriesAPI"], settings, diff --git a/src/plugins/appleMusic.desktop/index.tsx b/src/plugins/appleMusic.desktop/index.tsx index 6fa989cd..f3148c36 100644 --- a/src/plugins/appleMusic.desktop/index.tsx +++ b/src/plugins/appleMusic.desktop/index.tsx @@ -24,7 +24,7 @@ interface ActivityButton { } interface Activity { - state: string; + state?: string; details?: string; timestamps?: { start?: number; @@ -52,8 +52,8 @@ const enum ActivityFlag { export interface TrackData { name: string; - album: string; - artist: string; + album?: string; + artist?: string; appleMusicLink?: string; songLink?: string; @@ -61,8 +61,8 @@ export interface TrackData { albumArtwork?: string; artistArtwork?: string; - playerPosition: number; - duration: number; + playerPosition?: number; + duration?: number; } const enum AssetImageType { @@ -120,7 +120,7 @@ const settings = definePluginSettings({ stateString: { type: OptionType.STRING, description: "Activity state format string", - default: "{artist}" + default: "{artist} · {album}" }, largeImageType: { type: OptionType.SELECT, @@ -155,8 +155,8 @@ const settings = definePluginSettings({ function customFormat(formatStr: string, data: TrackData) { return formatStr .replaceAll("{name}", data.name) - .replaceAll("{album}", data.album) - .replaceAll("{artist}", data.artist); + .replaceAll("{album}", data.album ?? "") + .replaceAll("{artist}", data.artist ?? ""); } function getImageAsset(type: AssetImageType, data: TrackData) { @@ -212,14 +212,16 @@ export default definePlugin({ const assets: ActivityAssets = {}; + const isRadio = Number.isNaN(trackData.duration) && (trackData.playerPosition === 0); + if (settings.store.largeImageType !== AssetImageType.Disabled) { assets.large_image = largeImageAsset; - assets.large_text = customFormat(settings.store.largeTextString, trackData); + if (!isRadio) assets.large_text = customFormat(settings.store.largeTextString, trackData); } if (settings.store.smallImageType !== AssetImageType.Disabled) { assets.small_image = smallImageAsset; - assets.small_text = customFormat(settings.store.smallTextString, trackData); + if (!isRadio) assets.small_text = customFormat(settings.store.smallTextString, trackData); } const buttons: ActivityButton[] = []; @@ -243,17 +245,17 @@ export default definePlugin({ name: customFormat(settings.store.nameString, trackData), details: customFormat(settings.store.detailsString, trackData), - state: customFormat(settings.store.stateString, trackData), + state: isRadio ? undefined : customFormat(settings.store.stateString, trackData), - timestamps: (settings.store.enableTimestamps ? { + timestamps: (trackData.playerPosition && trackData.duration && settings.store.enableTimestamps) ? { start: Date.now() - (trackData.playerPosition * 1000), end: Date.now() - (trackData.playerPosition * 1000) + (trackData.duration * 1000), - } : undefined), + } : undefined, assets, - buttons: buttons.length ? buttons.map(v => v.label) : undefined, - metadata: { button_urls: buttons.map(v => v.url) || undefined, }, + buttons: !isRadio && buttons.length ? buttons.map(v => v.label) : undefined, + metadata: !isRadio && buttons.length ? { button_urls: buttons.map(v => v.url) } : undefined, type: settings.store.activityType, flags: ActivityFlag.INSTANCE, diff --git a/src/plugins/appleMusic.desktop/native.ts b/src/plugins/appleMusic.desktop/native.ts index 2eb2a075..7d69a85a 100644 --- a/src/plugins/appleMusic.desktop/native.ts +++ b/src/plugins/appleMusic.desktop/native.ts @@ -11,37 +11,11 @@ import type { TrackData } from "."; const exec = promisify(execFile); -// function exec(file: string, args: string[] = []) { -// return new Promise<{ code: number | null, stdout: string | null, stderr: string | null; }>((resolve, reject) => { -// const process = spawn(file, args, { stdio: [null, "pipe", "pipe"] }); - -// let stdout: string | null = null; -// process.stdout.on("data", (chunk: string) => { stdout ??= ""; stdout += chunk; }); -// let stderr: string | null = null; -// process.stderr.on("data", (chunk: string) => { stdout ??= ""; stderr += chunk; }); - -// process.on("exit", code => { resolve({ code, stdout, stderr }); }); -// process.on("error", err => reject(err)); -// }); -// } - async function applescript(cmds: string[]) { const { stdout } = await exec("osascript", cmds.map(c => ["-e", c]).flat()); return stdout; } -function makeSearchUrl(type: string, query: string) { - const url = new URL("https://tools.applemediaservices.com/api/apple-media/music/US/search.json"); - url.searchParams.set("types", type); - url.searchParams.set("limit", "1"); - url.searchParams.set("term", query); - return url; -} - -const requestOptions: RequestInit = { - headers: { "user-agent": "Mozilla/5.0 (Windows NT 10.0; rv:125.0) Gecko/20100101 Firefox/125.0" }, -}; - interface RemoteData { appleMusicLink?: string, songLink?: string, @@ -51,6 +25,24 @@ interface RemoteData { let cachedRemoteData: { id: string, data: RemoteData; } | { id: string, failures: number; } | null = null; +const APPLE_MUSIC_BUNDLE_REGEX = /