chore: format

This commit is contained in:
Timothy Jaeryang Baek
2025-05-07 02:01:03 +04:00
parent 96618967bd
commit 6359cb55fe
54 changed files with 169 additions and 113 deletions

View File

@@ -63,13 +63,13 @@ class YoutubeLoader:
self.video_id = _video_id if _video_id is not None else video_id
self._metadata = {"source": video_id}
self.proxy_url = proxy_url
# Ensure language is a list
if isinstance(language, str):
self.language = [language]
else:
self.language = list(language)
# Add English as fallback if not already in the list
if "en" not in self.language:
self.language.append("en")
@@ -87,7 +87,7 @@ class YoutubeLoader:
'Could not import "youtube_transcript_api" Python package. '
"Please install it with `pip install youtube-transcript-api`."
)
if self.proxy_url:
youtube_proxies = {
"http": self.proxy_url,
@@ -97,7 +97,7 @@ class YoutubeLoader:
log.debug(f"Using proxy URL: {self.proxy_url[:14]}...")
else:
youtube_proxies = None
try:
transcript_list = YouTubeTranscriptApi.list_transcripts(
self.video_id, proxies=youtube_proxies
@@ -105,7 +105,7 @@ class YoutubeLoader:
except Exception as e:
log.exception("Loading YouTube transcript failed")
return []
# Try each language in order of priority
for lang in self.language:
try:
@@ -125,8 +125,12 @@ class YoutubeLoader:
except Exception as e:
log.info(f"Error finding transcript for language '{lang}'")
raise e
# If we get here, all languages failed
languages_tried = ", ".join(self.language)
log.warning(f"No transcript found for any of the specified languages: {languages_tried}. Verify if the video has transcripts, add more languages if needed.")
raise NoTranscriptFound(f"No transcript found for any supported language. Verify if the video has transcripts, add more languages if needed.")
log.warning(
f"No transcript found for any of the specified languages: {languages_tried}. Verify if the video has transcripts, add more languages if needed."
)
raise NoTranscriptFound(
f"No transcript found for any supported language. Verify if the video has transcripts, add more languages if needed."
)

View File

@@ -158,7 +158,7 @@ class OAuthManager:
nested_claims = oauth_claim.split(".")
for nested_claim in nested_claims:
claim_data = claim_data.get(nested_claim, {})
if isinstance(claim_data, list):
user_oauth_groups = claim_data
elif isinstance(claim_data, str):