import youtube_dl
ydl_opts = {
'outtmpl': 'tmp/%(id)s.%(ext)s',
'prefer_ffmpeg': True,
'forceduration':True
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
dictMeta = ydl.extract_info(
"https://www.youtube.com/watch?v=t99ULJjCsaM",
download=True)
dictMeta['entries'][0]['duration']