Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Does Youtube-DL have a way to check if a page is compatible? #4503
Comments
|
You can do |
|
Using YoutubeDL via a simple Python script, you could check all of the info extractors to see if there is a dedicated extractor for the given URL - which would avoid having to contact the remote URL at all: import youtube_dl
def supported(url):
ies = youtube_dl.extractor.gen_extractors()
for ie in ies:
if ie.suitable(url) and ie.IE_NAME != 'generic':
# Site has dedicated extractor
return True
return False
print supported("http://www.youtube.com/watch?v=BaW_jenozKc") # True
print supported("http://www.google.com/bad_example_of_unsupported_site") # FalseNot as thorough as actually running |
|
Since I remember this question being asked at least twice before, I've added an FAQ entry that explains why using @dbr's code snippet is not a good idea. You can just call youtube-dl with |
YouTube-DL has a LOT of supported sites, which is great! But if I'm building an application to utilize some of them, is there any way for me to use YouTube-DL as a "catch all"?
Example command:
youtube-dl https://www.videovendor.com/video/title_of_video/1234 --is-compatible
This would yield "Yes" or "No" (in JSON or XML) depending on whether it was compatible.
I think this may be possible to do this with "--write-info-json" and maybe check the format of that, but can we count on consistency with this? If we can, I can then load the same file so it doesn't have to hit the endpoint more than once.
Thanks!