{"id":51,"date":"2013-11-22T08:50:16","date_gmt":"2013-11-22T09:06:39","guid":{"rendered":"https:\/\/632d6iphone_youtube.jpg"},"modified":"2015-07-16T18:49:50","modified_gmt":"2015-07-17T00:49:50","slug":"funcion-para-extraer-el-id-del-video-de-youtube","status":"publish","type":"post","link":"https:\/\/emanuelpaxtian.com\/blog\/funcion-para-extraer-el-id-del-video-de-youtube\/","title":{"rendered":"Funcion para extraer el id del video de youtube"},"content":{"rendered":"<p>En muchas ocasiones necesitamos extraer el ID de ciertos videos de youtube para luego hacer operaciones sobre ellos como extraer la imagen o manejarlo con cierto reproductor.<\/p>\n<p dir=\"ltr\">Para ello existe esta funcion con la cual podremos extraer el id del video para ello solo necesitamos pegar la url del video y nos devolvera el id<\/p>\n<p dir=\"ltr\">Aqui el codigo que realiza dicha funcion.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">function youtube($text){\r\n$MatchThis='\/&#x5B;\\\\?\\\\&amp;amp;]v=(&#x5B;^\\\\?\\\\&amp;amp;]+)\/';\r\nif(preg_match($MatchThis,$text,$matches))\r\n{\r\n\/\/ no queremos un enlace como este php?v= sea visto como youtube video!.\r\nif(strlen($vidid=$matches&#x5B;1]) == 11){\r\nreturn $vidid;\r\n}else{\r\nreturn $text;\/\/ no paso el text de el ID de youtube..\r\n}\r\n}else{\r\nreturn $text;\/\/ retornamos el texto pues no es un video youtube.\r\n}\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>En muchas ocasiones necesitamos extraer el ID de ciertos videos de youtube para luego hacer operaciones sobre ellos como extraer la imagen o manejarlo con cierto reproductor. Para ello existe&hellip;<\/p>\n","protected":false},"author":1,"featured_media":501,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-51","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-osx"],"_links":{"self":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/posts\/51","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/comments?post=51"}],"version-history":[{"count":0,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/posts\/51\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/media\/501"}],"wp:attachment":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/media?parent=51"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/categories?post=51"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/tags?post=51"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}