youtube_it 2.1.13 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -7,7 +7,7 @@
7
7
  will be destined to the Tuquito Libre Foundation(http://fundacion.tuquito.org.ar) for developing
8
8
  technology projects intended to close the digital gap in Latin America.
9
9
 
10
- {<img src=https://www.pledgie.com/campaigns/16746.png?skin_name=chrome>}[http://www.pledgie.com/campaigns/16746]
10
+ {<img src=http://www.pledgie.com/campaigns/16746.png?skin_name=chrome>}[http://www.pledgie.com/campaigns/16746]
11
11
 
12
12
  == DESCRIPTION
13
13
 
@@ -91,7 +91,7 @@ Standard Queries:
91
91
  $ client.videos_by(:most_viewed)
92
92
  $ client.videos_by(:most_linked, :page => 3)
93
93
  $ client.videos_by(:top_rated, :time => :today)
94
-
94
+ $ client.get_all_videos(:top_rated, :time => :today)
95
95
  Advanced Queries (with boolean operators OR (either), AND (include), NOT (exclude)):
96
96
  $ client.videos_by(:categories => { :either => [:news, :sports], :exclude => [:comedy] }, :tags => { :include => ['football'], :exclude => ['soccer'] })
97
97
 
@@ -213,11 +213,14 @@ Delete Playlist:
213
213
  $ client.delete_playlist(playlist_id)
214
214
 
215
215
  Add Video To Playlist:
216
- $ client.add_video_to_playlist(playlist_id, video_id)
216
+ $ client.add_video_to_playlist(playlist_id, video_id, position)
217
217
 
218
218
  Remove Video From Playlist:
219
219
  $ client.delete_video_from_playlist(playlist_id, playlist_entry_id)
220
220
 
221
+ Update Position Video From Playlist:
222
+ $ client.update_position_video_from_playlist(playlist_id, playlist_entry_id, position)
223
+
221
224
  Select All Videos From your Watch Later Playlist:
222
225
  $ watcher_later = client.watcherlater(user) #default: current user
223
226
  $ watcher_later.videos
@@ -244,6 +247,12 @@ List Response Videos
244
247
  $ video.responses.videos
245
248
 
246
249
 
250
+ == BATCH VIDEOS
251
+ you can list many videos at the same time
252
+
253
+ $ client.videos(['video_id_1', 'video_id_2',...])
254
+
255
+
247
256
  == ACCESS CONTROL LIST
248
257
 
249
258
  You can give permissions in your videos, for example denied comments, rate, etc...
@@ -263,6 +272,11 @@ List Response Videos
263
272
 
264
273
  client.video_upload(File.open("test.mov"), :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test], :comment => "denied")
265
274
 
275
+ == Partial Updates
276
+ You can send a single PATCH request to add, replace and/or delete specific fields for a particular resource.
277
+
278
+ client.video_partial_update(video.unique_id, :list => 'denied', :embed => 'allowed')
279
+
266
280
  == User Activity
267
281
  You can get user activity with the followings params:
268
282
 
data/lib/youtube_it.rb CHANGED
@@ -9,6 +9,7 @@ require 'oauth2'
9
9
  require 'faraday'
10
10
 
11
11
  class YouTubeIt
12
+ API_VERSION = "2.1"
12
13
 
13
14
  # Base error class for the extension
14
15
  class Error < RuntimeError
@@ -91,17 +91,28 @@ class YouTubeIt
91
91
  else
92
92
  vid = video
93
93
  end
94
- video_id ="http://gdata.youtube.com/feeds/api/videos/#{vid}?v=2#{@dev_key ? '&key='+@dev_key : ''}"
94
+ video_id ="http://gdata.youtube.com/feeds/api/videos/#{vid}?v=#{YouTubeIt::API_VERSION}#{@dev_key ? '&key='+@dev_key : ''}"
95
95
  parser = YouTubeIt::Parser::VideoFeedParser.new(video_id)
96
96
  parser.parse
97
97
  end
98
98
 
99
99
  def video_by_user(user, vid)
100
- video_id = "http://gdata.youtube.com/feeds/api/users/#{user}/uploads/#{vid}?v=2#{@dev_key ? '&key='+@dev_key : ''}"
100
+ video_id = "http://gdata.youtube.com/feeds/api/users/#{user}/uploads/#{vid}?v=#{YouTubeIt::API_VERSION}#{@dev_key ? '&key='+@dev_key : ''}"
101
101
  parser = YouTubeIt::Parser::VideoFeedParser.new(video_id)
102
102
  parser.parse
103
103
  end
104
104
 
105
+ def get_all_videos(opts)
106
+ page = videos_by(opts.merge({:page => 1}))
107
+ videos = page.videos
108
+
109
+ while page.next_page && (page = videos_by(opts.merge({:page => page.next_page})) || true)
110
+ videos += page.videos
111
+ end
112
+
113
+ videos
114
+ end
115
+
105
116
  def video_upload(data, opts = {})
106
117
  client.upload(data, opts)
107
118
  end
@@ -110,6 +121,10 @@ class YouTubeIt
110
121
  client.update(video_id, opts)
111
122
  end
112
123
 
124
+ def video_partial_update(video_id, opts = {})
125
+ client.partial_update(video_id, opts)
126
+ end
127
+
113
128
  def captions_update(video_id, data, opts = {})
114
129
  client.captions_update(video_id, data, opts)
115
130
  end
@@ -160,6 +175,10 @@ class YouTubeIt
160
175
  def profiles(*users)
161
176
  client.profiles(*users)
162
177
  end
178
+
179
+ def videos(*idxes)
180
+ client.videos(*idxes)
181
+ end
163
182
 
164
183
  # Fetches a user's activity feed.
165
184
  def activity(user = nil, opts = {})
@@ -178,8 +197,8 @@ class YouTubeIt
178
197
  client.delete_video_from_watchlater(video_id)
179
198
  end
180
199
 
181
- def playlist(playlist_id, order_by = :position)
182
- client.playlist(playlist_id, order_by)
200
+ def playlist(playlist_id, opts = {})
201
+ client.playlist(playlist_id, opts)
183
202
  end
184
203
 
185
204
  def playlists(user = nil, opts = nil)
@@ -210,8 +229,12 @@ class YouTubeIt
210
229
  client.update_playlist(playlist_id, options)
211
230
  end
212
231
 
213
- def add_video_to_playlist(playlist_id, video_id)
214
- client.add_video_to_playlist(playlist_id, video_id)
232
+ def add_video_to_playlist(playlist_id, video_id, position = nil)
233
+ client.add_video_to_playlist(playlist_id, video_id, position)
234
+ end
235
+
236
+ def update_position_video_from_playlist(playlist_id, playlist_entry_id, position = nil)
237
+ client.update_position_video_from_playlist(playlist_id, playlist_entry_id, position)
215
238
  end
216
239
 
217
240
  def delete_video_from_playlist(playlist_id, playlist_entry_id)
@@ -263,12 +286,12 @@ class YouTubeIt
263
286
  client.get_my_video(video_id)
264
287
  end
265
288
 
266
- # Gets all videos
289
+ # Gets all videos
267
290
  def my_videos(opts = {})
268
291
  client.get_my_videos(opts)
269
292
  end
270
293
 
271
- # Gets all of the user's contacts/friends.
294
+ # Gets all of the user's contacts/friends.
272
295
  def my_contacts(opts = {})
273
296
  client.get_my_contacts(opts)
274
297
  end
@@ -278,7 +301,7 @@ class YouTubeIt
278
301
  client.send_message(opts)
279
302
  end
280
303
 
281
- # Gets all of the user's messages/inbox.
304
+ # Gets all of the user's messages/inbox.
282
305
  def my_messages(opts = {})
283
306
  client.get_my_messages(opts)
284
307
  end
@@ -490,7 +513,7 @@ class YouTubeIt
490
513
  end
491
514
  @access_token
492
515
  end
493
-
516
+
494
517
  def session_token_info
495
518
  response = Faraday.get("https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=#{@client_access_token}")
496
519
  {:code => response.status, :body => response.body }
@@ -5,7 +5,7 @@ module FaradayMiddleware
5
5
  req_headers = env[:request_headers]
6
6
  req_headers.merge!(@headers)
7
7
  unless req_headers.include?("GData-Version")
8
- req_headers.merge!("GData-Version" => "2")
8
+ req_headers.merge!("GData-Version" => "2.1")
9
9
  end
10
10
  unless req_headers.include?("Content-Type")
11
11
  req_headers.merge!("Content-Type" => "application/atom+xml; charset=UTF-8")
@@ -100,6 +100,9 @@ class YouTubeIt
100
100
  # *String*:: Description of the video.
101
101
  attr_reader :html_content
102
102
 
103
+ # *String*:: Description of the video.
104
+ attr_reader :raw_content
105
+
103
106
  # YouTubeIt::Model::Author:: Information about the YouTube user who owns a piece of video content.
104
107
  attr_reader :author
105
108
 
@@ -141,19 +144,22 @@ class YouTubeIt
141
144
  attr_reader :latitude
142
145
  attr_reader :longitude
143
146
 
147
+ # Playlist position
148
+ attr_reader :video_position
149
+
144
150
  # Videos related to the current video.
145
151
  #
146
152
  # === Returns
147
153
  # YouTubeIt::Response::VideoSearch
148
154
  def related
149
- YouTubeIt::Parser::VideosFeedParser.new("http://gdata.youtube.com/feeds/api/videos/#{unique_id}/related?v=2").parse
155
+ YouTubeIt::Parser::VideosFeedParser.new("http://gdata.youtube.com/feeds/api/videos/#{unique_id}/related?v=#{YouTubeIt::API_VERSION}").parse
150
156
  end
151
157
  # Video responses to the current video.
152
158
  #
153
159
  # === Returns
154
160
  # YouTubeIt::Response::VideoSearch
155
161
  def responses
156
- YouTubeIt::Parser::VideosFeedParser.new("http://gdata.youtube.com/feeds/api/videos/#{unique_id}/responses?v=2").parse
162
+ YouTubeIt::Parser::VideosFeedParser.new("http://gdata.youtube.com/feeds/api/videos/#{unique_id}/responses?v=#{YouTubeIt::API_VERSION}").parse
157
163
  end
158
164
 
159
165
 
@@ -340,7 +340,7 @@ class YouTubeIt
340
340
  end.reduce({},:merge)
341
341
  end
342
342
  end
343
-
343
+
344
344
  class SubscriptionFeedParser < FeedParser #:nodoc:
345
345
 
346
346
  def parse_content(content)
@@ -474,11 +474,14 @@ class YouTubeIt
474
474
  :height => thumb_element["height"].to_i,
475
475
  :width => thumb_element["width"].to_i,
476
476
  :time => thumb_element["time"],
477
- :name => thumb_element["name"])
477
+ :name => thumb_element["yt:name"])
478
478
  end
