25
Feb 08

Post YouTube videos to your blog

Since I started IdontNeedYouTube.com, I had to face a little annoying detail of posting from the “share” link on YouTube.
The way the post is formatted is not cleanly parsed by xmlrpc.php on WordPress.

Basically the title is not recognized and is instead part of the post body.

the way I solved it:

  • duplicate xmlrpc.php
  • call it xmlrpc_custom.php (the main reason is preventing overwriting when you update WordPress… which is lately happening very often)
  • look for the function blogger_newPost

at about line 844 you can find $post_author
paste this snippet of code

$htVar=html_entity_decode($content);
if($stIndx=strpos($htVar,">")+1){
$enIndx=strpos($htVar,"");
$post_title=(substr($htVar,$stIndx,$enIndx-3));
$content=substr($content,$enIndx+5,strlen($htVar)-1);
}

right after

$post_title = xmlrpc_getposttitle($content);

now you just have to change the script URL in your YouTube blog settings.

I’m quite sure this could be done easily with RegExp, but I really never had time to learn all that complicated stuff.

enjoy

Popularity: 1% [?]


Leave a Reply