From 3f210c53f4ba310bf971e80825935067b29b99b4 Mon Sep 17 00:00:00 2001 From: Hellyson Rodrigo Parteka Date: Thu, 23 Sep 2021 00:41:26 -0300 Subject: [PATCH] fix: playlist load, cache key Fixes #357 --- src/services/get-songs.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/services/get-songs.ts b/src/services/get-songs.ts index a624d54..ba4401c 100644 --- a/src/services/get-songs.ts +++ b/src/services/get-songs.ts @@ -139,18 +139,20 @@ export default class { // Start fetching extra details about videos videoDetailsPromises.push((async () => { // Unfortunately, package doesn't provide a method for this + const p = { + searchParams: { + part: 'contentDetails', + id: items.map(item => item.contentDetails.videoId).join(','), + key: this.youtubeKey, + responseType: 'json', + }, + }; const {items: videoDetailItems} = await this.cache.wrap( async () => got( 'https://www.googleapis.com/youtube/v3/videos', - { - searchParams: { - part: 'contentDetails', - id: items.map(item => item.contentDetails.videoId).join(','), - key: this.youtubeKey, - responseType: 'json', - }, - }, + p, ).json() as Promise<{items: VideoDetailsResponse[]}>, + p, { expiresIn: ONE_MINUTE_IN_SECONDS, },