Using the YouTube API v3 to list all private videos

霸气de小男生 提交于 2019-12-04 15:46:25
  1. Get the ZF Gdata Library @ http://framework.zend.com/downloads/latest

  2. Run the Autoloader:

    set_include_path(APPPATH . 'third_party/zf/' . get_include_path());
    require 'Zend/Loader/Autoloader.php';
    Zend_Loader_Autoloader::getInstance();
    
  3. Create an HTTP Instance with your youtube Login, Password, and Developer Key (Youll have to grab one).

       $httpClient = Zend_Gdata_ClientLogin::getHttpClient(
                "Youtube LOGIN", 
                "Youtube PASSWORD", 
                'youtube'
        );
    
  4. Instantiate GData with your cedentials

        $yt = new Zend_Gdata_YouTube(
                $httpClient, 
                null,
                null, 
                "Youtube Developer Key"
        );
    
  5. Fetch your playlist

        $playlistListFeed = $yt->getPlaylistListFeed("YOUR YOUTUBE CHANNEL NAME");
        //print_r($playlistListFeed); // uncomment to see the goods
    
  6. Prepare an array to sort through less data

        $data['feed'] = array();
    
  7. Loop through everything, use the is_private to tell if its private or not

        foreach ($playlistListFeed as $playlistEntry) 
        {
          $feedUrl = $playlistEntry->getPlaylistVideoFeedUrl();
          $playlistVideoFeed = $yt->getPlaylistVideoFeed($feedUrl);
    
          foreach ($playlistVideoFeed as $video) {
    
            $data['feed'][] = array(
                'id' => $video->getVideoId(),
                'title' => $video->getTitle(),
                'thumbnail' => $video->getVideoThumbnails(),
                'is_private' => $video->isVideoPrivate(),
                'url' => $video->getVideoWatchPageUrl(),
                'flash_url' => $video->getFlashPlayerUrl ()
            );
        }
    
    } 
    

You may have to tinker around with it to get it right to your settings, hope this helps.

I believe that you can do that, using the YouTube Data v3, in this way:

Get the uploaded videos in this way (it is a Java example):

https://developers.google.com/youtube/v3/docs/playlistItems/list#examples

And then you can retrieve the videos resources for these playlistitems using:

https://developers.google.com/youtube/v3/docs/videos/list

And then you can verify the status.privacyStatus in each video resource (if you upload videos with a different status.privacyStatus .. )

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!