diff --git a/lib/google-reader-api/feed.rb b/lib/google-reader-api/feed.rb index 5b74b78..0562492 100644 --- a/lib/google-reader-api/feed.rb +++ b/lib/google-reader-api/feed.rb @@ -39,7 +39,22 @@ def starred_items(count=20) # return the number of specified items. (read or not) def items(count = 20) - create_entries get_feed_items(:n => count) + if count <= 1000 + all_items = get_feed_items(:n => count) + else + continuation = nil + feed_items = [] + (count/1000).times do |index| + args = (continuation ? {:n => 1000, :c => continuation} : {:n => 1000} ) + feed_items << get_feed_items(args) + continuation = feed_items.last.match(/(.*)<\/gr:continuation>/).try(:captures).try(:first) + break unless continuation + end + (feed_items << get_feed_items({:n => (count%1000), :c => continuation})) if (((count%1000) > 0) and continuation) + all_items = feed_items + end + + create_entries all_items end # return all the unread items in an array @@ -71,6 +86,6 @@ def get_user_items(state,args={}) def get_feed_items(args={}) @api.get_link "atom/feed/#{url}" , args end - + end end \ No newline at end of file diff --git a/lib/google-reader-api/rss_utils.rb b/lib/google-reader-api/rss_utils.rb index 6feb12d..d0baceb 100644 --- a/lib/google-reader-api/rss_utils.rb +++ b/lib/google-reader-api/rss_utils.rb @@ -6,8 +6,14 @@ module RssUtils private - def create_entries(atom_feed) - RSS::Parser.parse(atom_feed.force_encoding('utf-8')).entries.map {|e| GoogleReaderApi::Entry.new(@api,e) } + def create_entries(atom_feeds) + if atom_feeds.class == String + RSS::Parser.parse(atom_feeds.force_encoding('utf-8')).entries.map {|e| GoogleReaderApi::Entry.new(@api,e) } + elsif atom_feeds.class == Array + atom_feeds.map { |atom_feed| + RSS::Parser.parse(atom_feed.force_encoding('utf-8')).entries.map {|e| GoogleReaderApi::Entry.new(@api,e) } + }.flatten + end end end