0.0.0.99
This commit is contained in:
parent
28fa4968fe
commit
a85b01621c
4 changed files with 69 additions and 15 deletions
|
@ -22,19 +22,27 @@ module Handlers
|
|||
end
|
||||
end
|
||||
end
|
||||
# badge_id = [] of String
|
||||
# badge_de = [] of String
|
||||
# badge_im = [] of String
|
||||
# badges_tuple[:bttv]?.try &.as_a.each do |item|
|
||||
# if !badge_id.includes?(item["badge"]["type"])
|
||||
# badge_id << item["badge"]["type"].to_s
|
||||
# badge_de << item["badge"]["description"].to_s
|
||||
# badge_im << item["badge"]["svg"].to_s
|
||||
# end
|
||||
# end
|
||||
# pp badge_id
|
||||
# pp badge_de
|
||||
# pp badge_im
|
||||
# j.field "bttv" do
|
||||
# j.object do
|
||||
# j.field "badges" do
|
||||
# j.array do
|
||||
# badges_tuple[:bttv]?.try &.as_a.each do |item|
|
||||
# badge_de.each do |badgename|
|
||||
# j.object do
|
||||
# j.field "id", item["id"]
|
||||
# j.field "name", item["name"]
|
||||
# j.field "displayName", item["displayName"]
|
||||
# j.field "providerId", item["providerId"]
|
||||
# j.field "svg", item["badge"]["svg"]
|
||||
# j.field "svg", item["badge"]["svg"]
|
||||
# j.field "svg", item["badge"]["svg"]
|
||||
# j.field "name", badgename
|
||||
# j.field "url", badgename
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
@ -88,9 +96,9 @@ module Handlers
|
|||
j.object do
|
||||
j.field "name", item["meta_title"]?
|
||||
j.field "badgeUrl", item["meta_url"]?
|
||||
j.field "url1x", item["image_url"]?
|
||||
j.field "url2x", item["image_url_2"]?
|
||||
j.field "url4x", item["image_url_4"]?
|
||||
j.field "url1x", "https:#{item["image_url"]?}"
|
||||
j.field "url2x", "https:#{item["image_url_2"]?}"
|
||||
j.field "url4x", "https:#{item["image_url_4"]?}"
|
||||
j.field "users", item["usernames"]?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,2 +1,45 @@
|
|||
module Providers::SevenTV
|
||||
extend self
|
||||
def get_user_id(user_id : String)
|
||||
res = HTTP::Client.get("https://7tv.io/v3/users/twitch/#{user_id}", headers: HEADERS)
|
||||
JSON.parse(res.body)
|
||||
end
|
||||
|
||||
def get_user_cosmetics(user_id : String)
|
||||
query = %q(
|
||||
query GetUserCosmetics($id: ObjectID!) {
|
||||
user(id: $id) {
|
||||
id
|
||||
cosmetics {
|
||||
id
|
||||
kind
|
||||
selected
|
||||
__typename
|
||||
}
|
||||
__typename
|
||||
}
|
||||
}
|
||||
)
|
||||
data = JSON.build do |j|
|
||||
j.object do
|
||||
j.field "operationName", "GetUserCosmetics"
|
||||
j.field "variables" do
|
||||
j.object do
|
||||
j.field "id", user_id
|
||||
end
|
||||
end
|
||||
j.field "query", query
|
||||
end
|
||||
end
|
||||
headers = HTTP::Headers{
|
||||
"Content-Type" => "application/json",
|
||||
}
|
||||
response = HTTP::Client.post("https://7tv.io/v3/gql", headers: headers, body: data)
|
||||
|
||||
if response.success?
|
||||
(response.body)
|
||||
else
|
||||
raise "7tv is retarded #{response.status_code}: #{response.body}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,7 +23,8 @@ module Providers
|
|||
ffz: info[2].receive,
|
||||
dankchat: info[3].receive,
|
||||
chatty: info[4].receive,
|
||||
bttv: info[1].receive,
|
||||
}
|
||||
return items
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,8 +17,10 @@ REDIS_DB = Redis::Client.new(CONFIG.redisUrl)
|
|||
|
||||
HEADERS = HTTP::Headers{"User-Agent" => "Vanity-Tester-Backend/0.1.0"}
|
||||
|
||||
get "/badges" do |env|
|
||||
Handlers.parse_badges(env)
|
||||
end
|
||||
# get "/badges" do |env|
|
||||
# Handlers.parse_badges(env)
|
||||
# end
|
||||
|
||||
Providers::SevenTV.get_user_cosmetics("60ae872eac03cad60747208d")
|
||||
|
||||
Kemal.run
|
||||
|
|
Loading…
Add table
Reference in a new issue