Reputation: 505
I have been trying to use youtube-dl using python instead of console. I am trying to get some information of a video such as available video formats, title, duration of the video etc. None of the options are working except listformats
. So I tried different combinations of the options described in the documentation. Unfortunately nothing is working. I only see the list of video formats from listformats
. Also, the output is only showing in the console but I need the output info in a variable such as video_details
.
from __future__ import unicode_literals
import youtube_dl
ydl_opts = {
'-v': True,
'format': '-f',
'print_json': True,
'listformats': '--list-formats',
'getfilename': '--get-filename',
'--get-filename': True,
'-e': True,
}
ydl = youtube_dl.YoutubeDL(ydl_opts)
video_details = ydl.download(['https://www.youtube.com/watch?v=BaW_jenozKc'])
Upvotes: 0
Views: 5729
Reputation: 1609
You want to extract the information.
Use the extract_info
-method instead of download
and it will work!
Upvotes: 1