Reputation: 139
Is there a way to only get the url when using youtube-dl or yt-dlp embedded in python code?
It seems that --get-url
is not in the YoutubeDL
class' available options.
I tried i think all logical way to pass --get-url
, e.g. geturl
, getUrl
, get_url
, ...
There must be a way since the executable can do it. I wanted to "reverse engineer" it but the code execution order is kinda hard to track since I don't know python very well.
Upvotes: 3
Views: 9519
Reputation: 139
Ok I think I found out and I think it's the intended way to do it.
I just thought that I should be able to directly pass the same flag as a class option, since most of them have the same name, turns out --get-url
is just an "alias" for:
options = {
"quiet": True,
"simulate": True,
"forceurl": True,
}
The more you know.
Also, you can use extract_info(url)
instead of download([url])
, like so:
with youtube_dl.YoutubeDL(options) as ytdl:
info = ytdl.extract_info("https://twitter.com/MissMikkaa/status/1568324392953827328")
url = info["url"]
Hope it can help somebody else in the future :)
Upvotes: 6