Skip to content

Commit

Permalink
Format Python code with psf/black push
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions authored and github-actions committed Nov 4, 2023
1 parent 6155574 commit 4362972
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions models/index_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,18 +607,21 @@ def index_gdoc(self, doc_id, service_context) -> GPTVectorStoreIndex:

def index_youtube_transcript(self, link, service_context):
try:

def convert_shortlink_to_full_link(short_link):
# Check if the link is a shortened YouTube link
if "youtu.be" in short_link:
# Extract the video ID from the link
video_id = short_link.split('/')[-1].split('?')[0]
video_id = short_link.split("/")[-1].split("?")[0]
# Construct the full YouTube desktop link
desktop_link = f"https://www.youtube.com/watch?v={video_id}"
return desktop_link
else:
return short_link

documents = YoutubeTranscriptReader().load_data(ytlinks=[convert_shortlink_to_full_link(link)])
documents = YoutubeTranscriptReader().load_data(
ytlinks=[convert_shortlink_to_full_link(link)]
)
except Exception as e:
raise ValueError(f"The youtube transcript couldn't be loaded: {e}")

Expand Down

0 comments on commit 4362972

Please sign in to comment.