Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to retrieve the Video Title?#284

Vendrel started this conversation inGeneral
May 11, 2024· 2 comments· 1 reply
Discussion options

I seevideo_id,language_code but couldn't find a variable for video title.
'Transcript' object has no attribute 'video_title'
'Transcript' object has no attribute 'title'

You must be logged in to vote

Replies: 2 comments 1 reply

Comment options

It truly seems there's no attribute for Video Title.

The following code template worked for me:

import requestsfrom bs4 import BeautifulSoup# YouTube Video IDvideo_id = 'YOUR_VIDEO_ID'# YouTube Video URLurl = f'https://www.youtube.com/watch?v={video_id}'# Extracting HTML Code of the Video Page:response = requests.get(url)html_content = response.text# Processing the HTML Code with BeautifulSoupsoup = BeautifulSoup(html_content, 'html.parser')# Extracting <title> tag's contenttitle_tag = soup.find('meta', property='og:title')video_title = title_tag['content'] if title_tag else 'Title not found'print(video_title)
You must be logged in to vote
0 replies
Comment options

Hi@Vendrel!
That is correct, there is no property for the video title. I generally prefer keeping the scope of this module rather small/concise and therefore try to avoid adding features that require additional requests and parsing of data to add metadata that is not strictly required for retrieving transcripts.

You must be logged in to vote
1 reply
@tstanescu1
Comment options

Thanks@jdepoix for the great tool! I'm currently in the process of implementing it in my app, but I have two issues:

  1. Same as@Vendrel , I would love to have at least a title when extracting the transcripts, if not I would have to make a second request to another API. I understand that you want it to be lean, but I think a title would be a relatively cheap addition that would bring much benefit, as title and captions go well together.
  2. I understand that the default language is set to "en", but if you try to extract a video, without specifying the language it will throw an error for any language other than "en". Could we possibly make it to be using en OR the default language of the video? This would be super useful as now I have to create 2 requests, one to get the video and check the language, and then make sure to set it.

Very much appreciated Jonas, thanks again!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
General
Labels
None yet
3 participants
@Vendrel@jdepoix@tstanescu1

[8]ページ先頭

©2009-2025 Movatter.jp