Is it possible to check for duplicate youtube upload?
When I try to upload the same video it is in the rejected section of youtube and shows the status as 'duplicate'.
Is it possible to check duplicate video upload in the client side itself as youtube is doing?
If you make a request to retrieve the video entry while authorized as the owner of the video, you can get information back about that video, including whether it was rejected and the cause for rejection. (Rejected videos are not returned in unauthorized API responses.)
There's a section of the documentation that describes how to check for this sort of thing. For a video that's rejected as a duplication, you'll get back a <yt:state> element in the response that looks approximately like
<yt:state name="rejected" reasonCode="duplicate" ...>...</yt:state>
There's no way to determine whether a video is a duplicate or not as part of the upload response, because YouTube doesn't know whether the video is a duplicate until it has processed the video, and processing takes place after the upload has completed.
In PHP:
Assuming you already have a service object.
$listResponse = $service->videos->listVideos('status', ['id' => $youtube_id]);
$video = $listResponse[0];
$status = $video->getStatus();
$uploadStatus = $status['uploadStatus'];
$failureReason = $status['failureReason'];
$rejectionReason = $status['rejectionReason'];
if ( $uploadStatus == 'rejected' && $rejectionReason == 'duplicate' ) {
throw new Exception('Duplicate');
fi
uploadStatus can be one of the following: deleted, failed, processed, rejected, uploaded
failureReason can be one of the following: codec, conversion, emptyFile, invalidFile, tooSmall, uploadAborted
rejectionReason can be one of the following: claim, copyright, duplicate, inappropriate, legal, length, termsOfUse, trademark, uploaderAccountClosed, uploaderAccountSuspended
I haven’t found a way to retrieve the ID of the original video of which the offending video is a duplicate.
See the documentation for the video object at https://developers.google.com/youtube/v3/docs/videos