Class: Tubeclip::Parser::BatchProfileFeedParser

Inherits:
ProfileFeedParser show all
Defined in:
lib/tubeclip/parser.rb

Instance Method Summary collapse

Methods inherited from ProfileFeedParser

#parse_entry

Methods inherited from FeedParser

#initialize, #parse, #parse_single_entry, #parse_videos, #remove_bom

Constructor Details

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

Instance Method Details

#parse_content(content) ⇒ Object



334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/tubeclip/parser.rb', line 334

def parse_content(content)
  Nokogiri::XML(content.body).xpath("//xmlns:entry").map do |entry|
    entry.namespaces.each {|name, url| entry.document.root.add_namespace name, url }
    username = entry.at_xpath('batch:id', entry.namespaces).text
    result = catch(:result) do
      case entry.at_xpath('batch:status', entry.namespaces)['code'].to_i
      when 200...300 then parse_entry(entry)
      else nil
      end
    end
    { username => result }
  end.reduce({},:merge)
end