YouTube Zend library get VideoId of playlist entry - php

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?

I found the issue.
I needed to set the GData library version to version 2 on the $yt object
Used this:
$yt->setMajorProtocolVersion(2);
This made all the strange behavior disappear and the usage of $playlistVideoEntry->getMediaGroup()->getVideoId() worked as expected.

Have you tried doing
$playlistVideoEntry->getMediaGroup()->getVideoId();
Because from looking in the API, there seems to be such a function that should return exactly what you would need.

Related

Getting videos from a playlist

Is there a way to get a listing of videos from a specific playlist? I tried the following call, but it doesn't seem to be giving me a list of videos in that playlist
feed://gdata.youtube.com/feeds/users/USERNAME/playlists/PLAYLIST_ID
I want get all the playlists video url and name ...
Thanks in advance,
This is available in the JavaScript API:
player.getPlaylist():Array
This function returns an array of the video IDs in the playlist as
they are currently ordered. By default, this function will return
video IDs in the order designated by the playlist owner. However, if
you have called the setShuffle function to shuffle the playlist order,
then the getPlaylist() function's return value will reflect the
shuffled order.
That's v2 of the API that was deprecated over a year ago. You need to use v3.
Start here: https://developers.google.com/youtube/v3/docs/playlistItems/list

Yii JWPlayer playlist issue

I am still new to Yii. I need a video player in the website I am designing, so I just get JWPlayer for yii from below :
http://www.yiiframework.com/extension/ejwplayer/
I am able to put a single video in my Yii application using the filepath option, but I want to put more than only one video. The example of playlist does not work for me, but I really need the playlist !
My videos are in a videos folder(www.myWebsite.com/htdocs/videos).

Is it possible to alter the source video a youtube ID refers to?

Using the Zend_Gdata php library, is it possible to edit an existing youtube video entry to have a new source video? The use-case is I'm ebedding a timelapse recording of construction work, and I'd like to update the video each evening without changing the embed link each time.
If this is not possible, is there another way I can achieve this without requiring the embed code to be changed each day?
You can use a playlist, and update the playlist elements all days without changing the embed code. You can use the YouTube Data API to change the playlist elements:
https://developers.google.com/youtube/v3/docs/playlistItems

developer tags in youtube php api

Has anyone got the developer tags working with the php zend client library?
I have uploaded videos with developer tag of "BABYLON__"
Following the api instructions it should be able to retrieve only those videos with developer tags attached using the code below
$devTagUrl =
'http://gdata.youtube.com/feeds/api/videos/-/%7Bhttp%3A%2F%2Fgdata.youtube.com' .
'%2Fschemas%2F2007%2Fdevelopertags.cat%7DBABYLON__';
// obtain a feed with videos matching the provided developer tag
$yt->getVideoFeed($devTagUrl);
however this returns nothing. I know the videos exist, as a call to
$devTagUrl = "http://gdata.youtube.com/feeds/api/users/default/uploads";
$videoFeed = $yt->getVideoFeed($devTagUrl);
pulls all videos into the feed.
Anyone?
there is a delay between uploading and developer tags being available for searching on. do not expect your videos to be searchable immediately you have uploaded them, delay can be over an hour!

youtube xml feed for single playlist

Perhaps I am missing something but how does one go about retrieving the xml feed of videos from a single YouTube playlist. I have tried all the ways listed on google and so on but they keep returning an invalid playlist if error even though the id is exactly the one in the youtube url that works on youtube.
Thanks
You can get listing of user's public playlists at:
http://gdata.youtube.com/feeds/api/users/username/playlists?alt=rss&v=2
And you can get xml data for an individual playlist by at:
http://gdata.youtube.com/feeds/api/playlists/AA8A0579E8329C7A?alt=rss&v=2
replace AA8A0579E8329C7A with the playlist-id you want.

Categories