mirror of
https://github.com/iv-org/invidious.git
synced 2025-08-05 21:14:27 -04:00
Add constants for the Android client
This commit is contained in:
parent
933027f75f
commit
a2dc4fdc9a
1 changed files with 22 additions and 6 deletions
|
@ -5,9 +5,25 @@
|
||||||
module YoutubeAPI
|
module YoutubeAPI
|
||||||
extend self
|
extend self
|
||||||
|
|
||||||
# Hard-coded constants required by the API
|
# Enumerate used to select one of the clients supported by the API
|
||||||
HARDCODED_API_KEY = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8"
|
enum ClientType
|
||||||
HARDCODED_CLIENT_VERS = "2.20210330.08.00"
|
Web = 0
|
||||||
|
Android = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
# List of hard-coded values used by the different clients
|
||||||
|
HARDCODED_CLIENTS = {
|
||||||
|
ClientType::Web => {
|
||||||
|
name: "WEB",
|
||||||
|
version: "2.20210721.00.00",
|
||||||
|
api_key: "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8",
|
||||||
|
},
|
||||||
|
ClientType::Android => {
|
||||||
|
name: "ANDROID",
|
||||||
|
version: "16.20.35",
|
||||||
|
api_key: "AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
# make_context(region)
|
# make_context(region)
|
||||||
|
@ -20,8 +36,8 @@ module YoutubeAPI
|
||||||
"client" => {
|
"client" => {
|
||||||
"hl" => "en",
|
"hl" => "en",
|
||||||
"gl" => region || "US", # Can't be empty!
|
"gl" => region || "US", # Can't be empty!
|
||||||
"clientName" => "WEB",
|
"clientName" => HARDCODED_CLIENTS[0][:name],
|
||||||
"clientVersion" => HARDCODED_CLIENT_VERS,
|
"clientVersion" => HARDCODED_CLIENTS[0][:version],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -175,7 +191,7 @@ module YoutubeAPI
|
||||||
def _post_json(endpoint, data) : Hash(String, JSON::Any)
|
def _post_json(endpoint, data) : Hash(String, JSON::Any)
|
||||||
# Send the POST request and parse result
|
# Send the POST request and parse result
|
||||||
response = YT_POOL.client &.post(
|
response = YT_POOL.client &.post(
|
||||||
"#{endpoint}?key=#{HARDCODED_API_KEY}",
|
"#{endpoint}?key=#{HARDCODED_CLIENTS[0][:api_key]}",
|
||||||
headers: HTTP::Headers{"content-type" => "application/json; charset=UTF-8"},
|
headers: HTTP::Headers{"content-type" => "application/json; charset=UTF-8"},
|
||||||
body: data.to_json
|
body: data.to_json
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue