I’m trying to get youtube video duration by using youtube-dl in python. here is the code, I cant find duration in dictMeta, how to get it?
import youtube_dl ydl_opts = { 'format': 'bestaudio/best', 'outtmpl': 'tmp/%(id)s.%(ext)s', 'noplaylist': True, 'quiet': True, 'prefer_ffmpeg': True, 'logger': MyLogger(), 'audioformat': 'wav', 'forceduration':True } sID = "t99ULJjCsaM" with youtube_dl.YoutubeDL(ydl_opts) as ydl: dictMeta = ydl.extract_info( "https://www.youtube.com/watch?v={sID}".format(sID=sID), download=True)
Advertisement
Answer
just simple
dictMeta['duration']