Answer the question
In order to leave comments, you need to log in
How to run youtube-dl via subprocess in python?
Hello. I need to get the video sheet format from the link in order to find the code of the format I'm interested in. To do this, I'm trying to run youtube-dl with the --list-formats parameter to link to the video via the subprocess module. But in the terminal, instead of a list of formats, I see this text: [b'ERROR: \'--list-formats https://www.youtube.com/watch?v=e_Z6ZcCwPcU\ ' is not a valid URL. Set --default-search "ytsearch" (or run youtube-dl "ytsearch:--list-formats https://www.youtube.com/watch?v=e_Z6ZcCwPcU " ) to search YouTube\n']
But if you run just with the specified link, then the video just swings in maximum quality as it should.
Here is the code, please help me what is the problem:
import subprocess
p=subprocess.Popen(['youtube-dl', " --list-formats https://www.youtube.com/watch?v=e_Z6ZcCwPcU"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
result=p.stdout.readlines()
print(result)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question