Class: YouTubeIt::Parser::ProfileFeedParser
- Inherits:
-
FeedParser
- Object
- FeedParser
- YouTubeIt::Parser::ProfileFeedParser
- Defined in:
- lib/youtube_it/parser.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Method Summary collapse
Methods inherited from FeedParser
#initialize, #parse, #parse_single_entry, #parse_videos, #remove_bom
Constructor Details
This class inherits a constructor from YouTubeIt::Parser::FeedParser
Instance Method Details
#parse_content(content) ⇒ Object
291 292 293 294 295 |
# File 'lib/youtube_it/parser.rb', line 291 def parse_content(content) xml = Nokogiri::XML(content.body) entry = xml.at("entry") || xml.at("feed") parse_entry(entry) end |
#parse_entry(entry) ⇒ Object
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/youtube_it/parser.rb', line 296 def parse_entry(entry) YouTubeIt::Model::User.new( :age => entry.at_xpath("yt:age") ? entry.at_xpath("yt:age").text : nil, :username => entry.at_xpath("yt:username") ? entry.at_xpath("yt:username").text : nil, :username_display => (entry.at_xpath("yt:username")['display'] rescue nil), :user_id => (entry.at_xpath("xmlns:author/yt:userId").text rescue nil), :last_name => (entry.at_xpath("yt:lastName").text rescue nil), :first_name => (entry.at_xpath("yt:firstName").text rescue nil), :company => entry.at_xpath("yt:company") ? entry.at_xpath("yt:company").text : nil, :gender => entry.at_xpath("yt:gender") ? entry.at_xpath("yt:gender").text : nil, :hobbies => entry.at_xpath("yt:hobbies") ? entry.at_xpath("yt:hobbies").text : nil, :hometown => entry.at_xpath("yt:hometown") ? entry.at_xpath("yt:hometown").text : nil, :location => entry.at_xpath("yt:location") ? entry.at_xpath("yt:location").text : nil, :last_login => entry.at_xpath("yt:statistics")["lastWebAccess"], :join_date => entry.at("published") ? entry.at("published").text : nil, :movies => entry.at_xpath("yt:movies") ? entry.at_xpath("yt:movies").text : nil, :music => entry.at_xpath("yt:music") ? entry.at_xpath("yt:music").text : nil, :occupation => entry.at_xpath("yt:occupation") ? entry.at_xpath("yt:occupation").text : nil, :relationship => entry.at_xpath("yt:relationship") ? entry.at_xpath("yt:relationship").text : nil, :school => entry.at_xpath("yt:school") ? entry.at_xpath("yt:school").text : nil, :avatar => entry.at_xpath("media:thumbnail") ? entry.at_xpath("media:thumbnail")["url"] : nil, :upload_count => (entry.at_xpath('gd:feedLink[@rel="http://gdata.youtube.com/schemas/2007#user.uploads"]')['countHint'].to_i rescue nil), :max_upload_duration => (entry.at_xpath("yt:maxUploadDuration")['seconds'].to_i rescue nil), :subscribers => entry.at_xpath("yt:statistics")["subscriberCount"], :videos_watched => entry.at_xpath("yt:statistics")["videoWatchCount"], :view_count => entry.at_xpath("yt:statistics")["viewCount"], :upload_views => entry.at_xpath("yt:statistics")["totalUploadViews"], :insight_uri => (entry.at_xpath('xmlns:link[@rel="http://gdata.youtube.com/schemas/2007#insight.views"]')['href'] rescue nil) ) end |