fix(youtube): correct cache expiration handling in getLive function (#21853)

This commit is contained in:
Tony 2026-04-29 12:52:27 +08:00 committed by GitHub
parent 9bf19b8191
commit e06a6dee24
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 11 deletions

View File

@ -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