From 1dac031270f63f091c15143558769e25721cb71f Mon Sep 17 00:00:00 2001 From: Shreya Singhal <54439012+sonalshreya@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:15:29 -0600 Subject: [PATCH 1/4] Update youtube.py modifying the instantiation of the YouTube object to include use_oauth=True and allow_oauth_cache=True will enable OAuth-based authentication, allowing you to access videos that require login. This should correct the issue being faced with the KeyError: 'videoDetails'. --- libs/community/langchain_community/document_loaders/youtube.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/community/langchain_community/document_loaders/youtube.py b/libs/community/langchain_community/document_loaders/youtube.py index 67c1569adf8d6..a4b98e6be559b 100644 --- a/libs/community/langchain_community/document_loaders/youtube.py +++ b/libs/community/langchain_community/document_loaders/youtube.py @@ -319,7 +319,7 @@ def _get_video_info(self) -> Dict: 'Could not import "pytube" Python package. ' "Please install it with `pip install pytube`." ) - yt = YouTube(f"https://www.youtube.com/watch?v={self.video_id}") + yt = YouTube(f"https://www.youtube.com/watch?v={self.video_id}", use_oauth=True, allow_oauth_cache=True) video_info = { "title": yt.title or "Unknown", "description": yt.description or "Unknown", From ae503f0d18f7a0ea5f9b0fedc022951abe667f47 Mon Sep 17 00:00:00 2001 From: Shreya Singhal <54439012+sonalshreya@users.noreply.github.com> Date: Wed, 13 Nov 2024 22:04:23 -0600 Subject: [PATCH 2/4] Update youtube.py updated as the length of the line exceeded the required check --- .../langchain_community/document_loaders/youtube.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/community/langchain_community/document_loaders/youtube.py b/libs/community/langchain_community/document_loaders/youtube.py index a4b98e6be559b..3e863ea40a31b 100644 --- a/libs/community/langchain_community/document_loaders/youtube.py +++ b/libs/community/langchain_community/document_loaders/youtube.py @@ -319,7 +319,11 @@ def _get_video_info(self) -> Dict: 'Could not import "pytube" Python package. ' "Please install it with `pip install pytube`." ) - yt = YouTube(f"https://www.youtube.com/watch?v={self.video_id}", use_oauth=True, allow_oauth_cache=True) + yt = YouTube( + f"https://www.youtube.com/watch?v={self.video_id}", + use_oauth=True, + allow_oauth_cache=True + ) video_info = { "title": yt.title or "Unknown", "description": yt.description or "Unknown", From 107cffc1f592ae59aa443d7a2b3170438cf42654 Mon Sep 17 00:00:00 2001 From: Shreya Singhal <54439012+sonalshreya@users.noreply.github.com> Date: Wed, 13 Nov 2024 22:08:28 -0600 Subject: [PATCH 3/4] Update youtube.py solving commit issues --- libs/community/langchain_community/document_loaders/youtube.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/community/langchain_community/document_loaders/youtube.py b/libs/community/langchain_community/document_loaders/youtube.py index 3e863ea40a31b..16f18d7bec561 100644 --- a/libs/community/langchain_community/document_loaders/youtube.py +++ b/libs/community/langchain_community/document_loaders/youtube.py @@ -319,8 +319,9 @@ def _get_video_info(self) -> Dict: 'Could not import "pytube" Python package. ' "Please install it with `pip install pytube`." ) + yt_url = f"https://www.youtube.com/watch?v={self.video_id}" yt = YouTube( - f"https://www.youtube.com/watch?v={self.video_id}", + yt_url, use_oauth=True, allow_oauth_cache=True ) From 54d3148818fb2e9f41b5467709f921ef1c24980c Mon Sep 17 00:00:00 2001 From: Shreya Singhal <54439012+sonalshreya@users.noreply.github.com> Date: Wed, 13 Nov 2024 22:12:46 -0600 Subject: [PATCH 4/4] Update youtube.py --- libs/community/langchain_community/document_loaders/youtube.py | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/community/langchain_community/document_loaders/youtube.py b/libs/community/langchain_community/document_loaders/youtube.py index 16f18d7bec561..fd7634750400b 100644 --- a/libs/community/langchain_community/document_loaders/youtube.py +++ b/libs/community/langchain_community/document_loaders/youtube.py @@ -324,6 +324,7 @@ def _get_video_info(self) -> Dict: yt_url, use_oauth=True, allow_oauth_cache=True + ) video_info = { "title": yt.title or "Unknown",