Revert "Attempt to circumvent Cloudflare on Oatmealdome's API..."
This reverts commit b5b545ae7e
.
This commit is contained in:
parent
b5b545ae7e
commit
e2aa45bf3f
2 changed files with 7 additions and 26 deletions
|
@ -2,7 +2,7 @@
|
|||
namespace Satori;
|
||||
|
||||
final class SHttp {
|
||||
public static function getJson(string $url, bool $pretendToBeFirefox = false): mixed {
|
||||
public static function getJson(string $url): mixed {
|
||||
$curl = curl_init($url);
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_AUTOREFERER => true,
|
||||
|
@ -17,35 +17,16 @@ final class SHttp {
|
|||
CURLOPT_REDIR_PROTOCOLS => CURLPROTO_HTTPS,
|
||||
CURLOPT_CONNECTTIMEOUT => 2,
|
||||
CURLOPT_TIMEOUT => 5,
|
||||
]);
|
||||
|
||||
if($pretendToBeFirefox) {
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0',
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
|
||||
'Accept-Language: en-GB,en;q=0.5',
|
||||
'Sec-Fetch-Dest: document',
|
||||
'Sec-Fetch-Mode: navigate',
|
||||
'Sec-Fetch-Site: none',
|
||||
'Sec-Fetch-User: ?1',
|
||||
'Upgrade-Insecure-Requests: 1',
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_USERAGENT => sprintf('Satori/%s (+https://fii.moe/satori)', SAT_VERSION),
|
||||
CURLOPT_HTTPHEADER => ['Accept: application/json'],
|
||||
]);
|
||||
}
|
||||
|
||||
$response = json_decode(curl_exec($curl), true);
|
||||
curl_close($curl);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public static function getJsonCached(string $url, bool $pretendToBeFirefox = false): mixed {
|
||||
return SFileCache::for15mins($url, fn() => self::getJson($url, $pretendToBeFirefox));
|
||||
public static function getJsonCached(string $url): mixed {
|
||||
return SFileCache::for15mins($url, fn() => self::getJson($url));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ class Splatoon1Game implements ISplatoonGame, ISplatoonHasSchedules {
|
|||
|
||||
public function createLocale(string $locale): ISplatoonLocale {
|
||||
return new Splatoon1Locale(
|
||||
SHttp::getJsonCached(sprintf(self::LOCALE_URL, $locale), true)
|
||||
SHttp::getJsonCached(sprintf(self::LOCALE_URL, $locale))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ class Splatoon1Game implements ISplatoonGame, ISplatoonHasSchedules {
|
|||
private ?array $rawSchedule = null;
|
||||
private function getRawScheduleData(): array {
|
||||
if($this->rawSchedule === null)
|
||||
$this->rawSchedule = SHttp::getJsonCached(self::SCHED_URL, true);
|
||||
$this->rawSchedule = SHttp::getJsonCached(self::SCHED_URL);
|
||||
|
||||
return $this->rawSchedule;
|
||||
}
|
||||
|
|
Reference in a new issue