Skip to content

Commit

Permalink
modified: engine/process_md.py: fix missing title for youtube video
Browse files Browse the repository at this point in the history
  • Loading branch information
mmagnus committed Oct 22, 2023
1 parent b162e11 commit 2bab31d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions engine/process_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,14 @@ def get_youtube_embeds_insert(text):
video_url = "https://www.youtube.com/watch?v=" + video_id
content = requests.get(video_url)
soup = bs(content.content, "html.parser")
title = soup.find("title").text.replace('- YouTube', '').strip()
# title = soup.find("title").text.replace('- YouTube', '').strip()
# title is wrong right now
from pytube import YouTube
yt = YouTube(video_url)
title = yt.title
logger.info('youtube video detected: %s', video_id)
# '**' + title + '**\n
l = '<iframe width="800" height="441" src="https://www.youtube.com/embed/' + \
l = title + '\n<iframe width="800" height="441" src="https://www.youtube.com/embed/' + \
video_id + '" frameborder="0" allowfullscreen></iframe>\n' + \
'<https://www.youtube.com/watch?v=' + video_id + '>'
changed = True
Expand Down

0 comments on commit 2bab31d

Please sign in to comment.