bin/instafavs in instafavs-0.0.4 vs bin/instafavs in instafavs-0.0.5
- old
+ new
@@ -14,25 +14,28 @@
end
def send_links_from_fav_tweets_to_instapaper
Instafavs::Config.load!
- last_update_run_at = Instafavs::Config.last_update_run_at
- this_update_run_at = Time.now.utc
- twitter_username = Instafavs::Config.twitter_username
- favourites = Instafavs.new_favourites_in_period(twitter_username, last_update_run_at, this_update_run_at)
- verbose("found #{favourites.size} latest favourites for user #{twitter_username}")
+ seen_fav_ids = Set.new
+ favourites = Twitter.favorites(Instafavs::Config.twitter_username)
+ verbose("found #{favourites.size} latest favourites for user #{Instafavs::Config.twitter_username}")
favourites.each_with_index do |f, i|
+ seen_fav_ids << f.id_str
+ if Instafavs::Config.last_seen_fav_ids.include?(f.id_str)
+ verbose("skipping ##{i + 1} '#{f.text}', already seen")
+ next
+ end
verbose("scanning #{f.text} for urls to extract")
f.text.scan(%r{http(?:s?)://[^ ]+}).each do |url|
verbose("found #{url}, sending to instapaper", 2)
HTTParty.post("https://www.instapaper.com/api/add",
:query => { :url => url, :username => Instafavs::Config.instapaper_username,
:password => Instafavs::Config.instapaper_password })
end
end
- verbose("updating last run at timestamp")
- Instafavs::Config.last_update_run_at!(this_update_run_at)
+ verbose("updating config with #{seen_fav_ids.size} latest seen ids")
+ Instafavs::Config.update_last_seen_fav_ids!(seen_fav_ids)
end
def collect_config_info
config = {}
%w(twitter_username instapaper_username instapaper_password).each do |needed_value|
\ No newline at end of file