yt 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/HISTORY.md +1 -0
- data/README.md +16 -7
- data/lib/yt/errors/request_error.rb +1 -1
- data/lib/yt/models/video.rb +32 -1
- data/lib/yt/version.rb +1 -1
- data/spec/associations/device_auth/video_spec.rb +26 -1
- data/spec/models/video_spec.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dc19edffeaae2714ad047a40032115520edd738
|
4
|
+
data.tar.gz: 3f71e513ce00e106d65739806406953b4388f0b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08d1aa16ee0d6ddbe7f6b15098cbd72bfcbe9e9901bbcf87d1b6abf15e0d10fc73af313173d149fd6610bb73b4e40ace2536579ccbca618030dc97e76da332d9
|
7
|
+
data.tar.gz: ae6645e795bdb55896d4844e9824ce0e3001a8f4a39210418887bbeaa221cef15ecc4ca4ab2f6e6ac0d21a3fcae4409e9f7a080e3171dc5ecabace67b63c0ea9
|
data/Gemfile.lock
CHANGED
data/HISTORY.md
CHANGED
@@ -8,6 +8,7 @@ v0.7 - 2014/06/18
|
|
8
8
|
* More snippet methods for Playlist (channel_id, channel_title)
|
9
9
|
* More snippet methods for PlaylistItem (channel_id, channel_title, playlist_id, video_id)
|
10
10
|
* More status methods for PlaylistItem (privacy_status, public?, private?, unlisted?)
|
11
|
+
* Add video.update to update title, description, tags and categoryId of a video
|
11
12
|
|
12
13
|
v0.6 - 2014/06/05
|
13
14
|
-----------------
|
data/README.md
CHANGED
@@ -50,7 +50,7 @@ Yt::Account
|
|
50
50
|
Use [Yt::Account](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Models/Account) to:
|
51
51
|
|
52
52
|
* authenticate as a YouTube account
|
53
|
-
* read attributes of the account
|
53
|
+
* read the attributes of the account
|
54
54
|
* access the YouTube channel of the account
|
55
55
|
|
56
56
|
```ruby
|
@@ -86,7 +86,7 @@ Yt::Channel
|
|
86
86
|
|
87
87
|
Use [Yt::Channel](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Models/Channel) to:
|
88
88
|
|
89
|
-
* read attributes of a channel
|
89
|
+
* read the attributes of a channel
|
90
90
|
* access the videos of a channel
|
91
91
|
* access the playlists of a channel
|
92
92
|
* subscribe to and unsubscribe from a channel
|
@@ -150,7 +150,8 @@ Yt::Video
|
|
150
150
|
|
151
151
|
Use [Yt::Video](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Models/Video) to:
|
152
152
|
|
153
|
-
* read attributes of a video
|
153
|
+
* read the attributes of a video
|
154
|
+
* update the attributes of a video
|
154
155
|
* access the annotations of a video
|
155
156
|
* like and dislike a video
|
156
157
|
|
@@ -191,12 +192,19 @@ video.like #=> true
|
|
191
192
|
|
192
193
|
*The methods above require to be authenticated as a YouTube account (see below).*
|
193
194
|
|
195
|
+
```ruby
|
196
|
+
video.update title: 'New title', description: 'New description', tags: ['new tag'], categoryId: '21'
|
197
|
+
```
|
198
|
+
|
199
|
+
*The methods above require to be authenticated as the video’s owner (see below).*
|
200
|
+
|
194
201
|
Yt::Playlist
|
195
202
|
------------
|
196
203
|
|
197
204
|
Use [Yt::Playlist](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Models/Playlist) to:
|
198
205
|
|
199
|
-
* read attributes of a playlist
|
206
|
+
* read the attributes of a playlist
|
207
|
+
* update the attributes of a playlist
|
200
208
|
* access the items of a playlist
|
201
209
|
* add one or multiple videos to a playlist
|
202
210
|
* delete items from a playlist
|
@@ -223,6 +231,7 @@ playlist.playlist_items.first.video.title #=> "Fullscreen Creator Platform"
|
|
223
231
|
*The methods above do not require authentication.*
|
224
232
|
|
225
233
|
```ruby
|
234
|
+
playlist.update title: 'New title', description: 'New description', tags: ['new tag'], privacy_status: 'private'
|
226
235
|
playlist.add_video 'MESycYJytkU'
|
227
236
|
playlist.add_videos ['MESycYJytkU', 'MESycYJytkU']
|
228
237
|
playlist.delete_playlist_items title: 'Fullscreen Creator Platform' #=> [true]
|
@@ -235,7 +244,7 @@ Yt::PlaylistItem
|
|
235
244
|
|
236
245
|
Use [Yt::PlaylistItem](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Models/PlaylistItem) to:
|
237
246
|
|
238
|
-
* read attributes of a playlist item
|
247
|
+
* read the attributes of a playlist item
|
239
248
|
* delete a playlist item
|
240
249
|
|
241
250
|
```ruby
|
@@ -270,7 +279,7 @@ Yt::Annotation
|
|
270
279
|
|
271
280
|
Use [Yt::Annotation](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Models/Annotation) to:
|
272
281
|
|
273
|
-
* read attributes of an annotation
|
282
|
+
* read the attributes of an annotation
|
274
283
|
|
275
284
|
```ruby
|
276
285
|
video = Yt::Video.new id: 'MESycYJytkU'
|
@@ -406,7 +415,7 @@ To install on your system, run
|
|
406
415
|
|
407
416
|
To use inside a bundled Ruby project, add this line to the Gemfile:
|
408
417
|
|
409
|
-
gem 'yt', '~> 0.7.
|
418
|
+
gem 'yt', '~> 0.7.2'
|
410
419
|
|
411
420
|
Since the gem follows [Semantic Versioning](http://semver.org),
|
412
421
|
indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
|
data/lib/yt/models/video.rb
CHANGED
@@ -5,7 +5,7 @@ module Yt
|
|
5
5
|
# Provides methods to interact with YouTube videos.
|
6
6
|
# @see https://developers.google.com/youtube/v3/docs/videos
|
7
7
|
class Video < Resource
|
8
|
-
delegate :tags, :channel_id, :channel_title, :category_id,
|
8
|
+
delegate :tags, :channel_id, :channel_title, :category_id,
|
9
9
|
:live_broadcast_content, to: :snippet
|
10
10
|
|
11
11
|
# @!attribute [r] content_detail
|
@@ -28,6 +28,25 @@ module Yt
|
|
28
28
|
delegate :view_count, :like_count, :dislike_count, :favorite_count,
|
29
29
|
:comment_count, to: :statistics_set
|
30
30
|
|
31
|
+
# @todo Update the status, not just the snippet. This requires some
|
32
|
+
# caution, as the whole status object needs to be updated, not just
|
33
|
+
# privacyStatus, but also embeddable, license, publicStatsViewable,
|
34
|
+
# and publishAt
|
35
|
+
def update(options = {})
|
36
|
+
options[:title] ||= title
|
37
|
+
options[:description] ||= description
|
38
|
+
options[:tags] ||= tags
|
39
|
+
options[:categoryId] ||= category_id
|
40
|
+
snippet = options.slice :title, :description, :tags, :categoryId
|
41
|
+
body = {id: @id, snippet: snippet}
|
42
|
+
|
43
|
+
do_update(params: {part: 'snippet'}, body: body) do |data|
|
44
|
+
@id = data['id']
|
45
|
+
@snippet = Snippet.new data: data['snippet'] if data['snippet']
|
46
|
+
true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
31
50
|
# Returns whether the authenticated account likes the video.
|
32
51
|
#
|
33
52
|
# This method requires {Resource#auth auth} to return an
|
@@ -74,6 +93,18 @@ module Yt
|
|
74
93
|
rating.update :none
|
75
94
|
!liked?
|
76
95
|
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
# @return [Hash] the parameters to submit to YouTube to update a video.
|
100
|
+
# @see https://developers.google.com/youtube/v3/docs/videos/update
|
101
|
+
def update_params
|
102
|
+
super.tap do |params|
|
103
|
+
params[:path] = '/youtube/v3/videos'
|
104
|
+
params[:body_type] = :json
|
105
|
+
params[:expected_response] = Net::HTTPOK
|
106
|
+
end
|
107
|
+
end
|
77
108
|
end
|
78
109
|
end
|
79
110
|
end
|
data/lib/yt/version.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'yt/models/video'
|
3
5
|
|
4
6
|
describe Yt::Video, :device_app do
|
5
7
|
subject(:video) { Yt::Video.new id: id, auth: $account }
|
6
8
|
|
7
|
-
context 'given
|
9
|
+
context 'given someone else’s video' do
|
8
10
|
let(:id) { 'MESycYJytkU' }
|
9
11
|
|
10
12
|
it { expect(video.content_detail).to be_a Yt::ContentDetail }
|
@@ -25,6 +27,7 @@ describe Yt::Video, :device_app do
|
|
25
27
|
it { expect(video.rating).to be_a Yt::Rating }
|
26
28
|
it { expect(video.status).to be_a Yt::Status }
|
27
29
|
it { expect(video.statistics_set).to be_a Yt::StatisticsSet }
|
30
|
+
it { expect{video.update}.to fail }
|
28
31
|
|
29
32
|
context 'that I like' do
|
30
33
|
before { video.like }
|
@@ -54,4 +57,26 @@ describe Yt::Video, :device_app do
|
|
54
57
|
it { expect{video.status}.to raise_error Yt::Errors::NoItems }
|
55
58
|
it { expect{video.statistics_set}.to raise_error Yt::Errors::NoItems }
|
56
59
|
end
|
60
|
+
|
61
|
+
context 'given one of my own videos that I want to update' do
|
62
|
+
let(:id) { $account.videos.first.id }
|
63
|
+
|
64
|
+
describe 'updates the attributes that I specify explicitly' do
|
65
|
+
# NOTE: The use of UTF-8 characters is to test that we can pass up to
|
66
|
+
# 50 characters, independently of their representation
|
67
|
+
let(:attrs) { {title: "Yt Example Update Video #{rand} - ®•♡❥❦❧☙"} }
|
68
|
+
it { expect(video.update attrs).to eq true }
|
69
|
+
it { expect{video.update attrs}.to change{video.title} }
|
70
|
+
end
|
71
|
+
|
72
|
+
describe 'does not update the other attributes' do
|
73
|
+
let(:attrs) { {} }
|
74
|
+
it { expect(video.update attrs).to eq true }
|
75
|
+
it { expect{video.update attrs}.not_to change{video.title} }
|
76
|
+
it { expect{video.update attrs}.not_to change{video.description} }
|
77
|
+
it { expect{video.update attrs}.not_to change{video.tags} }
|
78
|
+
it { expect{video.update attrs}.not_to change{video.category_id} }
|
79
|
+
it { expect{video.update attrs}.not_to change{video.privacy_status} }
|
80
|
+
end
|
81
|
+
end
|
57
82
|
end
|
data/spec/models/video_spec.rb
CHANGED
@@ -10,4 +10,12 @@ describe Yt::Video do
|
|
10
10
|
it { expect(video.snippet).to be_a Yt::Snippet }
|
11
11
|
end
|
12
12
|
end
|
13
|
+
|
14
|
+
describe '#update' do
|
15
|
+
let(:attrs) { {id: 'MESycYJytkU', snippet: {'title'=>'old'}} }
|
16
|
+
before { expect(video).to receive(:do_update).and_yield 'snippet'=>{'title'=>'new'} }
|
17
|
+
|
18
|
+
it { expect(video.update title: 'new').to be true }
|
19
|
+
it { expect{video.update title: 'new'}.to change{video.title} }
|
20
|
+
end
|
13
21
|
end
|