YouTube v3 renewable data API downloads using Ruby

I am currently using google-api-ruby-client to upload videos to the Youtube API V3, but I cannot find a way to get the Youtube ID that is generated by the resumable download. The code I'm trying to use matches the lines:

media = Google::APIClient::UploadIO.new(file_path, 'application/octet-stream') yt_response = @client.execute!({ :api_method => @youtube.videos.insert, :parameters => { :part => 'snippet,status', 'uploadType' => 'resumable' }, :body_object => file_details, :media => media }) return JSON.parse(yt_response.response.body) 

But unfortunately, for renewable downloads, yt_response.response.body empty. If I change 'uploadType' to 'multipart' then the body will be a JSON block containing the Youtube identifier. Resumable download response is only a renewable session URI for empty-boot downloads. How do I go from this URI to the Youtube ID I just created?

+4
source share
2 answers

Synthesizing information from How to enable resuming download to Google Drive using the Google-api-ruby client? and the existing multi-page loading pattern results in

 videos_insert_response = client.execute!( :api_method => youtube.videos.insert, :body_object => body, :media => Google::APIClient::UploadIO.new(opts[:file], 'video/*'), :parameters => { 'uploadType' => 'resumable', :part => body.keys.join(',') } ) videos_insert_response.resumable_upload.send_all(client) puts "'#{videos_insert_response.data.snippet.title}' (video id: #{videos_insert_response.data.id}) was successfully uploaded." 

It worked for me.

+1
source

I am doing renewable downloads in chunks using API version 0.7.1, and I had to do this to get the identifier ...

 result = videos_insert_response.resumable_upload.send_all(client) video = JSON.parse(result.response.body) puts "Video id '#{video['id']}' was successfully uploaded." 
0
source

Source: https://habr.com/ru/post/1481048/


All Articles