From a8571f28c6e59cf04bd26451fad5f1df62dcc637 Mon Sep 17 00:00:00 2001 From: reidlab Date: Tue, 21 Oct 2025 00:06:26 -0700 Subject: [PATCH] fix evil edge case (and fix typo) is it really my fault. they say it's required right here: https://developer.apple.com/documentation/applemusicapi/songs/attributes-data.dictionary --- src/appleMusicApi/types/attributes.ts | 4 +++- src/index.ts | 2 +- src/web/index.ts | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/appleMusicApi/types/attributes.ts b/src/appleMusicApi/types/attributes.ts index 39fc2d8..20963da 100644 --- a/src/appleMusicApi/types/attributes.ts +++ b/src/appleMusicApi/types/attributes.ts @@ -53,7 +53,9 @@ export type SongAttributes< composerName?: string; contentRating?: string; discNumber?: number; - durationInMillis: number; + // >claims to be required + // >not present sometimes ?? + durationInMillis?: number; editorialNotes?: EditorialNotes; genreNames: string[]; hasLyrics: boolean; diff --git a/src/index.ts b/src/index.ts index fd7e220..8b0bd09 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,7 +16,7 @@ setGlobalDispatcher(new Agent().compose([ // TODO: configurable cache sizes? // these values are pretty nice for non-binary (lol) data interceptors.cache({ store: new cacheStores.MemoryCacheStore({ - maxSize: 50 * 1024 * 1024, // 5mb + maxSize: 50 * 1024 * 1024, // 50mb maxCount: 1000, maxEntrySize: 5 * 1024 // 5kb })}) diff --git a/src/web/index.ts b/src/web/index.ts index 3f244bb..1e3201d 100644 --- a/src/web/index.ts +++ b/src/web/index.ts @@ -24,7 +24,7 @@ const hbs = create({ helpers: { add(a: number, b: number) { return a + b; }, arrayJoin(array: string[], separator: string) { return array.join(separator); }, - formatDuration(duration: number) { return formatDuration(duration); }, + formatDuration(duration?: number) { return duration === undefined ? "n/a" : formatDuration(duration); }, greaterThan(a: number, b: number) { return a > b; }, mapNumberToLetter(num: number) { return String.fromCharCode(num + 64); } // A = 1, B = 2 }