문제

First of all let me say that I am not asking "how to check a status of a previously uploaded video". My question is about getting the status of a video from the response of an upload. I am using the dotnet client and right after an upload is completed the response is a Google.Apis.Youtube.v3.Data.Video object. That object has a property called Status that contains the folllowing fields among others: RejectionReason, PrivacyStatus and UploadStatus. The problem is that only the PrivacyStatus and UploadStatus have values. The RejectionReason is null. Jeff Posnick mentioned that (see whole thread here)

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

That's a bit strange because when I issue a video.list right after the upload the API returns a status for the uploaded video. So even if the video is not published and it seems like YouTube is still indexing/processing the video it already knows the status of the "just uploaded video". So why can it not return the status as part of the response?

It's important that the response include the status because if not then, in the code, we have to do two API calls each time we do an upload: (1) insertmediaupload then (2) video.list. It'd a very costly operation especially that not all uploads will be duplicate.

EDIT As a response to Jeff-Posnick's comment below the question is "can the API wait for a few seconds and check if the processing is done and then include the status as part of the response?".

I came up with that question because of the behavior I've seen: That's a bit strange because when I issue a video.list right after the upload the API returns a status for the uploaded video. But I've been playing around with the API and got inconsistent results. I have uploaded the same video over and over and sometimes there is "a duplicate" status and sometimes there is none. Please take note of the steps I took, #1 and #2 above. There are no other codes in between of those two API calls.

도움이 되었습니까?

해결책

I'm not sure what the question is here.

You seem to understand the limitations of the way uploads work with the YouTube API, and those limitations still apply with v3 of the YouTube Data API. At the time that a response is returned from the videos.insert() request, the status of the video is not known, because it hasn't been processed yet. The actual processing might happen a second or two after the video has been uploaded, or it might happen a few minutes (or longer) after the video has been uploaded, especially for larger video files. It's not done in real time, and it's not reasonable to expect the videos.insert() API call to block waiting for the processing to be finished.

I'd disagree with your assessment that performing a videos.list(id=...,part=status) is a "very costly operation". The amount of bandwidth and YouTube API quota that consumes is minimal compared to an actual video upload. It would be nice to provide a way to communicate back the processing status independent of the videos.insert() call via some sort of callback or push update mechanism, but we don't have anything available like that at this time. You have to poll videos.list(id=...,part=status).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top