When searching for a playlist item with a specific video ID, the youtube-api seems to only search among the 50 latest playlist items.
I have over 1000 items on my playlist and searching for a item for a certain video ID yields no results. I am therefor forced to fetch all the items on the playlist and iterate overthem my self to find the specific item.
// This only searches among the first 50 playlist items$videoId = 'ASDFQWER';$playlistId = 'ASDFASDFQWERQWER';$part = "contentDetails";$response = $youtube->playlistItems->listPlaylistItems( $part, array("playlistId" => $playlistId,"videoId" => $videoId, ));$playlistItem = reset($response->getItems());// This works, but is slow and awkward$videoId = 'ASDFQWER';$playlistId = 'ASDFASDFQWERQWER';$part = "contentDetails";$playlistItems = array();$nextPageToken = NULL; do { $response = $youtube->playlistItems->listPlaylistItems( $part, array("playlistId" => $playlistId,"maxResults" => 50,"pageToken" => $nextPageToken, ) ); $nextPageToken = $response->getNextPageToken(); $playlistItems = array_merge($playlistItems, $response->getItems());} while ($nextPageToken); $hasVideoId = function($playlistItem) use ($videoId){ $idOnItem = $playlistItem->getContentDetails()->getVideoId(); return ($videoId == $idOnItem);};$playlistItem = reset(array_filter($playlistItems, $hasVideoId));I would prefer to use the video's ID for doing the search at YouTube's end rather than fetching all the items in chuncks of 50 items and searching all those.
The point in all this is to automate the removal of old videos. If I only delete the video there will be invalid items on my playlist. And that's why I need to find these playlist items, so I can remove them along with the videos.
I first opened an issue at GitHub for the PHP-client, but this really doesn't seem to be an issue on the client.
Any help is much appreciated.