bugfix
This commit is contained in:
parent
1a8b81cb53
commit
f1bbf852e2
@ -74,13 +74,20 @@ export function parseTextFromCaptions(caption_text) {
|
|||||||
* @returns {Promise<import("googleapis").youtube_v3.Schema$PlaylistItem[]>}
|
* @returns {Promise<import("googleapis").youtube_v3.Schema$PlaylistItem[]>}
|
||||||
*/
|
*/
|
||||||
export async function getVideosFromPlaylist(access_token, playlist_id) {
|
export async function getVideosFromPlaylist(access_token, playlist_id) {
|
||||||
const videos = await service.playlistItems.list({
|
if(!access_token) return [];
|
||||||
|
let videos;
|
||||||
|
try {
|
||||||
|
videos = await service.playlistItems.list({
|
||||||
access_token,
|
access_token,
|
||||||
part: "id,snippet",
|
part: "id,snippet",
|
||||||
playlistId: playlist_id,
|
playlistId: playlist_id,
|
||||||
maxResults: 10
|
maxResults: 10
|
||||||
}).then(res => res);
|
}).then(res => res)
|
||||||
|
} catch (e) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(videos.status);
|
||||||
if (videos.status > 299 || videos.status < 200) {
|
if (videos.status > 299 || videos.status < 200) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@ -143,7 +150,9 @@ export async function getAccessToken(fastify, request) {
|
|||||||
|
|
||||||
if ((new Date().getTime() + 10) > request.session.expires_at) {
|
if ((new Date().getTime() + 10) > request.session.expires_at) {
|
||||||
/** @type {import('@fastify/oauth2').Token} */
|
/** @type {import('@fastify/oauth2').Token} */
|
||||||
const {token} = await fastify.googleOAuth2.getNewAccessTokenUsingRefreshToken(request.session);
|
const { token } = await fastify.googleOAuth2.getNewAccessTokenUsingRefreshToken(request.session).catch(e => ({token: null}));
|
||||||
|
|
||||||
|
if(!token) return ""
|
||||||
|
|
||||||
access_token = token.access_token;
|
access_token = token.access_token;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user