Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions lib/google-reader-api/feed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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>(.*)<\/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
Expand Down Expand Up @@ -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
10 changes: 8 additions & 2 deletions lib/google-reader-api/rss_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down