I have a small problem converting a console command into python code.
cmd: yt-dlp --referer https://referer.link --no-part "https://video.link"
This works fine in the terminal. i tried to convert it to python like this:
import yt_dlp
ydl_opts = {
'referer': 'https://referer.link',
'no_part': True,
}
video_url = 'https://video.link'
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
ydl.download([video_url])
this executes with following error:
ERROR: [generic] Unable to download webpage: <urllib3.connection.HTTPSConnection object at 0x000001FC91E32D80>: Failed to resolve 'link' ([Errno 11002] getaddrinfo failed) (caused by TransportError("<urllib3.connection.HTTPSConnection object at 0x000001FC91E32D80>: Failed to resolve 'link' ([Errno 11002] getaddrinfo failed)"))
does anyone know whats wrong with my code? thank you
Already tried serval yt_opt
You could use the http_headers opts.
from yt_dlp import YoutubeDL
opts = {
'http_headers': {
'Referer': 'https://referer.link'
}
}
video_url = 'https://video.link'
with YoutubeDL(opts) as ydl:
ydl.download([video_url])