479
479
 
480
480
  rating_element = entry.at_xpath("gd:rating") rescue nil
481
481
  extended_rating_element = entry.at_xpath("yt:rating") rescue nil
482
+ unless entry.at_xpath("yt:position").nil?
483
+ video_position = entry.at_xpath("yt:position").text
484
+ end
482
485
 
483
486
  rating = nil
484
487
  if rating_element
@@ -544,7 +547,6 @@ class YouTubeIt
544
547
  :categories => categories,
545
548
  :keywords => keywords,
546
549
  :title => title,
547
- :html_content => html_content,
548
550
  :author => author,
549
551
  :description => description,
550
552
  :duration => duration,
@@ -560,11 +562,13 @@ class YouTubeIt
560
562
  :noembed => noembed,
561
563
  :safe_search => safe_search,
562
564
  :position => position,
565
+ :video_position => video_position,
563
566
  :latitude => latitude,
564
567
  :longitude => longitude,
565
568
  :state => state,
566
569
  :insight_uri => insight_uri,
567
570
  :unique_id => ytid,
571
+ :raw_content => entry,
568
572
  :perm_private => perm_private)
569
573
  end
570
574
 
@@ -585,6 +589,22 @@ class YouTubeIt
585
589
  end
586
590
  end
587
591
 
592
+ class BatchVideoFeedParser < VideoFeedParser
593
+ def parse_content(content)
594
+ Nokogiri::XML(content.body).xpath("//xmlns:entry").map do |entry|
595
+ entry.namespaces.each {|name, url| entry.document.root.add_namespace name, url }
596
+ username = entry.at_xpath('batch:id', entry.namespaces).text
597
+ result = catch(:result) do
598
+ case entry.at_xpath('batch:status', entry.namespaces)['code'].to_i
599
+ when 200...300 then parse_entry(entry)
600
+ else nil
601
+ end
602
+ end
603
+ { username => result }
604
+ end.reduce({},:merge)
605
+ end
606
+ end
607
+
588
608
  class VideosFeedParser < VideoFeedParser #:nodoc:
589
609
 
590
610
  private
@@ -33,7 +33,7 @@ class YouTubeIt
33
33
  'orderby' => @order_by,
34
34
  'start-index' => @offset,
35
35
  'time' => @time,
36
- 'v' => 2
36
+ 'v' => YouTubeIt::API_VERSION
37
37
  }
38
38
  end
39
39
  end
@@ -37,7 +37,7 @@ class YouTubeIt
37
37
  'max-results' => @max_results,
38
38
  'orderby' => @order_by,
39
39
  'start-index' => @offset,
40
- 'v' => 2
40
+ 'v' => YouTubeIt::API_VERSION
41
41
  }
42
42
  end
43
43
  end
@@ -42,7 +42,7 @@ class YouTubeIt
42
42
  @dev_key = params[:dev_key] if params[:dev_key]
43
43
 
44
44
  # Return a single video (base_url + /T7YazwP8GtY)
45
- return @url << "/" << params[:video_id] << "?v=2" if params[:video_id]
45
+ return @url << "/" << params[:video_id] << "?v=#{YouTubeIt::API_VERSION}" if params[:video_id]
46
46
 
47
47
  @url << "/-/" if (params[:categories] || params[:tags])
48
48
  @url << categories_to_params(params.delete(:categories)) if params[:categories]
@@ -69,7 +69,7 @@ class YouTubeIt
69
69
  'max-results' => @max_results,
70
70
  'orderby' => @order_by,
71
71
  'start-index' => @offset,
72
- 'v' => 2,
72
+ 'v' => YouTubeIt::API_VERSION,
73
73
  'q' => @query,
74
74
  'alt' => @response_format,
75
75
  'format' => @video_format,
@@ -115,6 +115,15 @@ class YouTubeIt
115
115
  return YouTubeIt::Parser::VideoFeedParser.new(response.body).parse rescue nil
116
116
  end
117
117
 
118
+ # Partial updates to a video.
119
+ def partial_update(video_id, options)
120
+ update_body = partial_video_xml(options)
121
+ update_url = "/feeds/api/users/default/uploads/%s" % video_id
122
+ update_header = { "Content-Type" => "application/xml" }
123
+ response = yt_session.patch(update_url, update_body, update_header)
124
+
125
+ return YouTubeIt::Parser::VideoFeedParser.new(response.body).parse rescue nil
126
+ end
118
127
 
119
128
  def captions_update(video_id, data, options)
