I am using the Zend GData library to manage YouTube videos from within my application. The application gives the user the ability to choose to add the uploaded video to one of their pre-existing YouTube playlists if they desire. One problem is that if the video is subsequently deleted from within our application, it seems to leave an "orphaned" deleted video object within the playlist to which it was added.
I've been trying to figure out a way to have our application remove the video from any playlists before deleting it from YouTube but I am having difficulty figuring out how to determine if a particular YouTube video is contained within playlists.
I've written a function which loops through each entry in each playlist relevant to the logged in user and attempts to compare the video Id of the video in the playlist with a video Id that has been passed as an argument. However, I can't seem to get a value for the video Id for any of the videos in the playlists.
Here's the function:
function remove_video_from_playlists($yt,$hash){
$playlistListFeed = $yt->getPlaylistListFeed("default");
foreach ($playlistListFeed as $playlistListEntry) {
$playlistVideoFeed = $yt->getPlaylistVideoFeed($playlistListEntry->getPlaylistVideoFeedUrl());
foreach ($playlistVideoFeed as $playlistVideoEntry) {
//check to see if each video in the playlist matches the video we are trying to delete
if($playlistVideoEntry->getMediaGroup()->videoId == $hash){
$playlistVideoEntry->delete();
}
}
}
}
Any help would be appreciated. How do I get the underlying videoId of each video entry in the playlists?