Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add accessor to insight_uri for both user and video; will be nil if n…

…ot present
  • Loading branch information...
commit daf770d28a97a7c8d1d949498c8621488ac0328f 1 parent 1f20b37
@yaauie yaauie authored
View
1  lib/youtube_it/model/user.rb
@@ -22,6 +22,7 @@ class User < YouTubeIt::Record
attr_reader :videos_watched
attr_reader :view_count
attr_reader :avatar
+ attr_reader :insight_uri
end
end
end
View
3  lib/youtube_it/model/video.rb
@@ -118,6 +118,9 @@ def self.by_code(format_code)
# *String*:: State of the video (processing, restricted, deleted, rejected and failed)
attr_reader :state
+ # *String*:: URI for insight for this video, if present; nil otherwise
+ attr_reader :insight_uri
+
# Geodata
attr_reader :where
View
6 lib/youtube_it/parser.rb
@@ -298,7 +298,8 @@ def parse_content(content)
:subscribers => entry.elements["yt:statistics"].attributes["subscriberCount"],
:videos_watched => entry.elements["yt:statistics"].attributes["videoWatchCount"],
:view_count => entry.elements["yt:statistics"].attributes["viewCount"],
- :upload_views => entry.elements["yt:statistics"].attributes["totalUploadViews"]
+ :upload_views => entry.elements["yt:statistics"].attributes["totalUploadViews"],
+ :insight_uri => (entry.elements['link[attribute::rel="http://gdata.youtube.com/schemas/2007#insight.views"]'].attributes['href'] rescue nil)
)
end
end
@@ -463,6 +464,8 @@ def parse_entry(entry)
end
+ insight_uri = (entry.elements['link[attribute::rel="http://gdata.youtube.com/schemas/2007#insight.views"]'].attributes['href'] rescue nil)
+
YouTubeIt::Model::Video.new(
:video_id => video_id,
:published_at => published_at,
@@ -488,6 +491,7 @@ def parse_entry(entry)
:latitude => latitude,
:longitude => longitude,
:state => state,
+ :insight_uri => insight_uri,
:unique_id => ytid)
end
View
5 test/test_client.rb
@@ -298,6 +298,8 @@ def test_should_get_my_videos
assert_valid_video video
result = @client.my_videos
assert_equal result.videos.first.unique_id, video.unique_id
+ assert_not_nil result.videos.first.insight_uri, 'insight data not present'
+ ensure
@client.video_delete(video.unique_id)
end
@@ -347,7 +349,8 @@ def test_should_list_subscriptions
def test_should_get_profile
profile = @client.profile
- assert_equal profile.username, "tubeit20101"
+ assert_equal profile.username, "tubeit20101"
+ assert_not_nil profile.insight_uri, 'user insight_uri nil'
end
def test_should_add_and_delete_video_to_favorite
Please sign in to comment.
Something went wrong with that request. Please try again.