yt 0.12.2 → 0.13.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9333b4d750412a49e64f7f9cb9630b427aa7c2e3
4
- data.tar.gz: 2138e4b1baa893c8655df621e75b6137132385e1
3
+ metadata.gz: 820fa9ccb5406a4e131d08a7ac9a25a49d46bbd1
4
+ data.tar.gz: 4ef554de94ae9f8fcbaf1162cabc4cb2f2e1f5b4
5
5
  SHA512:
6
- metadata.gz: 3f40ff61411c758ecd314b1bf81b1784ef87d90416e0073c7ec58a3cb29434a591d6e3d1a0e8dfc30d67868871991e14976023a43654e183a97f07447b60c1d7
7
- data.tar.gz: bda762260ab03d9b85c373e0a6740b245a37ad2d2c629f747e26ef1030074804e038381e418e3c359c86022628fa24aac5cf931046bb54f2b17c751feb79d4d8
6
+ metadata.gz: 7eef44a502dd74725b4cd9755a89a532ae4352b608c0a92e876370841162b135d7e1031597cf1edd8d60fdf33f399e303b19341b8d57ebf6e3f46a00b51cd085
7
+ data.tar.gz: 7881bc55e5a89efc27125e186d07e03eed78c30ddf745c7937efd7b7bfe5ed41e6f58da0e985ed9fed61957e2a55d00d56f19bc90a04e671857b25ecc462e751
@@ -6,6 +6,20 @@ For more information about changelogs, check
6
6
  [Keep a Changelog](http://keepachangelog.com) and
7
7
  [Vandamme](http://tech-angels.github.io/vandamme).
8
8
 
9
+ ## 0.13.0 - 2014-09-11
10
+
11
+ **How to upgrade**
12
+
13
+ If your code never calls the `create_playlist` on a Channel object, then you
14
+ are good to go.
15
+
16
+ If it does, then replace your calls to `channel.create_playlist` with
17
+ `account.create_playlist`, that is, call `create_playlist` on the channel’s
18
+ account instead.
19
+
20
+ * [ENHANCEMENT] Remove `create_playlist` from Channel (still exists on Account)
21
+ * [ENHANCEMENT] Accept `category_id` in `upload_video`.
22
+
9
23
  ## 0.12.2 - 2014-09-09
10
24
 
11
25
  * [ENHANCEMENT] Accept `part` in the `where` clause of Videos, so statistics and content details can be eagerly loaded.
data/README.md CHANGED
@@ -41,7 +41,7 @@ To install on your system, run
41
41
 
42
42
  To use inside a bundled Ruby project, add this line to the Gemfile:
43
43
 
44
- gem 'yt', '~> 0.12.2'
44
+ gem 'yt', '~> 0.13.0'
45
45
 
46
46
  Since the gem follows [Semantic Versioning](http://semver.org),
47
47
  indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
@@ -60,6 +60,7 @@ Use [Yt::Account](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Models/Acco
60
60
  * read the attributes of the account
61
61
  * access the channel managed by the account
62
62
  * access the videos uploaded by the account
63
+ * create playlist
63
64
  * upload a video
64
65
  * list the channels subscribed to an account
65
66
 
@@ -73,9 +74,11 @@ account.channel #=> #<Yt::Models::Channel @id=...>
73
74
  account.videos.count #=> 12
74
75
  account.videos.first #=> #<Yt::Models::Video @id=...>
75
76
 
76
- account.upload_video 'my_video.mp4', title: 'My new video', privacy_status: 'private'
77
+ account.upload_video 'my_video.mp4', title: 'My new video', privacy_status: 'private', category_id: 17
77
78
  account.upload_video 'http://example.com/remote.m4v', title: 'My other video', tags: ['music']
78
79
 
80
+ account.create_playlist title: 'New playlist', privacy_status: 'unlisted' #=> true
81
+
79
82
  account.subscribers.count #=> 2
80
83
  account.subscribers.first #=> #<Yt::Models::Channel @id=...>
81
84
  account.subscribers.first.title #=> 'Fullscreen'
@@ -141,7 +144,7 @@ Use [Yt::Channel](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Models/Chan
141
144
  * access the playlists of a channel
142
145
  * access the channels that the channel is subscribed to
143
146
  * subscribe to and unsubscribe from a channel
144
- * create and delete playlists from a channel
147
+ * delete playlists from a channel
145
148
  * retrieve the daily earnings, views, comments, likes, dislikes, shares and impressions of a channel
146
149
  * retrieve the viewer percentage of a channel by gender and age group
147
150
 
@@ -188,7 +191,6 @@ channel.subscribe #=> true
188
191
  account = Yt::Account.new access_token: 'ya29.1.ABCDEFGHIJ'
189
192
  channel = Yt::Channel.new id: 'UCxO1tY8h1AhOz0T4ENwmpow', auth: account
190
193
 
191
- channel.create_playlist title: 'New playlist' #=> true
192
194
  channel.delete_playlists title: 'New playlist' #=> [true]
193
195
 
194
196
  channel.views since: 7.days.ago #=> {Wed, 28 May 2014 => 12.0, Thu, 29 May 2014 => 3.0, …}
@@ -688,8 +690,10 @@ Why you should use Yt…
688
690
  ======================
689
691
 
690
692
  … and not [youtube_it](https://github.com/kylejginavan/youtube_it)?
691
- Because youtube_it does not support Google API V3 and the previous version
692
- has already been deprecated by Google and will soon be dropped.
693
+ Because youtube_it does not support YouTube API V3, and the YouTube API V2 has
694
+ been [officially deprecated as of March 4, 2014](https://developers.google.com/youtube/2.0/developers_guide_protocol_audience).
695
+ If you need help upgrading your code, check [YOUTUBE_IT.md](https://github.com/Fullscreen/yt/blob/master/YOUTUBE_IT.md),
696
+ a step-by-step comparison between youtube_it and Yt to make upgrade easier.
693
697
 
694
698
  … and not [Google Api Client](https://github.com/google/google-api-ruby-client)?
695
699
  Because Google Api Client is poorly coded, poorly documented and adds many
@@ -0,0 +1,867 @@
1
+ How to migrate from youtube_it
2
+ ==============================
3
+
4
+ If you are used to access the YouTube API with [youtube_it](https://github.com/kylejginavan/youtube_it),
5
+ this guide will help you translate your code to use Yt instead.
6
+
7
+ This guide follows [youtube_it README.rdoc](https://github.com/kylejginavan/youtube_it/blob/f61ed0b00905e048dcbed12457d02f52ddbae45d/README.rdoc)
8
+ listing the original `youtube_it` commands and their equivalent `Yt` versions.
9
+
10
+ Establishing a client
11
+ ---------------------
12
+
13
+ While `youtube_it` supports authentication with developer key, AuthSub and
14
+ OAuth, `Yt` only supports OAuth 2.0, because this is the only process that has
15
+ not been deprecated by YouTube Data API V3.
16
+
17
+ Another difference is that `youtube_it` authentication methods are invoked on
18
+ a generic `Client` class, while with `Yt` you can specify whether you want to
19
+ authenticate as a YouTube `Account` or as a `ContentOwner`.
20
+ Content owners are special [CMS accounts](https://cms.youtube.com) that can
21
+ manage multiple YouTube accounts at once.
22
+
23
+ Creating a client:
24
+
25
+ ```ruby
26
+ # with youtube_it
27
+ client = YouTubeIt::Client.new
28
+ # with yt
29
+ account = Yt::Account.new # or Yt::ContentOwner.new
30
+ ```
31
+
32
+ Client with developer key:
33
+
34
+ ```ruby
35
+ # with youtube_it
36
+ client = YouTubeIt::Client.new(:dev_key => "developer_key")
37
+ # with yt: not supported (must use OAuth 2.0)
38
+ ```
39
+
40
+ Client with youtube account and developer key:
41
+
42
+ ```ruby
43
+ # with youtube_it
44
+ client = YouTubeIt::Client.new(:username => "youtube_username", :password => "youtube_passwd", :dev_key => "developer_key")
45
+ # with yt: not supported (must use OAuth 2.0)
46
+ ```
47
+
48
+ Client with AuthSub:
49
+
50
+ ```ruby
51
+ # with youtube_it
52
+ client = YouTubeIt::AuthSubClient.new(:token => "token" , :dev_key => "developer_key")
53
+ # with yt: not supported (must use OAuth 2.0)
54
+ ```
55
+
56
+ Client with OAuth:
57
+
58
+ ```ruby
59
+ # with youtube_it
60
+ client = YouTubeIt::OAuthClient.new("consumer_key", "consumer_secret", "youtube_username", "developer_key")
61
+ client.authorize_from_access("access_token", "access_secret")
62
+ # with yt: not supported (must use OAuth 2.0)
63
+ ```
64
+
65
+ Client with OAuth2:
66
+
67
+ ```ruby
68
+ # with youtube_it
69
+ client = YouTubeIt::OAuth2Client.new(client_access_token: "access_token", client_refresh_token: "refresh_token", client_id: "client_id", client_secret: "client_secret", dev_key: "dev_key", expires_at: "expiration time")
70
+ client.refresh_access_token!
71
+ # with yt
72
+ Yt.configure do |config|
73
+ config.client_id = 'client_id'
74
+ config.client_secret = 'client_secret'
75
+ end
76
+ account = Yt::Account.new access_token: 'access_token', refresh_token: 'refresh_token'
77
+ ```
78
+
79
+ Profiles
80
+ --------
81
+
82
+ With `youtube_it`, you can use multiple profiles in the same account:
83
+
84
+ ```ruby
85
+ profiles = client.profiles(['username1','username2'])
86
+ profiles['username1'].username, "username1"
87
+ ```
88
+
89
+ With `yt`, you can access all the channels managed by the same YouTube account:
90
+
91
+ ```ruby
92
+ first_channel = Yt::Channel.new id: 'UCx12345', auth: account
93
+ second_channel = Yt::Channel.new id: 'UCy45678', auth: account
94
+ first_channel.title
95
+ ```
96
+
97
+ Video queries
98
+ -------------
99
+
100
+ List videos by keyword:
101
+
102
+ ```ruby
103
+ # with youtube_it
104
+ client = YouTubeIt::Client.new
105
+ client.videos_by(:query => "penguin")
106
+ # with yt
107
+ videos = Yt::Collections::Videos.new
108
+ videos.where(q: 'penguin')
109
+ ```
110
+
111
+ List videos by page:
112
+
113
+ ```ruby
114
+ # with youtube_it
115
+ client = YouTubeIt::Client.new
116
+ client.videos_by(:query => "penguin", :page => 2, :per_page => 15)
117
+ # with yt: pagination is automatically supported by collection, which iterates
118
+ # though all the pages, not just the first one
119
+ videos = Yt::Collections::Videos.new
120
+ videos.where(q: 'penguin')
121
+ ```
122
+
123
+ List videos by region:
124
+
125
+ ```ruby
126
+ # with youtube_it
127
+ client = YouTubeIt::Client.new
128
+ client.videos_by(:query => "penguin", :restriction => "DE")
129
+ # with yt
130
+ # Note that some users report that regionCode does not work in YouTube API V3
131
+ # See https://code.google.com/p/gdata-issues/issues/detail?id=4110
132
+ videos = Yt::Collections::Videos.new
133
+ videos.where(q: 'penguin', region_code: 'DE')
134
+ ```
135
+
136
+ List videos by author:
137
+
138
+ ```ruby
139
+ # with youtube_it
140
+ client = YouTubeIt::Client.new
141
+ client.videos_by(:query => "penguin", :author => "liz")
142
+ # with yt: the 'author' filter was removed from YouTube API V3, so the
143
+ # request must be done using the channel of the requested author
144
+ channel = Yt::Channel.new url: 'youtube.com/liz'
145
+ channel.videos.where(q: 'penguin')
146
+ ```
147
+
148
+ List videos by categories:
149
+
150
+ ```ruby
151
+ # with youtube_it
152
+ client = YouTubeIt::Client.new
153
+ client.videos_by(:categories => [:news, :sports])
154
+ # with yt: the 'categories' filter was removed from YouTube API V3, so the
155
+ # request must be done using one category_id at the time
156
+ videos = Yt::Collections::Videos.new
157
+ videos.where(video_category_id: 25) #=> News
158
+ videos.where(video_category_id: 17) #=> Sports
159
+ ```
160
+
161
+ List videos by tags:
162
+
163
+ ```ruby
164
+ # with youtube_it
165
+ client = YouTubeIt::Client.new
166
+ client.videos_by(:tags => ['tiger', 'leopard'])
167
+ client.videos_by(:categories => [:news, :sports], :tags => ['soccer', 'football'])
168
+ # with yt: not supported (was removed from YouTube API V3)
169
+ ```
170
+
171
+ List videos by user:
172
+
173
+ ```ruby
174
+ # with youtube_it
175
+ client = YouTubeIt::Client.new
176
+ client.videos_by(:user => 'liz')
177
+ # with yt: the 'author' filter was removed from YouTube API V3, so the
178
+ # request must be done using the channel of the requested author
179
+ channel = Yt::Channel.new url: 'youtube.com/liz'
180
+ channel.videos.where(q: 'penguin')
181
+ ```
182
+
183
+ <!--
184
+
185
+ TODO: Although FAVORITE is somehow deprecated, it can still be retrieved with
186
+ V3. First, get the contentDetails of the account's channel and you'll get
187
+
188
+ {"relatedPlaylists"=>
189
+ {"likes"=>"LLrWYT-_Xncr1BLPfPNr50sQ",
190
+ "favorites"=>"FLrWYT-_Xncr1BLPfPNr50sQ",
191
+ "uploads"=>"UUrWYT-_Xncr1BLPfPNr50sQ",
192
+ "watchHistory"=>"HLrWYT-_Xncr1BLPfPNr50sQ",
193
+ "watchLater"=>"WLrWYT-_Xncr1BLPfPNr50sQ"},
194
+
195
+ Then you can list the videos of the "favorites" playlist. That playlist does
196
+ not exist for new YouTube account, but you can still add a video to it, and
197
+ it will magically appear (and also, DELETE PLAYLIST will be disabled)
198
+
199
+ List videos favorited by user:
200
+
201
+ ```ruby
202
+ # with youtube_it
203
+ client = YouTubeIt::Client.new
204
+ client.videos_by(:favorites, :user => 'liz')
205
+ # with yt: not supported (was removed from YouTube API V3)
206
+
207
+ or maybe add .liked_videos and .disliked_videos here !!!!!
208
+
209
+ ```
210
+
211
+
212
+
213
+ -->
214
+
215
+ Retrieve video by ID:
216
+
217
+ ```ruby
218
+ # with youtube_it
219
+ client = YouTubeIt::Client.new
220
+ client.video_by("FQK1URcxmb4")
221
+ # with yt
222
+ Yt::Video.new id: 'FQK1URcxmb4'
223
+ ```
224
+
225
+ Retrieve video by URL:
226
+
227
+ ```ruby
228
+ # with youtube_it
229
+ client = YouTubeIt::Client.new
230
+ client.video_by("https://www.youtube.com/watch?v=QsbmrCtiEUU")
231
+ # with yt
232
+ Yt::Video.new url: 'https://www.youtube.com/watch?v=QsbmrCtiEUU'
233
+ ```
234
+
235
+ Retrieve video of a user by ID:
236
+
237
+ ```ruby
238
+ # with youtube_it
239
+ client = YouTubeIt::Client.new
240
+ client.video_by_user("chebyte","FQK1URcxmb4")
241
+ # with yt
242
+ Yt::Video.new id: 'FQK1URcxmb4'
243
+ ```
244
+
245
+ List most viewed videos:
246
+
247
+ ```ruby
248
+ # with youtube_it
249
+ client = YouTubeIt::Client.new
250
+ client.videos_by(:most_viewed)
251
+ # with yt
252
+ videos = Yt::Collections::Videos.new
253
+ videos.where(order: 'viewCount')
254
+ ```
255
+
256
+ List most linked videos:
257
+
258
+ ```ruby
259
+ # with youtube_it
260
+ client = YouTubeIt::Client.new
261
+ client.videos_by(:most_linked, :page => 3)
262
+ # with yt: not supported (was removed from YouTube API V3)
263
+ ```
264
+
265
+ List most popular video:
266
+
267
+ ```ruby
268
+ # with youtube_it
269
+ client = YouTubeIt::Client.new
270
+ client.videos_by(:top_rated, :time => :today).first
271
+ # with yt
272
+ videos = Yt::Collections::Videos.new
273
+ videos.where(chart: 'mostPopular').first
274
+ ```
275
+
276
+ List *all* most popular videos:
277
+
278
+ ```ruby
279
+ # with youtube_it
280
+ client = YouTubeIt::Client.new
281
+ client.videos_by(:top_rated, :time => :today)
282
+ # with yt: YouTube API V3 only returns the top 50
283
+ videos = Yt::Collections::Videos.new
284
+ videos.where(chart: 'mostPopular')
285
+ ```
286
+
287
+ List most popular video by region and category:
288
+
289
+ ```ruby
290
+ # with youtube_it
291
+ client = YouTubeIt::Client.new
292
+ client.videos_by(:top_rated, :region => "RU", :category => "News").first
293
+ # with yt
294
+ videos = Yt::Collections::Videos.new
295
+ videos.where(chart: 'mostPopular', region_code: 'RU', video_category_id: 25).first
296
+ ```
297
+
298
+ Advanced Queries (with boolean operators OR (either), AND (include), NOT (exclude)):
299
+
300
+ ```ruby
301
+ # with youtube_it
302
+ client = YouTubeIt::Client.new
303
+ client.videos_by(:categories => { :either => [:news, :sports], :exclude => [:comedy] }, :tags => { :include => ['football'], :exclude => ['soccer'] })
304
+ # with yt: not supported (was removed from YouTube API V3)
305
+ ```
306
+
307
+ Custom Query Params:
308
+
309
+ ```ruby
310
+ # with youtube_it
311
+ client = YouTubeIt::Client.new
312
+ client.videos_by(:query => "penguin", :safe_search => "strict")
313
+ client.videos_by(:query => "penguin", :duration => "long")
314
+ client.videos_by(:query => "penguin", :hd => "true")
315
+ client.videos_by(:query => "penguin", :region => "AR")
316
+ # with yt
317
+ videos = Yt::Collections::Videos.new
318
+ videos.where(q: 'penguin', safe_search: 'strict')
319
+ videos.where(q: 'penguin', duration: 'long')
320
+ videos.where(q: 'penguin', video_definition: 'high')
321
+ videos.where(q: 'penguin', region_code: 'AR')
322
+ ```
323
+
324
+ Return videos with more than 1,000 views:
325
+
326
+ ```ruby
327
+ # with youtube_it
328
+ client = YouTubeIt::Client.new
329
+ client.videos_by(:fields => {:view_count => "1000"})
330
+ # with yt: the most similar method in YouTube API V3 is to return the results by view count
331
+ videos = Yt::Collections::Videos.new
332
+ videos.where(order: 'viewCount')
333
+ ```
334
+
335
+ Filter by date (also with range):
336
+
337
+ ```ruby
338
+ # with youtube_it
339
+ client = YouTubeIt::Client.new
340
+ client.videos_by(:fields => {:published => (Date.today)})
341
+ client.videos_by(:fields => {:recorded => (Date.today)})
342
+ client.videos_by(:fields => {:published => ((Date.today - 30)..(Date.today))})
343
+ client.videos_by(:fields => {:recorded => ((Date.today - 30)..(Date.today))})
344
+ # with yt (only published is available in YouTube API V3, not recorded date)
345
+ videos = Yt::Collections::Videos.new
346
+ videos.where(published_before: 0.days.ago.utc.iso8601(0), published_after: 30.day.ago.utc.iso8601(0))
347
+ ```
348
+
349
+ Filter including private videos:
350
+
351
+ ```ruby
352
+ # with youtube_it
353
+ client = # new client initialized with either OAuth or AuthSub
354
+ client.my_video("FQK1URcxmb4")
355
+ client.my_videos(:query => "penguin")
356
+ # with yt
357
+ account = Yt::Account.new access_token: 'access_token'
358
+ video = Yt::Video.new id: 'FQK1URcxmb4', auth: account
359
+ account.videos.where(q: 'penguin')
360
+ ```
361
+
362
+ Video management
363
+ ----------------
364
+
365
+ Upload video:
366
+
367
+ ```ruby
368
+ # with youtube_it
369
+ client = # new client initialized with either OAuth or AuthSub
370
+ client.video_upload(File.open("test.mov"), :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test])
371
+ # with yt
372
+ account = Yt::Account.new access_token: 'access_token'
373
+ account.upload_video 'test.mov', title: 'test', description: 'some description', category_id: 22, tags: %w(cool blah test)
374
+ ```
375
+
376
+ Upload remote video:
377
+
378
+ ```ruby
379
+ # with youtube_it
380
+ client = # new client initialized with either OAuth or AuthSub
381
+ client.video_upload("http://url/myvideo.mp4", :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test])
382
+ # with yt
383
+ account = Yt::Account.new access_token: 'access_token'
384
+ account.upload_video 'http://url/myvideo.mp4', title: 'test', description: 'some description', category_id: 22, tags: %w(cool blah test)
385
+ ```
386
+
387
+ Upload video with a developer tag:
388
+
389
+ ```ruby
390
+ # with youtube_it
391
+ client = # new client initialized with either OAuth or AuthSub
392
+ client.video_upload(File.open("test.mov"), :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test], :dev_tag => 'tagdev')
393
+ # with yt: not supported (was removed from YouTube API V3)
394
+ ```
395
+
396
+ Upload video from URL:
397
+
398
+ ```ruby
399
+ # with youtube_it
400
+ client = # new client initialized with either OAuth or AuthSub
401
+ client.video_upload("http://media.railscasts.com/assets/episodes/videos/412-fast-rails-commands.mp4", :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test])
402
+ # with yt
403
+ account = Yt::Account.new access_token: 'access_token'
404
+ account.upload_video 'http://media.railscasts.com/assets/episodes/videos/412-fast-rails-commands.mp4', title: 'test', description: 'some description', category_id: 22, tags: %w(cool blah test)
405
+ ```
406
+
407
+ Upload private video:
408
+
409
+ ```ruby
410
+ # with youtube_it
411
+ client = # new client initialized with either OAuth or AuthSub
412
+ client.video_upload(File.open("test.mov"), :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test], :private => true)
413
+ # with yt
414
+ account = Yt::Account.new access_token: 'access_token'
415
+ account.upload_video 'test.mov', privacy_status: :private, title: 'test', description: 'some description', category_id: 22, tags: %w(cool blah test)
416
+ ```
417
+
418
+ Update video:
419
+
420
+ ```ruby
421
+ # with youtube_it
422
+ client = # new client initialized with either OAuth or AuthSub
423
+ client.video_update("FQK1URcxmb4", :title => "new test",:description => 'new description', :category => 'People',:keywords => %w[cool blah test])
424
+ # with yt: only provides the values that need to be updated; the remaining ones
425
+ # will automatically be kept as they are
426
+ account = Yt::Account.new access_token: 'access_token'
427
+ video = Yt::Video.new id: 'FQK1URcxmb4', auth: account
428
+ video.update title: 'new test', description: 'new description'
429
+ ```
430
+
431
+ Delete video:
432
+
433
+ ```ruby
434
+ # with youtube_it
435
+ client = # new client initialized with either OAuth or AuthSub
436
+ client.video_delete("FQK1URcxmb4")
437
+ # with yt
438
+ account = Yt::Account.new access_token: 'access_token'
439
+ video = Yt::Video.new id: 'FQK1URcxmb4'
440
+ video.delete
441
+ ```
442
+
443
+ My videos:
444
+
445
+ ```ruby
446
+ # with youtube_it
447
+ client = # new client initialized with either OAuth or AuthSub
448
+ client.my_videos
449
+ # with yt
450
+ account = Yt::Account.new access_token: 'access_token'
451
+ account.videos
452
+ ```
453
+
454
+ My video:
455
+
456
+ ```ruby
457
+ # with youtube_it
458
+ client = # new client initialized with either OAuth or AuthSub
459
+ client.my_video(video_id)
460
+ # with yt
461
+ account = Yt::Account.new access_token: 'access_token'
462
+ Yt::Video.new id: video_id, auth: account
463
+ ```
464
+
465
+ Profile details:
466
+
467
+ ```ruby
468
+ # with youtube_it
469
+ client = # new client initialized with either OAuth or AuthSub
470
+ client.profile(user)
471
+ # with yt
472
+ account = Yt::Account.new access_token: 'access_token'
473
+ account.user_info
474
+ ```
475
+
476
+ List comments:
477
+
478
+ ```ruby
479
+ # with youtube_it
480
+ client = YouTubeIt::Client.new
481
+ client.comments(video_id)
482
+ # with yt: not supported (was removed from YouTube API V3)
483
+ ```
484
+
485
+ Add a comment:
486
+
487
+ ```ruby
488
+ # with youtube_it
489
+ client = # new client initialized with either OAuth or AuthSub
490
+ client.add_comment(video_id, "test comment!")
491
+ # with yt: not supported (was removed from YouTube API V3)
492
+ ```
493
+
494
+ Add a reply comment:
495
+
496
+ ```ruby
497
+ # with youtube_it
498
+ client = # new client initialized with either OAuth or AuthSub
499
+ client.add_comment(video_id, "test reply!", :reply_to => another_comment)
500
+ # with yt: not supported (was removed from YouTube API V3)
501
+ ```
502
+
503
+ Delete a comment:
504
+
505
+ ```ruby
506
+ # with youtube_it
507
+ client = # new client initialized with either OAuth or AuthSub
508
+ client.delete_comment(video_id, comment_id)
509
+ # with yt: not supported (was removed from YouTube API V3)
510
+ ```
511
+
512
+ <!--
513
+ List Favorites:
514
+
515
+
516
+ TODO: Although FAVORITE is somehow deprecated, it can still be retrieved with
517
+ V3. First, get the contentDetails of the account's channel and you'll get
518
+
519
+ {"relatedPlaylists"=>
520
+ {"likes"=>"LLrWYT-_Xncr1BLPfPNr50sQ",
521
+ "favorites"=>"FLrWYT-_Xncr1BLPfPNr50sQ",
522
+ "uploads"=>"UUrWYT-_Xncr1BLPfPNr50sQ",
523
+ "watchHistory"=>"HLrWYT-_Xncr1BLPfPNr50sQ",
524
+ "watchLater"=>"WLrWYT-_Xncr1BLPfPNr50sQ"},
525
+
526
+ Then you can list the videos of the "favorites" playlist. That playlist does
527
+ not exist for new YouTube account, but you can still add a video to it, and
528
+ it will magically appear (and also, DELETE PLAYLIST will be disabled)
529
+
530
+
531
+ ```ruby
532
+ # with youtube_it
533
+ client = # new client initialized with either OAuth or AuthSub
534
+ client.favorites(user) # default: current user
535
+ # with yt
536
+
537
+ # TODO: ADD account.liked_videos and .disliked_videos
538
+ ```
539
+
540
+ Add Favorite:
541
+
542
+ ```ruby
543
+ # with youtube_it
544
+ client = # new client initialized with either OAuth or AuthSub
545
+ client.add_favorite(video_id)
546
+ # with yt: "like" a video to mark as favorite with YouTube API V3
547
+ account = Yt::Account.new access_token: 'access_token'
548
+ video = Yt::Video.new id: video_id, auth: account
549
+ video.like
550
+ ```
551
+
552
+ Delete Favorite:
553
+
554
+ ```ruby
555
+ # with youtube_it
556
+ client = # new client initialized with either OAuth or AuthSub
557
+ client.delete_favorite(favorite_entry_id)
558
+ # with yt: "unlike" a video to remove from favorites with YouTube API V3
559
+ account = Yt::Account.new access_token: 'access_token'
560
+ video = Yt::Video.new id: video_id, auth: account
561
+ video.unlike
562
+ ```
563
+
564
+ -->
565
+
566
+ Like a video:
567
+
568
+ ```ruby
569
+ # with youtube_it
570
+ client = # new client initialized with either OAuth or AuthSub
571
+ client.like_video(video_id)
572
+ # with yt
573
+ account = Yt::Account.new access_token: 'access_token'
574
+ video = Yt::Video.new id: video_id, auth: account
575
+ video.like
576
+ ```
577
+
578
+ Dislike a video:
579
+
580
+ ```ruby
581
+ # with youtube_it
582
+ client = # new client initialized with either OAuth or AuthSub
583
+ client.dislike_video(video_id)
584
+ # with yt
585
+ account = Yt::Account.new access_token: 'access_token'
586
+ video = Yt::Video.new id: video_id, auth: account
587
+ video.dislike
588
+ ```
589
+
590
+ List Subscriptions (channels an account is subscribed to):
591
+
592
+ ```ruby
593
+ # with youtube_it
594
+ client = # new client initialized with either OAuth or AuthSub
595
+ client.subscriptions(user) # default: current user
596
+ # with yt
597
+ account = Yt::Account.new access_token: 'access_token'
598
+ account.subscribed_channels
599
+ ```
600
+
601
+ Subscribe to a channel:
602
+
603
+ ```ruby
604
+ # with youtube_it
605
+ client = # new client initialized with either OAuth or AuthSub
606
+ client.subscribe_channel(channel_name)
607
+ # with yt
608
+ account = Yt::Account.new access_token: 'access_token'
609
+ channel = Yt::Channel.new id: channel_id, auth: account
610
+ channel.subscribe
611
+ ```
612
+
613
+ Unsubscribe from a channel:
614
+
615
+ ```ruby
616
+ # with youtube_it
617
+ client = # new client initialized with either OAuth or AuthSub
618
+ client.unsubscribe_channel(subscription_id)
619
+ # with yt
620
+ account = Yt::Account.new access_token: 'access_token'
621
+ channel = Yt::Channel.new id: channel_id, auth: account
622
+ channel.unsubscribe
623
+ ```
624
+
625
+ List New Subscription Videos:
626
+
627
+
628
+ ```ruby
629
+ # with youtube_it
630
+ client = # new client initialized with either OAuth or AuthSub
631
+ client.new_subscription_videos(user) # default: current user
632
+ # with yt: not supported (was removed from YouTube API V3)
633
+ ```
634
+
635
+ List Playlists:
636
+
637
+ ```ruby
638
+ # with youtube_it
639
+ client = # new client initialized with either OAuth or AuthSub
640
+ client.playlists(user) # default order, by position
641
+ client.playlists(user, "title") # order by title
642
+ # with yt: available without order; ordering was removed from YouTube API V3
643
+ account = Yt::Account.new access_token: 'access_token'
644
+ account.playlists
645
+ ```
646
+
647
+ Select Playlist:
648
+
649
+ ```ruby
650
+ # with youtube_it
651
+ client.playlist(playlist_id)
652
+ # with yt
653
+ Yt::Playlist.new id: playlist_id
654
+ ```
655
+
656
+ Select All Videos From A Playlist:
657
+
658
+ ```ruby
659
+ # with youtube_it
660
+ playlist = client.playlist(playlist_id)
661
+ playlist.videos
662
+ # with yt
663
+ playlist = Yt::Playlist.new id: playlist_id
664
+ playlist.playlist_items.map &:video
665
+ ```
666
+
667
+ Create Playlist:
668
+
669
+ ```ruby
670
+ # with youtube_it
671
+ client = # new client initialized with either OAuth or AuthSub
672
+ playlist = client.add_playlist(:title => "new playlist", :description => "playlist description")
673
+ # with yt
674
+ account = Yt::Account.new access_token: 'access_token'
675
+ account.create_playlist title: 'new playlist', description: 'playlist description'
676
+ ```
677
+
678
+ Delete Playlist:
679
+
680
+ ```ruby
681
+ # with youtube_it
682
+ client = # new client initialized with either OAuth or AuthSub
683
+ client.delete_playlist(playlist_id)
684
+ # with yt
685
+ account = Yt::Account.new access_token: 'access_token'
686
+ playlist = Yt::Playlist.new id: playlist_id, auth: account
687
+ playlist.delete
688
+ ```
689
+
690
+ Add Video To Playlist:
691
+
692
+ ```ruby
693
+ # with youtube_it
694
+ client = # new client initialized with either OAuth or AuthSub
695
+ client.add_video_to_playlist(playlist_id, video_id, position)
696
+ # with yt
697
+ account = Yt::Account.new access_token: 'access_token'
698
+ playlist = Yt::Playlist.new id: playlist_id, auth: account
699
+ playlist.add_video video_id, position: position
700
+ ```
701
+
702
+ Remove Video From Playlist:
703
+
704
+ ```ruby
705
+ # with youtube_it
706
+ client = # new client initialized with either OAuth or AuthSub
707
+ client.delete_video_from_playlist(playlist_id, playlist_entry_id)
708
+ # with yt
709
+ account = Yt::Account.new access_token: 'access_token'
710
+ playlist_item = Yt::PlaylistItem.new id: playlist_entry_id, auth: account
711
+ playlist_item.delete
712
+ ```
713
+
714
+ Update Position Video From Playlist:
715
+
716
+ ```ruby
717
+ # with youtube_it
718
+ client = # new client initialized with either OAuth or AuthSub
719
+ client.update_position_video_from_playlist(playlist_id, playlist_entry_id, position)
720
+ # with yt
721
+ account = Yt::Account.new access_token: 'access_token'
722
+ playlist_item = Yt::PlaylistItem.new id: playlist_entry_id, auth: account
723
+ playlist_item.update position: position
724
+ ```
725
+
726
+ <!--
727
+
728
+
729
+ TODO: Although WATCHLATER is somehow deprecated, it can still be retrieved with
730
+ V3. First, get the contentDetails of the account's channel and you'll get
731
+
732
+ {"relatedPlaylists"=>
733
+ {"likes"=>"LLrWYT-_Xncr1BLPfPNr50sQ",
734
+ "favorites"=>"FLrWYT-_Xncr1BLPfPNr50sQ",
735
+ "uploads"=>"UUrWYT-_Xncr1BLPfPNr50sQ",
736
+ "watchHistory"=>"HLrWYT-_Xncr1BLPfPNr50sQ",
737
+ "watchLater"=>"WLrWYT-_Xncr1BLPfPNr50sQ"},
738
+
739
+ Then you can list the videos of the "watch later" playlist. That playlist does
740
+ not exist for new YouTube account, but you can still add a video to it, and
741
+ it will magically appear (and also, DELETE PLAYLIST will be disabled)
742
+
743
+
744
+ Select All Videos From your Watch Later Playlist:
745
+ $ watcher_later = client.watcherlater(user) #default: current user
746
+ $ watcher_later.videos
747
+
748
+ Add Video To Watcher Later Playlist:
749
+ $ client.add_video_to_watchlater(video_id)
750
+
751
+ Remove Video From Watch Later Playlist:
752
+ $ client.delete_video_from_watchlater(watchlater_entry_id)
753
+
754
+ -->
755
+
756
+
757
+ <!-- TODO: Add using https://developers.google.com/youtube/v3/docs/search/list#relatedToVideoId
758
+
759
+ List Related Videos:
760
+
761
+ ```ruby
762
+ # with youtube_it
763
+ client = # new client initialized with either OAuth or AuthSub
764
+ video = client.video_by("https://www.youtube.com/watch?v=QsbmrCtiEUU&feature=player_embedded")
765
+ video.related.videos
766
+ # with yt:
767
+ ```
768
+
769
+ -->
770
+
771
+ Add Response Video:
772
+
773
+ ```ruby
774
+ # with youtube_it
775
+ client = # new client initialized with either OAuth or AuthSub
776
+ video.add_response(original_video_id, response_video_id)
777
+ # with yt: not supported (was removed from YouTube API V3)
778
+ ```
779
+
780
+ Delete Response Video:
781
+
782
+ ```ruby
783
+ # with youtube_it
784
+ client = # new client initialized with either OAuth or AuthSub
785
+ video.delete_response(original_video_id, response_video_id)
786
+ # with yt: not supported (was removed from YouTube API V3)
787
+ ```
788
+
789
+ List Response Videos:
790
+
791
+ ```ruby
792
+ # with youtube_it
793
+ client = # new client initialized with either OAuth or AuthSub
794
+ video = client.video_by("https://www.youtube.com/watch?v=QsbmrCtiEUU&feature=player_embedded")
795
+ video.responses.videos
796
+ # with yt: not supported (was removed from YouTube API V3)
797
+ ```
798
+
799
+ Batch videos (list multiple videos):
800
+
801
+ ```ruby
802
+ # with youtube_it
803
+ client = # new client initialized with either OAuth or AuthSub
804
+ client.videos(['video_id_1', 'video_id_2',...])
805
+ # with yt
806
+ Yt::Collections::Videos.new.where(id: 'video_id_1,video_id_2')
807
+ ```
808
+
809
+ Access control list
810
+ -------------------
811
+
812
+ While `youtube_it` allows users to give and revoke permissions to rate, comment,
813
+ respond, list, embed and syndicate uploaded videos, `Yt` does not.
814
+
815
+ The reason is that most of these permissions have been deprecated in YouTube
816
+ Data API V3. The only parameter that can still be passed when updating a
817
+ video is 'embeddable'; however many users have reported that updating this
818
+ setting through the API simply does not work.
819
+ See https://code.google.com/p/gdata-issues/issues/detail?id=4861
820
+
821
+ Block users from commenting on a video:
822
+
823
+ ```ruby
824
+ # with youtube_it
825
+ client = YouTubeIt::Client.new(:username => "youtube_username", :password => "youtube_passwd", :dev_key => "developer_key")
826
+ client.video_upload(File.open("test.mov"), :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test], :comment => "denied")
827
+ # with yt: not supported (was removed from YouTube API V3; only the embeddable setting can be specified)
828
+ ```
829
+
830
+ Block users from embedding a video:
831
+
832
+ ```ruby
833
+ # with youtube_it
834
+ client = YouTubeIt::Client.new(:username => "youtube_username", :password => "youtube_passwd", :dev_key => "developer_key")
835
+ client.video_upload(File.open("test.mov"), :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test], :embed => "denied")
836
+ # with yt: not supported (it is documented in YouTube API V3 but looks like it is not working)
837
+ ```
838
+
839
+ Partial updates
840
+ ---------------
841
+
842
+ While `youtube_it` uses a separate method to specify that an UPDATE request
843
+ should not modify any field that has not been explicitly specified, `Yt`
844
+ applies this behavior by default
845
+
846
+ Change the title of a video, but not its privacy status or its description:
847
+
848
+ ```ruby
849
+ # with youtube_it
850
+ client = # new client initialized with either OAuth or AuthSub
851
+ client.video_partial_update(video_id, :title => 'new title')
852
+ # with yt
853
+ account = Yt::Account.new access_token: 'access_token'
854
+ video = Yt::Video.new id: video_id, auth: account
855
+ video.update title: 'new title'
856
+ ```
857
+
858
+ <!--
859
+
860
+ TODO
861
+
862
+ == User Activity
863
+ You can get user activity with the followings params:
864
+
865
+ $ client.activity(user) #default current user
866
+
867
+ -->