I spent about 5 hours today working on modifying this to create a modern Auto YouTube Embed mod for my vBulletin 3.8 board (though this should also work on 4.x boards), and I thought I would share it here. This is a simple way for bare YouTube URL's in posts to be automatically converted to embedded video.
What it detects/auto-converts:
It will only match on URL's that are in BB code [url] links. I tried to make it match non-linked URLs, but it was a bad idea because it wreaked havoc with BB code tags that might have YouTube URL's in them, like [code] or custom [youtube] tags.
By default, vBulletin auto-[url] links text that starts with www, http, or https. That means this will match most YouTube URLs that users might put in their post, but text like m.youtube.com/watch?v=XXXXXXXXXXX would not match, unless the user explicitly puts [url] tags around it, because vBulletin would not auto-link it.
It will handle both HTTP and HTTPS URLs
It will handle www, m, or no prefix.
It will handle youtu.be and youtube.com URLs. Besides .com, it will also handle de, jp, ca, co, ch, au, net, and be.
It will handle YouTube URL's in the following forms: watch?v=, v/, e/, embed/
It will not pass through parameters in the URL like "autoplay=1" or "loop=1" or, unfortunately, start times (t=4m3s, for example), but it will not be tripped up by them either.
What it outputs:
It outputs iframe embedding code, which is the
YouTube-preferred embedding method. This allows either the HTML5 player or Flash player to be used, depending on the browser's capabilities.
Fullscreen is enabled
16:9 embedded aspect ratio (700x394 pixels). If you want to change the size, simply edit the width and height in the XML file before installing.