Guest User

Adam Dempsey

a guest
Sep 29th, 2008
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. Plugin Name: Video Poster
  5. Version: 0.1
  6. Description: Automatically make new posts based on YouTube feeds.
  7. */
  8.  
  9. register_activation_hook(__FILE__, 'video_poster_activation');
  10. add_action('video_poster_event', 'do_video_post');
  11.  
  12. function video_poster_activation() {
  13.     wp_schedule_event(time(), 'hourly', 'video_poster_event');
  14. }
  15.  
  16. function do_video_post() {
  17.     //yt_user("thebeats");
  18.     //use the YouTube id in a meta custom field to check if already posted?
  19. }
  20.  
  21.  
  22. function get_feed($feed){
  23.     $ch = curl_init();
  24.     $timeout = 0;
  25.     curl_setopt ($ch, CURLOPT_URL, $feed);
  26.     curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  27.     curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  28.     $xml = curl_exec($ch);
  29.     curl_close($ch);
  30.     return $xml;
  31. }
  32.  
  33. function yt_user($user){
  34.     $feed = "http://gdata.youtube.com/feeds/api/users/".$user."/uploads";
  35.     $xml = get_feed($feed);
  36.     preg_match_all("/<media\:title type='plain'>(.+?)<\/media\:title>/",$xml,$titles);
  37.     preg_match_all("/\/v\/(.+?)\&/i",$xml,$ids);   
  38.     array_shift($titles);
  39.     array_shift($ids);
  40.     $total = count($titles[0]);
  41.     //for($i = 0; $i<$total; $i++){
  42.         //echo "<b>".$titles[0][$i]."</b><br/>httpv://youtube.com/watch?v=".$ids[0][$i]."<br><br>";
  43.     //}
  44. }
  45.  
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment