import subprocess def tube(video_id): cmd = ['youtube-dl', '--no-playlist', '--no-warnings', '--quiet', '-f', 'mp4', 'https://www.youtube.com/watch?v={}'.format(video_id) ] subprocess.run(cmd) #convert the above code into youtube_dl python
import youtube_dl ydl_opts = { 'format': 'mp4', 'no-playlist': True, 'quiet': True, 'no-warnings': True } def tube(video_id): with youtube_dl.YoutubeDL(ydl_opts) as ydl: ydl.download(['https://www.youtube.com/watch?v={}'.format(video_id)]) return