I cannot find a way of getting youtube to not return duplicate videos in a feed. I am currently using API v1 and I understand that v2 and v3 are where I should be moving too. I am using ZF 1 and its Gdata library not that it should matter if there is API level support for what I want to do.
However I cannot see the solution in either of those versions either.
Heres whats happening. For some reason the server code is occasionally uploading duplicate videos in parallel. Youtube detects that and then it seems to list a video on the feed as duplicate and it wont play.
https://gdata.youtube.com/feeds/api/users/username/uploads/?max-results=50
So I get 50 videos from that users account. Is there anyway to tell youtube, dont return videos that are duplicates.
I mean it almost seems obvious that it shouldnt right?
Does anyone know anything about filtering duplicates out of feeds? I look at the data returned and theres no indication of a status or any other info which would provide me with a way to tell a clip is duplicate.
Hopefully someone knows the solution.
Cheers!
Okay, so I worked it out, turns out theres a state property which you can interrogate in the feed. See the code below to know how to check the state and ignore it if its been rejected.
Damn Zend Framework v1 Documentation is pretty much non-existent for this kind of thing.
$applicationId = 'App ID';
$clientId = 'Client ID';
$youtubeDeveloperKey = 'Developer Key';
$token = unserialize($gdata_oauth_access_token);
$httpClient = $token->getHttpClient($this->_oauthOptions);
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $youtubeDeveloperKey);
$url = 'https://gdata.youtube.com/feeds/api/users/' . $youtube_user_name . '/uploads/?max-results=50';
$videoFeed = $yt->getVideoFeed($url);
// process the feed
foreach ($videoFeed as $videoEntry) {
$state = $videoEntry->getVideoState();
if (is_object($state) && $state->name == 'rejected') {
// skip this video
continue;
}
}