Skip to content

Commit

Permalink
remove debug logging for ytsubs
Browse files Browse the repository at this point in the history
  • Loading branch information
shivanker committed Feb 3, 2025
1 parent 4ca871c commit 433695f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
4 changes: 1 addition & 3 deletions session.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ def extract(text):
if match:
url = match.group(1)
if is_youtube_video(url):
logger.warning(
f"SHIV1 Fetching youtube transcript for {url}. Original text {text}"
)
logger.warning(f"Fetching youtube transcript for {url}. Original text {text}")
return yt_transcript(url) or f"Failed to extract transcript for {url}."
logger.info(f"Reading text from [{url}]. Original text {text}")
return scrape_text(url) or f"Failed to scrape text from {url}."
Expand Down
14 changes: 1 addition & 13 deletions ytsubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,36 +45,24 @@ def extract_video_id(url):

def yt_transcript(url: str) -> Union[str, None]:
"""Function to fetch the transcript of a YouTube video, given the URL."""
logger.warning(f"SHIV1 Fetching youtube transcript for {url}")
cached_transcript = s3_cache.get_cache(CACHE_NAMESPACE, url)
if cached_transcript:
logger.warning(f"SHIV1 Found cached transcript for {url}")
return cached_transcript
try:
logger.warning(f"SHIV1 Extracting video id for {url}")
video_id = extract_video_id(url)
if video_id:
logger.warning(f"SHIV1 Found video id {video_id} for {url}")
transcript = YouTubeTranscriptApi.get_transcript(video_id)
if transcript:
logger.warning(
f"SHIV1 Found transcript for {url}, beginning with {transcript[:50]}"
)
transcript = " ".join(
f"[{segment['start']:.2f}] {segment['text']}"
for segment in transcript
)
s3_cache.set_cache(CACHE_NAMESPACE, url, transcript)
return transcript
else:
logger.warning(f"SHIV1 No transcript found for {url}")
else:
logger.warning(f"SHIV1 No video id found for {url}")
except Exception as e:
logger.exception(
f"SHIV1 Failed to extract transcript for {url}." + str(e),
f"Failed to extract transcript for {url}." + str(e),
stack_info=True,
)
# logger.error(f"SHIV1 Failed to extract transcript for {url}." + str(e))
return None
return "<empty>"

0 comments on commit 433695f

Please sign in to comment.