Class: YouTubeIt::Parser::ProfileFeedParser

Inherits:
FeedParser
  • Object
show all
Defined in:
lib/youtube_it/parser.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from FeedParser

#initialize, #parse, #parse_videos

Constructor Details

This class inherits a constructor from YouTubeIt::Parser::FeedParser

Instance Method Details

#parse_content(content) ⇒ Object



279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/youtube_it/parser.rb', line 279

def parse_content(content)
  xml = REXML::Document.new(content.body)
  entry = xml.elements["entry"] || xml.elements["feed"]
  YouTubeIt::Model::User.new(
    :age            => entry.elements["yt:age"] ? entry.elements["yt:age"].text : nil,
    :username       => entry.elements["yt:username"] ? entry.elements["yt:username"].text : nil,
    :company        => entry.elements["yt:company"] ? entry.elements["yt:company"].text : nil,
    :gender         => entry.elements["yt:gender"] ? entry.elements["yt:gender"].text : nil,
    :hobbies        => entry.elements["yt:hobbies"] ? entry.elements["yt:hobbies"].text : nil,
    :hometown       => entry.elements["yt:hometown"] ? entry.elements["yt:hometown"].text : nil,
    :location       => entry.elements["yt:location"] ? entry.elements["yt:location"].text : nil,
    :last_login     => entry.elements["yt:statistics"].attributes["lastWebAccess"],
    :join_date      => entry.elements["published"] ? entry.elements["published"].text : nil,
    :movies         => entry.elements["yt:movies"] ? entry.elements["yt:movies"].text : nil,
    :music          => entry.elements["yt:music"] ? entry.elements["yt:music"].text : nil,
    :occupation     => entry.elements["yt:occupation"] ? entry.elements["yt:occupation"].text : nil,
    :relationship   => entry.elements["yt:relationship"] ? entry.elements["yt:relationship"].text : nil,
    :school         => entry.elements["yt:school"] ? entry.elements["yt:school"].text : nil,
    :avatar         => entry.elements["media:thumbnail"] ? entry.elements["media:thumbnail"].attributes["url"] : nil,
    :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"],
    :insight_uri    => (entry.elements['link[attribute::rel="http://gdata.youtube.com/schemas/2007#insight.views"]'].attributes['href'] rescue nil)
  )
end