Skip to content

Instantly share code, notes, and snippets.

@tknzk
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tknzk/413e1c104c7f6a98c792 to your computer and use it in GitHub Desktop.
Save tknzk/413e1c104c7f6a98c792 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'feed-normalizer'
require 'open-uri'
require 'twitter'
client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV['TWITTER_CONSUMER_KEY']
config.consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
config.access_token = ENV['TWITTER_ACCESS_TOKEN']
config.access_token_secret = ENV['TWITTER_ACCESS_TOKEN_SECRET']
end
uri_jazz_song_rank = 'https://itunes.apple.com/jp/rss/topsongs/limit=100/genre=11/xml'
feed = FeedNormalizer::FeedNormalizer.parse open(uri_jazz_song_rank)
text = ""
itunes_url = "https://itunes.apple.com/jp/album/rakurai/id887425587?i=887425634"
i = 1
feed.entries.each { |e|
if e.title == "rakurai - YAPANI!"
text = "現在 iTunes Jazz チャート #{i}位 " + e.title + " #{itunes_url}" + " updated_at:" + e.last_updated.strftime("%Y-%m-%d %H:%M:%S %Z")
client.update(text)
break
end
i+=1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment