How does VLC open and play youtube videos? If you press Ctrl+N and enter the url of a youtube video, it loads for a few seconds and then plays the video.
How does it parse the HTML code?
VLC has integrated the Lua scripting language to allow users to do things at different times in the playback pipeline. One of the extension points that VLC exposes via Lua is called a playlist extensions. With this type of extension, you can take the URL passed to VLC and transform it to a new URL or set of URLs.
VLC ships with some default Lua extensions, one of which is the
youtube.lua extension. You can read the code for yourself there, but basically the script takes the video URL and pulls in the HTML and parses it to get the video metadata and a URL it can use to play.
Just as a side note, you can see the compiled Lua scripts that ship with VLC in the