lib/ayadn/api.rb in ayadn-1.8.2 vs lib/ayadn/api.rb in ayadn-2.0

- old
+ new

@@ -2,10 +2,11 @@ module Ayadn class API def initialize @workers = Workers.new + @status = Status.new end def get_unified(options) options = paginate options, 'unified' get_parsed_response(Endpoints.new.unified(options)) @@ -266,16 +267,11 @@ if directed == true || directed == 1 directed = 1 else directed = 0 end - html = arg[:html] || Settings.options[:timeline][:html] - if html == true || html == 1 - html = 1 - else - html = 0 - end + html = 0 if arg[:since_id] "&count=#{count}&include_html=#{html}&include_directed_posts=#{directed}&include_deleted=0&include_annotations=1&since_id=#{arg[:since_id]}" elsif arg[:recent_message] "&count=#{count}&include_html=#{html}&include_directed_posts=#{directed}&include_deleted=0&include_annotations=1&include_recent_message=#{arg[:recent_message]}" else @@ -285,11 +281,11 @@ private def paginate options, target if options[:new] || options[:scroll] - return {since_id: Databases.pagination[target]} + return {since_id: Databases.find_last_id_from(target)} end return options end def get_parsed_response(url) @@ -307,10 +303,13 @@ def build_list(username, target) options = {:count => 200, :before_id => nil} big_hash = {} loop do resp = get_parsed_response(get_list_url(username, target, options)) - abort(Status.user_404(username)) if resp['meta']['code'] == 404 + if resp['meta']['code'] == 404 + @status.user_404(username) + exit + end users = @workers.extract_users(resp) big_hash.merge!(users) break if resp['meta']['min_id'] == nil options = {:count => 200, :before_id => resp['meta']['min_id']} end