Skip to content

Commit

Permalink
Use timestamp for next paging of #videos
Browse files Browse the repository at this point in the history
Do not use next paging uri, because it is not provided even when
there is a next page. For example it did not return the first video
of FullscreenInc channel.
  • Loading branch information
kangkyu committed Apr 18, 2017
1 parent 006f6d2 commit 433090a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/funky/connections/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ def self.fetch(path_query, is_array: false)

def self.fetch_multiple_pages(uri)
json = json_for(uri)
if json[:paging][:next]
next_paging_uri = URI json[:paging][:next]
json[:data] + fetch_multiple_pages(next_paging_uri)
if json[:data].empty?
[]
else
json[:data]
timestamp = json[:data][-1][:created_time]
if @previous_timestamp == timestamp
[]
else
@previous_timestamp = timestamp
uri.query = uri.query + "&until=#{Time.parse(timestamp).to_i}"
json[:data] + fetch_multiple_pages(uri)
end
end
end

Expand Down

0 comments on commit 433090a

Please sign in to comment.