From 245ab19183499a424c981cc8cb24964b00a4a0d0 Mon Sep 17 00:00:00 2001 From: Dylan De Faoite Date: Mon, 19 Jan 2026 22:54:48 +0000 Subject: [PATCH] Add error handling for YouTube comments fetching --- connectors/youtube_api.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/connectors/youtube_api.py b/connectors/youtube_api.py index 650590d..b132578 100644 --- a/connectors/youtube_api.py +++ b/connectors/youtube_api.py @@ -2,6 +2,7 @@ import os from dotenv import load_dotenv from googleapiclient.discovery import build +from googleapiclient.errors import HttpError from dto.post import Post from dto.comment import Comment @@ -30,7 +31,12 @@ class YouTubeAPI: maxResults=limit, textFormat='plainText' ) - response = request.execute() + + try: + response = request.execute() + except HttpError as e: + print(f"Error fetching comments for video {video_id}: {e}") + return [] return response.get('items', []) def fetch_and_parse_videos(self, query, video_limit, comment_limit):