fix(youtube): correct cache expiration handling in getLive function (#21853)
This commit is contained in:
parent
9bf19b8191
commit
e06a6dee24
|
|
@ -118,17 +118,22 @@ export async function getSubscriptionsRecusive(part, nextPageToken?) {
|
|||
// taken from https://webapps.stackexchange.com/a/101153
|
||||
export const isYouTubeChannelId = (id) => /^UC[\w-]{21}[AQgw]$/.test(id);
|
||||
export const getLive = (id, cache) =>
|
||||
cache.tryGet(`youtube:getLive:${id}`, async () => {
|
||||
const res = await exec((youtube) =>
|
||||
youtube.search.list({
|
||||
part: 'snippet',
|
||||
channelId: id,
|
||||
eventType: 'live',
|
||||
type: 'video',
|
||||
})
|
||||
);
|
||||
return res;
|
||||
});
|
||||
cache.tryGet(
|
||||
`youtube:getLive:${id}`,
|
||||
async () => {
|
||||
const res = await exec((youtube) =>
|
||||
youtube.search.list({
|
||||
part: 'snippet',
|
||||
channelId: id,
|
||||
eventType: 'live',
|
||||
type: 'video',
|
||||
})
|
||||
);
|
||||
return res;
|
||||
},
|
||||
config.cache.routeExpire,
|
||||
false
|
||||
);
|
||||
export const getVideoUrl = (id: string) => `https://www.youtube-nocookie.com/embed/${id}?controls=1&autoplay=1&mute=0`;
|
||||
|
||||
// Get the appropriate playlist ID with or without shorts
|
||||
|
|
|
|||
Loading…
Reference in New Issue