diff --git a/src/plugins/appleMusic.desktop/index.tsx b/src/plugins/appleMusic.desktop/index.tsx index 6fa989cdd..327fafc30 100644 --- a/src/plugins/appleMusic.desktop/index.tsx +++ b/src/plugins/appleMusic.desktop/index.tsx @@ -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, diff --git a/src/plugins/appleMusic.desktop/native.ts b/src/plugins/appleMusic.desktop/native.ts index 2eb2a0757..7d69a85ae 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 = /