I'm catching a 301 Perm Moved page when I post a link.
I added some echo's to the script to see where it was going wrong, and they all check out.
This is what I get from the sock read echo:
HTTP/1.1 301 Moved Permanently
Date: Sat, 03 Oct 2015 00:39:59 GMT
Server: gwiseguy/2.0
Content-Length: 0
X-XSS-Protection: 1; mode=block; report=https://www.google.com/appserve/security-bugs/log/youtube
Cache-Control: no-cache
Content-Type: text/html; charset=utf-8
X-Content-Type-Options: nosniff
P3P: CP="This is not a P3P policy! See http://support.google.com/accounts/answer/151657?hl=en for more info."
Location: https://www.youtube.com/watch?v=kdUnpV7n1xs
Expires: Tue, 27 Apr 1971 19:44:06 EST
X-Frame-Options: SAMEORIGIN
Set-Cookie: VISITOR_INFO1_LIVE=S9KY8ccag8c; path=/; domain=.youtube.com; expires=Thu, 02-Jun-2016 12:32:59 GMT; httponly
Set-Cookie: YSC=uhmg8nBjaOs; path=/; domain=.youtube.com; httponly