Last active
August 29, 2015 14:03
-
-
Save rafaelcgo/2f211135ba456f502687 to your computer and use it in GitHub Desktop.
Notificador de ingressos para a Copa do Mundo 2014
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
## CODIGO PARA CONSOLE JAVASCRIPT | |
# var t = setInterval(refreshAvailability_new, 5000) | |
# $(".catSelection").live('click', function() { | |
# console.log($(this).attr("id")) | |
# window.CATSELECTED = $(this).attr("id") | |
# console.log("Categoria Selecionada: " + window.CATSELECTED) | |
# }); | |
# $("#gen-btn-ok").on('click', function() { | |
# var quantity = 2; # DEFINA AQUI A QUANTIDADE DE INGRESSOS | |
# console.log("Ingresso Categoria: " + window.CATSELECTED) | |
# $("#" + window.CATSELECTED).click() | |
# $($("#selectable")[0]).find("li")[quantity-1].click() | |
# $("#btnAddToCart").click() | |
# }); | |
require 'net/http' | |
require 'json' | |
require 'openssl' | |
def playsound() | |
while true | |
# Mudei para esse outro som, mais alarmante. | |
6.times {|i| `afplay /System/Library/Sounds/Ping.aiff`} | |
sleep(2) | |
end | |
end | |
puts "Tocar som e parar de rodar ao achar ingresso? (s/n)" | |
case gets.chomp | |
when "s" | |
PARAR = true | |
when "n" | |
PARAR = false | |
else | |
PARAR = true | |
end | |
while true | |
begin | |
url = "https://fwctickets.fifa.com/TopsAkaCalls/Calls.aspx/getRefreshChartAvaDem?l=en&c=BRA" | |
uri = URI.parse "#{url}" | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
res = http.get(uri.request_uri) | |
data = JSON.parse(res.body) | |
parsed = JSON.parse(data["d"]["data"]) | |
found = false | |
# games = ['IMT47', 'IMT49', 'IMT55', 'IMT57', 'IMT58', 'IMT61', 'IMT62', 'IMT64'] | |
games = ['IMT47', 'IMT49', 'IMT55', 'IMT62', 'IMT64'] | |
categories = ['3', '4'] | |
ident = { | |
'IMT47' => 'BÉLGICA X CORÉIA DO SUL (SP)', | |
'IMT49' => 'OITAVAS (BRASIL X CHILE MG)', | |
'IMT55' => 'OITAVAS (ARGENTINA X SUIÇA SP)', | |
'IMT62' => 'SEMI (SP)', | |
'IMT64' => 'FINAL RJ' | |
} | |
parsed["BasicCodes"]["PRODUCTPRICES"].each do |game| | |
if games.include?(game["PRPProductId"]) and !['0', '-1'].include?(game["Quantity"]) and categories.include?(game["PRPCategoryId"]) | |
puts "(#{Time.now}) #{ident[game["PRPProductId"]]} #{game}" | |
puts | |
found = true | |
end | |
end | |
if found && PARAR | |
playsound | |
break | |
else | |
puts Time.now | |
sleep(5) | |
end | |
rescue | |
puts "Algo de errado está acontecendo..." | |
end | |
end |
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
Para MAC OS! (O som só funciona em MacOs) | |
Faça download do script. | |
Edite ele de acordo com suas necessidades (jogos, categorias) | |
Abra o terminal. | |
Vá até a pasta do script. | |
execute com: | |
ruby kurira_ticket_notifier.rb | |
Assim que o script encontrar qualquer ingresso dentro das suas configurações ele vai começar a apitar até que você mate-o (com ctrl+c). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment