simple_youtube 1.0.3 → 2.0.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.
- data/lib/simple_youtube/activeyoutube.rb +6 -11
- data/lib/simple_youtube/entry_interface_shim.rb +18 -0
- data/lib/simple_youtube/youtube.rb +11 -0
- data/{test → spec}/fakeweb_helper.rb +2 -2
- data/{test → spec}/fixture/playlist_cyanure1982.xml +0 -0
- data/{test → spec}/fixture/standardfeed_toprated_jp.xml +0 -0
- data/{test → spec}/fixture/standardfeed_toprated_jp_comedy.xml +0 -0
- data/{test → spec}/fixture/standardfeed_toprated_today.xml +0 -0
- data/{test → spec}/fixture/user_cyanure1982_playlists.xml +0 -0
- data/{test → spec}/fixture/user_ionysis_favourites.xml +0 -0
- data/{test → spec}/fixture/user_ionysis_subscriptions.xml +0 -0
- data/spec/fixture/user_mike6011_uploads.xml +1343 -0
- data/spec/fixture/user_neodracco.xml +43 -0
- data/{test → spec}/fixture/user_vinyljunkie07_contacts.xml +0 -0
- data/{test → spec}/fixture/video_category_comedy.xml +0 -0
- data/{test → spec}/fixture/video_category_comedy_exclude_film.xml +0 -0
- data/{test → spec}/fixture/video_category_david_beckham_news_or_sports.xml +0 -0
- data/{test → spec}/fixture/video_comments.xml +0 -0
- data/{test → spec}/fixture/video_related.xml +0 -0
- data/{test → spec}/fixture/video_responses.xml +0 -0
- data/{test → spec}/fixture/video_search.xml +0 -0
- data/spec/fixture/video_uid.xml +58 -0
- data/spec/fixture/video_update.xml +19 -0
- data/spec/youtube_read_spec.rb +126 -0
- data/spec/youtube_update_spec.rb +31 -0
- metadata +70 -74
- data/test/youtube_test.rb +0 -108
@@ -1,7 +1,10 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'active_resource'
|
3
|
+
require File.dirname(__FILE__) + "/entry_interface_shim"
|
3
4
|
|
4
5
|
class ActiveYoutube < ActiveResource::Base
|
6
|
+
|
7
|
+
include EntryInterfaceShim
|
5
8
|
|
6
9
|
self.site = "http://gdata.youtube.com/feeds/api"
|
7
10
|
|
@@ -9,15 +12,7 @@ class ActiveYoutube < ActiveResource::Base
|
|
9
12
|
scope, type, query = args[:scope], args[:type], args[:params]
|
10
13
|
headers['Accept'] = "application/atom+xml"
|
11
14
|
path = "#{prefix()}#{collection_name}#{'/' if scope}#{scope}#{'/' if type}#{type}#{query_string(query)}"
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
# if youtube only returns a single entry, then convert to an array to standardize subsequent feed processing
|
16
|
-
def self.convert_entry_to_array object
|
17
|
-
if object.respond_to?:entry and !(object.entry.kind_of? Array)
|
18
|
-
object.entry=[object.entry]
|
19
|
-
end
|
20
|
-
object
|
21
|
-
end
|
22
|
-
|
15
|
+
instantiate_record(connection.get(path, headers))
|
16
|
+
end
|
17
|
+
|
23
18
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#
|
2
|
+
# This module provides the interface for a response object to have
|
3
|
+
# a #entry method regardless of the response object being a single
|
4
|
+
# entry or a collection of entries
|
5
|
+
#
|
6
|
+
module EntryInterfaceShim
|
7
|
+
def entry
|
8
|
+
if attributes.has_key?('entry')
|
9
|
+
if attributes['entry'].kind_of? Array
|
10
|
+
return attributes['entry']
|
11
|
+
else
|
12
|
+
return [attributes['entry']]
|
13
|
+
end
|
14
|
+
else
|
15
|
+
[self]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,6 +1,16 @@
|
|
1
|
+
require 'oauth'
|
2
|
+
|
1
3
|
#### Create classes for YouTube resources.
|
2
4
|
module Youtube
|
5
|
+
|
3
6
|
class Video < ActiveYoutube
|
7
|
+
|
8
|
+
def self.update scope, user_name, update_xml, oauth_token, oauth_token_secret, x_gdata_key, host, host_secret
|
9
|
+
consumer = OAuth::Consumer.new(host, host_secret, {:site=>"https://www.google.com", :request_token_path=>"/accounts/OAuthGetRequestToken", :authorize_path=>"/accounts/OAuthAuthorizeToken", :access_token_path=>"/accounts/OAuthGetAccessToken"})
|
10
|
+
access_token = OAuth::AccessToken.new(consumer, oauth_token, oauth_token_secret)
|
11
|
+
access_token.put("http://gdata.youtube.com/feeds/api/users/#{user_name}/uploads/#{scope}", update_xml, {'Accept' => 'application/atom+xml', 'Content-Type' => 'application/atom+xml', 'X-GData-Key' => x_gdata_key})
|
12
|
+
end
|
13
|
+
|
4
14
|
end
|
5
15
|
|
6
16
|
class User < ActiveYoutube
|
@@ -11,4 +21,5 @@ module Youtube
|
|
11
21
|
|
12
22
|
class Playlist < ActiveYoutube
|
13
23
|
end
|
24
|
+
|
14
25
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|