From e2aa45bf3fe603430046a72bc9dc8cc572d16a11 Mon Sep 17 00:00:00 2001 From: flashwave Date: Fri, 12 Apr 2024 00:49:41 +0000 Subject: [PATCH] Revert "Attempt to circumvent Cloudflare on Oatmealdome's API..." This reverts commit b5b545ae7e092a7095d3f407d29edf379f6b2a32. --- src/SHttp.php | 29 ++++-------------------- src/Splatoon/Splatoon1/Splatoon1Game.php | 4 ++-- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/src/SHttp.php b/src/SHttp.php index 13ad905..10ec289 100644 --- a/src/SHttp.php +++ b/src/SHttp.php @@ -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, + CURLOPT_USERAGENT => sprintf('Satori/%s (+https://fii.moe/satori)', SAT_VERSION), + CURLOPT_HTTPHEADER => ['Accept: application/json'], ]); - - 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)); } } diff --git a/src/Splatoon/Splatoon1/Splatoon1Game.php b/src/Splatoon/Splatoon1/Splatoon1Game.php index a2d9ff5..3eaf84f 100644 --- a/src/Splatoon/Splatoon1/Splatoon1Game.php +++ b/src/Splatoon/Splatoon1/Splatoon1Game.php @@ -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; }