yt icon indicating copy to clipboard operation
yt copied to clipboard

"Processing abandoned" videos returning Yt::Errors::NoItems

Open benclum11 opened this issue 4 years ago • 5 comments

When fetching all videos that an authenticated Account object has available (unlisted, public, and private), the gem is throwing a Yt::Errors::NoItems error on failed videos. I think the issue is that youtube doesn't return these videos via the API, and in turn, the gem (correctly) throws a NoItems error. Consequently since an error is raised, I'm unable to get the full list of videos for the account. the account in question has over 600 videos, and it's only returning 100 or so due to the exception being thrown in the middle of fetching the videos. Is it possible to skip videos and not throw an exception when fetching failed videos?

If it helps, the video's status is VIDEO_STATUS_FAILED and the detailed status is VIDEO_STATUS_DETAIL_FAILED_UNKNOWN. the error message in the creator UI is "Processing abandoned. The video could not be processed."

sample code that fetches all videos for an account:

videos = []
account = Yt::Account.new refresh_token: REFRESH_TOKEN
account.videos.each do |video|
  videos <<= { url: video.id, thumbnail: video.thumbnail_url, title: video.title }
end

sample response/error from the gem:

Yt::Errors::NoItems
({"request_curl":"curl -X GET -H \"content-length: 0\" -H \"user-agent: Yt::Request (gzip)\" -H \"authorization: Bearer AUTH_TOKEN\" -H \"host: www.googleapis.com\" \"https://www.googleapis.com/youtube/v3/videos?id=VIDEO_ID\u0026part=snippet\"","response_body":"{\"kind\":\"youtube#videoListResponse\",\"etag\":\"ETAG\",\"items\":[],\"pageInfo\":{\"totalResults\":0,\"resultsPerPage\":0}}"})

benclum11 avatar Jan 20 '21 18:01 benclum11

I believe this is because the video has been removed from YouTube because of a violation to the terms of service. It's still in the list of videos, but it doesn't have all of the additional information, like title.

bradleygauthier avatar Feb 04 '22 03:02 bradleygauthier

begin
  ...
rescue Yt::Errors::NoItems
end

I think this is a good workaround for your case

kangkyu avatar Jun 20 '22 18:06 kangkyu

@kangkyu this is actually the solution we ended up using, but it doesn't actually solve the problem. we had to actually go in and delete the "broken" video that was causing the error.

For example, if the account has 600 videos, and the 100th video is "broken", then the gem is only able to fetch the first 129 videos, and the rest of the 499 videos won't be able to be fetched.

benclum11 avatar Jun 20 '22 21:06 benclum11

Sorry I missed your comment. It was not possible to skip the broken video, when get information of other videos? Interesting

It sounds like you were able to get only some part of videos even though it skips, but you were able to get all the video information, when you come back after removing the broken video.

kangkyu avatar Oct 29 '22 19:10 kangkyu

Do you still consider it as something the gem can fix?

If it helps, the video's status is VIDEO_STATUS_FAILED and the detailed status is VIDEO_STATUS_DETAIL_FAILED_UNKNOWN. the error message in the creator UI is "Processing abandoned. The video could not be processed."

Even though we know the response for that case (status and error message) we still cannot pull all the videos because of that broken video.. no? We still should remove that video separately. Do you want to see a different error something like Yt::Errors::BrokenVideo? @benclum11

kangkyu avatar Sep 27 '23 05:09 kangkyu