120
129
  @opts = {
@@ -136,7 +145,7 @@ class YouTubeIt
136
145
  # Fetches the currently authenticated user's contacts (i.e. friends).
137
146
  # When the authentication credentials are incorrect, an AuthenticationError will be raised.
138
147
  def get_my_contacts(opts)
139
- contacts_url = "/feeds/api/users/default/contacts?v=2"
148
+ contacts_url = "/feeds/api/users/default/contacts?v=#{YouTubeIt::API_VERSION}"
140
149
  contacts_url << opts.collect { |k,p| [k,p].join '=' }.join('&')
141
150
  response = yt_session.get(contacts_url)
142
151
 
@@ -253,10 +262,39 @@ class YouTubeIt
253
262
  return YouTubeIt::Parser::ProfileFeedParser.new(response).parse
254
263
  end
255
264
 
265
+ def videos(idxes_to_fetch)
266
+ idxes_to_fetch.each_slice(50).map do |idxes|
267
+ post = Nokogiri::XML <<-BATCH
268
+ <feed
269
+ xmlns='http://www.w3.org/2005/Atom'
270
+ xmlns:media='http://search.yahoo.com/mrss/'
271
+ xmlns:batch='http://schemas.google.com/gdata/batch'
272
+ xmlns:yt='http://gdata.youtube.com/schemas/2007'>
273
+ </feed>
274
+ BATCH
275
+ idxes.each do |idx|
276
+ post.at('feed').add_child <<-ENTRY
277
+ <entry>
278
+ <batch:operation type="query" />
279
+ <id>/feeds/api/videos/#{idx}?v=#{YouTubeIt::API_VERSION}</id>
280
+ <batch:id>#{idx}</batch:id>
281
+ </entry>
282
+ ENTRY
283
+ end
284
+
285
+ post_body = StringIO.new('')
286
+ post.write_to( post_body, :indent => 2 )
287
+ post_body_io = StringIO.new(post_body.string)
288
+
289
+ response = yt_session.post('feeds/api/videos/batch', post_body_io )
290
+ YouTubeIt::Parser::BatchVideoFeedParser.new(response).parse
291
+ end.reduce({},:merge)
292
+ end
293
+
256
294
  def profiles(usernames_to_fetch)
257
295
  usernames_to_fetch.each_slice(50).map do |usernames|
258
296
  post = Nokogiri::XML <<-BATCH
259
- <feed
297
+ <feed
260
298
  xmlns='http://www.w3.org/2005/Atom'
261
299
  xmlns:media='http://search.yahoo.com/mrss/'
262
300
  xmlns:batch='http://schemas.google.com/gdata/batch'
@@ -283,12 +321,12 @@ class YouTubeIt
283
321
  end
284
322
 
285
323
  def profile_url(user=nil)
286
- "/feeds/api/users/%s?v=2" % (user || "default")
324
+ "/feeds/api/users/%s?v=#{YouTubeIt::API_VERSION}" % (user || "default")
287
325
  end
288
326
 
289
327
  # Return's a user's activity feed.
290
328
  def get_activity(user, opts)
291
- activity_url = "/feeds/api/events?author=%s&v=2&" % (user ? user : "default")
329
+ activity_url = "/feeds/api/events?author=%s&v=#{YouTubeIt::API_VERSION}&" % (user ? user : "default")
292
330
  activity_url << opts.collect { |k,p| [k,p].join '=' }.join('&')
293
331
  response = yt_session.get(activity_url)
294
332
 
@@ -296,7 +334,7 @@ class YouTubeIt
296
334
  end
297
335
 
298
336
  def watchlater(user)
299
- watchlater_url = "/feeds/api/users/%s/watch_later?v=2" % (user ? user : "default")
337
+ watchlater_url = "/feeds/api/users/%s/watch_later?v=#{YouTubeIt::API_VERSION}" % (user ? user : "default")
300
338
  response = yt_session.get(watchlater_url)
301
339
 
302
340
  return YouTubeIt::Parser::PlaylistFeedParser.new(response).parse
@@ -317,9 +355,12 @@ class YouTubeIt
317
355
  return true
318
356
  end
319
357
 
320
- def playlist(playlist_id, order_by = :position)
321
- playlist_url = "/feeds/api/playlists/%s?v=2&orderby=%s" % [playlist_id, order_by]
322
- response = yt_session.get(playlist_url)
358
+ def playlist(playlist_id, opts = {})
359
+ playlist_url = "/feeds/api/playlists/%s" % playlist_id
360
+ params = {'v' => 2, 'orderby' => 'position'}
361
+ params.merge!(opts) if opts
362
+ playlist_url << "?#{params.collect { |k,v| [k,v].join '=' }.join('&')}"
363
+ response = yt_session.get(playlist_url)
323
364
 
324
365
  return YouTubeIt::Parser::PlaylistFeedParser.new(response).parse
325
366
  end
@@ -334,7 +375,7 @@ class YouTubeIt
334
375
  # max-results - maximum number of playlists to fetch, up to 25 (default is 25)
335
376
  def playlists(user, opts={})
336
377
  playlist_url = "/feeds/api/users/%s/playlists" % (user ? user : "default")
337
- params = {'v' => 2}
378
+ params = {'v' => YouTubeIt::API_VERSION}
338
379
  params.merge!(opts) if opts
339
380
  playlist_url << "?#{params.collect { |k,v| [k,v].join '=' }.join('&')}"
340
381
  response = yt_session.get(playlist_url)
@@ -350,14 +391,22 @@ class YouTubeIt
350
391
  return YouTubeIt::Parser::PlaylistFeedParser.new(response).parse
351
392
  end
352
393
 
353
- def add_video_to_playlist(playlist_id, video_id)
354
- playlist_body = video_xml_for(:playlist => video_id)
394
+ def add_video_to_playlist(playlist_id, video_id, position)
395
+ playlist_body = video_xml_for(:playlist => video_id, :position => position)
355
396
  playlist_url = "/feeds/api/playlists/%s" % playlist_id
356
397
  response = yt_session.post(playlist_url, playlist_body)
357
398
 
358
399
  return {:code => response.status, :body => response.body, :playlist_entry_id => get_entry_id(response.body)}
359
400
  end
360
401
 
402
+ def update_position_video_from_playlist(playlist_id, playlist_entry_id, position)
403
+ playlist_body = video_xml_for(:position => position)
404
+ playlist_url = "/feeds/api/playlists/%s/%s" % [playlist_id, playlist_entry_id]
405
+ response = yt_session.put(playlist_url, playlist_body)
406
+
407
+ return {:code => response.status, :body => response.body, :playlist_entry_id => get_entry_id(response.body)}
408
+ end
409
+
361
410
  def update_playlist(playlist_id, options)
362
411
  playlist_body = video_xml_for_playlist(options)
363
412
  playlist_url = "/feeds/api/users/default/playlists/%s" % playlist_id
@@ -389,7 +438,7 @@ class YouTubeIt
389
438
  end
390
439
 
391
440
  def subscriptions(user)
392
- subscription_url = "/feeds/api/users/%s/subscriptions?v=2" % (user ? user : "default")
441
+ subscription_url = "/feeds/api/users/%s/subscriptions?v=#{YouTubeIt::API_VERSION}" % (user ? user : "default")
393
442
  response = yt_session.get(subscription_url)
394
443
 
395
444
  return YouTubeIt::Parser::SubscriptionFeedParser.new(response).parse
@@ -440,14 +489,14 @@ class YouTubeIt
440
489
  end
441
490
 
442
491
  def get_watch_history
443
- watch_history_url = "/feeds/api/users/default/watch_history?v=2"
492
+ watch_history_url = "/feeds/api/users/default/watch_history?v=#{YouTubeIt::API_VERSION}"
444
493
  response = yt_session.get(watch_history_url)
445
494
 
446
495
  return YouTubeIt::Parser::VideosFeedParser.new(response.body).parse
447
496
  end
448
497
 
449
498
  def new_subscription_videos(user)
450
- subscription_url = "/feeds/api/users/%s/newsubscriptionvideos?v=2" % (user ? user : "default")
499
+ subscription_url = "/feeds/api/users/%s/newsubscriptionvideos?v=#{YouTubeIt::API_VERSION}" % (user ? user : "default")
451
500
  response = yt_session.get(subscription_url)
452
501
 
453
502
  return YouTubeIt::Parser::VideosFeedParser.new(response.body).parse
@@ -525,7 +574,7 @@ class YouTubeIt
525
574
  @auth_token ||= begin
526
575
  http = Faraday.new("https://www.google.com", :ssl => {:verify => false})
527
576
  body = "Email=#{YouTubeIt.esc @user}&Passwd=#{YouTubeIt.esc @password}&service=youtube&source=#{YouTubeIt.esc @client_id}"
528
- response = http.post("/youtube/accounts/ClientLogin", body, "Content-Type" => "application/x-www-form-urlencoded")
577
+ response = http.post("/accounts/ClientLogin", body, "Content-Type" => "application/x-www-form-urlencoded")
529
578
  raise ::AuthenticationError.new(response.body[/Error=(.+)/,1], response.status.to_i) if response.status.to_i != 200
530
579
  @auth_token = response.body[/Auth=(.+)/, 1]
531
580
  end
@@ -565,12 +614,59 @@ class YouTubeIt
565
614
  end.to_s
566
615
  end
567
616
 
617
+ def partial_video_xml(opts)
618
+ perms = [ :rate, :comment, :commentVote, :videoRespond, :list, :embed, :syndicate ]
619
+ delete_attrs = []
620
+ perms.each do |perm|
621
+ delete_attrs << "@action='#{perm}'" if opts[perm]
622
+ end
623
+
624
+ entry_attrs = {
625
+ :xmlns => "http://www.w3.org/2005/Atom",
626
+ 'xmlns:media' => "http://search.yahoo.com/mrss/",
627
+ 'xmlns:gd' => "http://schemas.google.com/g/2005",
628
+ 'xmlns:yt' => "http://gdata.youtube.com/schemas/2007",
629
+ 'xmlns:gml' => 'http://www.opengis.net/gml',
630
+ 'xmlns:georss' => 'http://www.georss.org/georss' }
631
+
632
+ if !delete_attrs.empty?
633
+ entry_attrs['gd:fields'] = "yt:accessControl[#{delete_attrs.join(' or ')}]"
634
+ end
635
+
636
+ b = Builder::XmlMarkup.new
637
+ b.instruct!
638
+ b.entry(entry_attrs) do | m |
639
+
640
+ m.tag!("media:group") do | mg |
641
+ mg.tag!("media:title", opts[:title], :type => "plain") if opts[:title]
642
+ mg.tag!("media:description", opts[:description], :type => "plain") if opts[:description]
643
+ mg.tag!("media:keywords", opts[:keywords].join(",")) if opts[:keywords]
644
+ mg.tag!('media:category', opts[:category], :scheme => "http://gdata.youtube.com/schemas/2007/categories.cat") if opts[:category]
645
+ mg.tag!('yt:private') if opts[:private]
646
+ mg.tag!('media:category', opts[:dev_tag], :scheme => "http://gdata.youtube.com/schemas/2007/developertags.cat") if opts[:dev_tag]
647
+ end
648
+
649
+ perms.each do |perm|
650
+ m.tag!("yt:accessControl", :action => perm.to_s, :permission => opts[perm]) if opts[perm]
651
+ end
652
+
653
+ if opts[:latitude] and opts[:longitude]
654
+ m.tag!("georss:where") do |geo|
655
+ geo.tag!("gml:Point") do |point|
656
+ point.tag!("gml:pos", opts.values_at(:latitude, :longitude).join(' '))
657
+ end
658
+ end
659
+ end
660
+ end.to_s
661
+ end
662
+
568
663
  def video_xml_for(data)
569
664
  b = Builder::XmlMarkup.new
570
665
  b.instruct!
571
666
  b.entry(:xmlns => "http://www.w3.org/2005/Atom", 'xmlns:yt' => "http://gdata.youtube.com/schemas/2007") do | m |
572
667
  m.id(data[:favorite] || data[:playlist] || data[:response]) if data[:favorite] || data[:playlist] || data[:response]
573
668
  m.tag!("yt:rating", :value => data[:rating]) if data[:rating]
669
+ m.tag!("yt:position", data[:position]) if data[:position]
574
670
  if(data[:subscribe])
575
671
  m.category(:scheme => "http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat", :term => "channel")
576
672
  m.tag!("yt:username", data[:subscribe])
@@ -1,4 +1,4 @@
1
1
  class YouTubeIt
2
- VERSION = '2.1.13'
2
+ VERSION = '2.2.1'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,177 +1,154 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: youtube_it
3
- version: !ruby/object:Gem::Version
4
- version: 2.1.13
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
5
+ version: 2.2.1
6
6
  platform: ruby
7
- authors:
8
- - kylejginavan
9
- - chebyte
7
+ authors:
8
+ - kylejginavan
9
+ - chebyte
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-02-04 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: nokogiri
17
- requirement: !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ~>
21
- - !ruby/object:Gem::Version
22
- version: 1.5.2
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ~>
29
- - !ruby/object:Gem::Version
30
- version: 1.5.2
31
- - !ruby/object:Gem::Dependency
32
- name: oauth
33
- requirement: !ruby/object:Gem::Requirement
34
- none: false
35
- requirements:
36
- - - ~>
37
- - !ruby/object:Gem::Version
38
- version: 0.4.4
39
- type: :runtime
40
- prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - ~>
45
- - !ruby/object:Gem::Version
46
- version: 0.4.4
47
- - !ruby/object:Gem::Dependency
48
- name: oauth2
49
- requirement: !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: '0.6'
55
- type: :runtime
56
- prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ~>
61
- - !ruby/object:Gem::Version
62
- version: '0.6'
63
- - !ruby/object:Gem::Dependency
64
- name: simple_oauth
65
- requirement: !ruby/object:Gem::Requirement
66
- none: false
67
- requirements:
68
- - - ! '>='
69
- - !ruby/object:Gem::Version
70
- version: 0.1.5
71
- type: :runtime
72
- prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
- requirements:
76
- - - ! '>='
77
- - !ruby/object:Gem::Version
78
- version: 0.1.5
79
- - !ruby/object:Gem::Dependency
80
- name: faraday
81
- requirement: !ruby/object:Gem::Requirement
82
- none: false
83
- requirements:
84
- - - ~>
85
- - !ruby/object:Gem::Version
86
- version: '0.8'
87
- type: :runtime
88
- prerelease: false
89
- version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
- requirements:
92
- - - ~>
93
- - !ruby/object:Gem::Version
94
- version: '0.8'
95
- - !ruby/object:Gem::Dependency
96
- name: builder
97
- requirement: !ruby/object:Gem::Requirement
98
- none: false
99
- requirements:
100
- - - ! '>='
101
- - !ruby/object:Gem::Version
102
- version: '0'
103
- type: :runtime
104
- prerelease: false
105
- version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
- requirements:
108
- - - ! '>='
109
- - !ruby/object:Gem::Version
110
- version: '0'
13
+
14
+ date: 2013-04-25 00:00:00 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: nokogiri
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: 1.5.2
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: oauth
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: 0.4.4
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: oauth2
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: "0.6"
47
+ type: :runtime
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: simple_oauth
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 0.1.5
58
+ type: :runtime
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: faraday
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: "0.8"
69
+ type: :runtime
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: builder
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ type: :runtime
81
+ version_requirements: *id006
111
82
  description: Upload, delete, update, comment on youtube videos all from one gem.
112
- email:
113
- - kylejginavan@gmail.com
114
- - maurotorres@gmail.com
83
+ email:
84
+ - kylejginavan@gmail.com
85
+ - maurotorres@gmail.com
115
86
  executables: []
87
+
116
88
  extensions: []
117
- extra_rdoc_files:
118
- - README.rdoc
119
- files:
120
- - lib/youtube_it/chain_io.rb
121
- - lib/youtube_it/client.rb
122
- - lib/youtube_it/middleware/faraday_authheader.rb
123
- - lib/youtube_it/middleware/faraday_oauth.rb
124
- - lib/youtube_it/middleware/faraday_oauth2.rb
125
- - lib/youtube_it/middleware/faraday_youtubeit.rb
126
- - lib/youtube_it/model/activity.rb
127
- - lib/youtube_it/model/author.rb
128
- - lib/youtube_it/model/caption.rb
129
- - lib/youtube_it/model/category.rb
130
- - lib/youtube_it/model/comment.rb
131
- - lib/youtube_it/model/contact.rb
132
- - lib/youtube_it/model/content.rb
133
- - lib/youtube_it/model/message.rb
134
- - lib/youtube_it/model/playlist.rb
135
- - lib/youtube_it/model/rating.rb
136
- - lib/youtube_it/model/subscription.rb
137
- - lib/youtube_it/model/thumbnail.rb
138
- - lib/youtube_it/model/user.rb
139
- - lib/youtube_it/model/video.rb
140
- - lib/youtube_it/parser.rb
141
- - lib/youtube_it/record.rb
142
- - lib/youtube_it/request/base_search.rb
143
- - lib/youtube_it/request/error.rb
144
- - lib/youtube_it/request/standard_search.rb
145
- - lib/youtube_it/request/user_search.rb
146
- - lib/youtube_it/request/video_search.rb
147
- - lib/youtube_it/request/video_upload.rb
148
- - lib/youtube_it/response/video_search.rb
149
- - lib/youtube_it/version.rb
150
- - lib/youtube_it.rb
151
- - README.rdoc
152
- - youtube_it.gemspec
89
+
90
+ extra_rdoc_files:
91
+ - README.rdoc
92
+ files:
93
+ - lib/youtube_it.rb
94
+ - lib/youtube_it/chain_io.rb
95
+ - lib/youtube_it/client.rb
96
+ - lib/youtube_it/parser.rb
97
+ - lib/youtube_it/record.rb
98
+ - lib/youtube_it/version.rb
99
+ - lib/youtube_it/middleware/faraday_authheader.rb
100
+ - lib/youtube_it/middleware/faraday_oauth.rb
101
+ - lib/youtube_it/middleware/faraday_oauth2.rb
102
+ - lib/youtube_it/middleware/faraday_youtubeit.rb
103
+ - lib/youtube_it/model/activity.rb
104
+ - lib/youtube_it/model/author.rb
105
+ - lib/youtube_it/model/caption.rb
106
+ - lib/youtube_it/model/category.rb
107
+ - lib/youtube_it/model/comment.rb
108
+ - lib/youtube_it/model/contact.rb
109
+ - lib/youtube_it/model/content.rb
110
+ - lib/youtube_it/model/message.rb
111
+ - lib/youtube_it/model/playlist.rb
112
+ - lib/youtube_it/model/rating.rb
113
+ - lib/youtube_it/model/subscription.rb
114
+ - lib/youtube_it/model/thumbnail.rb
115
+ - lib/youtube_it/model/user.rb
116
+ - lib/youtube_it/model/video.rb
117
+ - lib/youtube_it/request/base_search.rb
118
+ - lib/youtube_it/request/error.rb
119
+ - lib/youtube_it/request/standard_search.rb
120
+ - lib/youtube_it/request/user_search.rb
121
+ - lib/youtube_it/request/video_search.rb
122
+ - lib/youtube_it/request/video_upload.rb
123
+ - lib/youtube_it/response/video_search.rb
124
+ - README.rdoc
125
+ - youtube_it.gemspec
153
126
  homepage: http://github.com/kylejginavan/youtube_it
154
127
  licenses: []
128
+
155
129
  post_install_message:
156
130
  rdoc_options: []
157
- require_paths:
158
- - lib
159
- required_ruby_version: !ruby/object:Gem::Requirement
131
+
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
160
135
  none: false
161
- requirements:
162
- - - ! '>='
163
- - !ruby/object:Gem::Version
164
- version: '0'
165
- required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: "0"
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
141
  none: false
167
- requirements:
168
- - - ! '>='
169
- - !ruby/object:Gem::Version
170
- version: '0'
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: "0"
171
146
  requirements: []
147
+
172
148
  rubyforge_project:
173
- rubygems_version: 1.8.23
149
+ rubygems_version: 1.8.15
174
150
  signing_key:
175
151
  specification_version: 3
176
152
  summary: The most complete Ruby wrapper for youtube api's
177
153
  test_files: []
154
+