From 52b5c06cb1502630cfefe0224b522e2c62bf7a2b Mon Sep 17 00:00:00 2001 From: Oded Shafran Date: Wed, 17 Aug 2016 15:05:47 +0300 Subject: [PATCH 1/4] adding media_category to video upload --- lib/twitter/rest/tweets.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/twitter/rest/tweets.rb b/lib/twitter/rest/tweets.rb index c96fc52d5..99b9ac920 100644 --- a/lib/twitter/rest/tweets.rb +++ b/lib/twitter/rest/tweets.rb @@ -334,6 +334,7 @@ def upload(media) # rubocop:disable MethodLength, AbcSize init = Twitter::REST::Request.new(self, :post, 'https://upload.twitter.com/1.1/media/upload.json', command: 'INIT', media_type: 'video/mp4', + media_category: 'tweet_video', total_bytes: media.size).perform until media.eof? From ec2d8771df49745d9cd05d7055259ce8220b3515 Mon Sep 17 00:00:00 2001 From: Oded Shafran Date: Wed, 17 Aug 2016 16:00:06 +0300 Subject: [PATCH 2/4] adding status for video --- lib/twitter/rest/tweets.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/twitter/rest/tweets.rb b/lib/twitter/rest/tweets.rb index 99b9ac920..64fc27804 100644 --- a/lib/twitter/rest/tweets.rb +++ b/lib/twitter/rest/tweets.rb @@ -355,6 +355,10 @@ def upload(media) # rubocop:disable MethodLength, AbcSize end end + def upload_status(media_id) + Twitter::REST::Request.new(self, :get, "https://upload.twitter.com/1.1/media/upload.json?command=STATUS&media_id=#{media_id}").perform + end + def array_wrap(object) if object.respond_to?(:to_ary) object.to_ary || [object] From 39a4da3439756d43f571e5e3811829e6a8bbc5a5 Mon Sep 17 00:00:00 2001 From: Oded Shafran Date: Wed, 17 Aug 2016 16:19:55 +0300 Subject: [PATCH 3/4] fixing public status --- lib/twitter/rest/tweets.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/twitter/rest/tweets.rb b/lib/twitter/rest/tweets.rb index 64fc27804..81e876c2d 100644 --- a/lib/twitter/rest/tweets.rb +++ b/lib/twitter/rest/tweets.rb @@ -321,7 +321,11 @@ def unretweet(*args) end.compact end - private + def upload_status(media_id) + Twitter::REST::Request.new(self, :get, "https://upload.twitter.com/1.1/media/upload.json?command=STATUS&media_id=#{media_id}").perform + end + + private # Uploads images and videos. Videos require multiple requests and uploads in chunks of 5 Megabytes. # The only supported video format is mp4. @@ -355,10 +359,6 @@ def upload(media) # rubocop:disable MethodLength, AbcSize end end - def upload_status(media_id) - Twitter::REST::Request.new(self, :get, "https://upload.twitter.com/1.1/media/upload.json?command=STATUS&media_id=#{media_id}").perform - end - def array_wrap(object) if object.respond_to?(:to_ary) object.to_ary || [object] From fe4ff4709fd2dbdc26b589760d1905c3ae821c57 Mon Sep 17 00:00:00 2001 From: Oded Shafran Date: Wed, 17 Aug 2016 16:24:39 +0300 Subject: [PATCH 4/4] fixing identation --- lib/twitter/rest/tweets.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/twitter/rest/tweets.rb b/lib/twitter/rest/tweets.rb index 81e876c2d..379657fca 100644 --- a/lib/twitter/rest/tweets.rb +++ b/lib/twitter/rest/tweets.rb @@ -325,7 +325,7 @@ def upload_status(media_id) Twitter::REST::Request.new(self, :get, "https://upload.twitter.com/1.1/media/upload.json?command=STATUS&media_id=#{media_id}").perform end - private + private # Uploads images and videos. Videos require multiple requests and uploads in chunks of 5 Megabytes. # The only supported video format is mp4.