Created
May 29, 2014 11:27
-
-
Save zaki/2567e4f69dfe38761c13 to your computer and use it in GitHub Desktop.
App store rankings for Dashing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
# Disclaimer: | |
# This is a quick hack to display ios app store rankings. It works for me. | |
# On your machine for all I know it could delete your hard drive, freeze your city's power grid, | |
# start WWIII, or even lock Australian people out of their iPhones, so use with caution. | |
require 'time' | |
require 'json' | |
# see genre codes here: https://www.apple.com/itunes/affiliates/resources/documentation/genre-mapping.html | |
# main country codes (sf=) | |
# JP: 143462 | |
# US: 143441 | |
# KR: 143466 | |
# CN: 143465 | |
def get_rank(genre) | |
country_code = 143462 | |
app_name = "My Little App" | |
rank = "園外" | |
rankings = JSON.parse(`curl "http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topfreeapplications/sf=#{country_code}/limit=100/genre=#{genre}/json" 2>/dev/null`) | |
rankings["feed"]["entry"].each_with_index {|x, i| rank = i+1 if x["im:name"]["label"] == app_name} | |
rank | |
end | |
SCHEDULER.every '1h' do | |
all_rank = get_rank(36) | |
games_rank = get_rank(6014) | |
sports_rank = get_rank(7016) | |
text = "総合無料:#{all_rank} / ゲーム無料:#{games_rank} / スポーツ無料: #{sports_rank}" | |
send_event('rankings', { text: text }) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment