lib/ayadn/stream.rb in ayadn-1.6.0 vs lib/ayadn/stream.rb in ayadn-1.7.0

- old
+ new

@@ -7,68 +7,50 @@ @api = api @view = view @workers = workers end - def unified options - @view.downloading(options) - stream = @api.get_unified(options) - Check.no_new_posts(stream, options, 'unified') - Databases.save_max_id(stream) - @view.render(stream, options) - Scroll.new(@api, @view).unified(options) if options[:scroll] - end - - def checkins options - @view.downloading(options) - stream = @api.get_checkins(options) - Check.no_new_posts(stream, options, 'explore:checkins') - Databases.save_max_id(stream) - @view.render(stream, options) - Scroll.new(@api, @view).checkins(options) if options[:scroll] - end - def global settings + Settings.options[:force] = true if settings[:force] options = settings.dup options[:filter] = nicerank_true() @view.downloading(options) stream = @api.get_global(options) - niceranks = NiceRank.new.get_ranks(stream) + Settings.options[:force] == true ? niceranks = {} : niceranks = NiceRank.new.get_ranks(stream) Check.no_new_posts(stream, options, 'global') - Databases.save_max_id(stream) + Databases.save_max_id(stream, 'global') unless stream['meta']['max_id'].nil? @view.render(stream, options, niceranks) Scroll.new(@api, @view).global(options) if options[:scroll] end - def trending options - @view.downloading(options) - stream = @api.get_trending(options) - Check.no_new_posts(stream, options, 'explore:trending') - Databases.save_max_id(stream) - @view.render(stream, options) - Scroll.new(@api, @view).trending(options) if options[:scroll] - end - def photos options - @view.downloading(options) - stream = @api.get_photos(options) - Check.no_new_posts(stream, options, 'explore:photos') - Databases.save_max_id(stream) - @view.render(stream, options) - Scroll.new(@api, @view).photos(options) if options[:scroll] + def method_missing(meth, options) + case meth + when :checkins, :trending, :photos + stream(meth, options, "explore:#{meth}") + when :conversations + stream(meth, options, "explore:replies") + when :unified + stream(meth, options, meth.to_s) + else + super + end end - def conversations options + def stream meth, options, target + Settings.options[:force] = true if options[:force] @view.downloading(options) - stream = @api.get_conversations(options) - Check.no_new_posts(stream, options, 'explore:replies') + stream = @api.send("get_#{meth}".to_sym, options) + Check.no_new_posts(stream, options, target) Databases.save_max_id(stream) @view.render(stream, options) - Scroll.new(@api, @view).replies(options) if options[:scroll] + Scroll.new(@api, @view).send(meth, options) if options[:scroll] end + def mentions username, options + Settings.options[:force] = true if options[:force] Check.no_username(username) username = @workers.add_arobase(username) @view.downloading(options) stream = @api.get_mentions(username, options) Check.no_user(stream, username) @@ -79,17 +61,21 @@ @view.render(stream, options) Scroll.new(@api, @view).mentions(username, options) if options[:scroll] end def posts username, options + Settings.options[:force] = true if options[:force] Check.no_username(username) username = @workers.add_arobase(username) @view.downloading(options) stream = @api.get_posts(username, options) Check.no_user(stream, username) - Databases.save_max_id(stream) + Databases.save_max_id(stream) unless stream['meta']['marker'].nil? Check.no_data(stream, 'mentions') + if Databases.blacklist["-#{username.downcase}"] || stream['data'][0]['user']['you_muted'] || stream['data'][0]['user']['you_blocked'] + abort(Status.no_force("#{username.downcase}")) unless options[:raw] || Settings.options[:force] + end @view.render(stream, options) Scroll.new(@api, @view).posts(username, options) if options[:scroll] end def whatstarred(username, options) @@ -176,9 +162,10 @@ abort(Status.nobody_starred) if list['data'].empty? @view.list(:whostarred, list['data'], id) end def convo(post_id, options) + Settings.options[:force] = true if options[:force] Check.bad_post_id(post_id) @view.downloading(options) details = @api.get_details(post_id, options) Check.no_post(details, post_id) id = @workers.get_original_id(post_id, details)