-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Facepunch changing something with EXPO, use their endpoint now
- Loading branch information
1 parent
d843075
commit 55ea0af
Showing
2 changed files
with
13 additions
and
39 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,22 @@ | ||
import requests | ||
import logging | ||
import json | ||
from datetime import datetime | ||
|
||
|
||
class MagicValueGrabber: | ||
@staticmethod | ||
def get_magic_value() -> int: | ||
try: | ||
data = requests.get( | ||
"https://exp.host/@facepunch/RustCompanion", | ||
headers={ | ||
"Exponent-SDK-Version": "40.0.0", # These are the two lines that determine the version of data that | ||
"Exponent-Version": "0.0.29", # you receive as far as I can tell from my limited debugging. As of | ||
# now (8th April 2022), this is the latest | ||
"Exponent-Platform": "android", | ||
"Accept": "application/expo+json,application/json", | ||
"Expo-Release-Channel": "default", | ||
"Expo-Api-Version": "1", | ||
"Expo-Client-Environment": "STANDALONE", | ||
"Exponent-Accept-Signature": "true", | ||
"Expo-JSON-Error": "true", | ||
"Host": "exp.host", | ||
"User-Agent": "okhttp/3.12.1", | ||
}, | ||
) | ||
|
||
halves = ( | ||
str(json.loads(data.json()["manifestString"])["publishedTime"]) | ||
.replace("Z", "") | ||
.split("T") | ||
) | ||
data = requests.get( | ||
"https://companion-rust.facepunch.com/api/version" | ||
) | ||
|
||
year, month, day = halves[0].split("-") | ||
hour, minute, second = halves[1].split(":") | ||
if data.status_code == 200: | ||
data = data.json() | ||
time = data.get("minPublishedTime", None) | ||
if time is not None: | ||
return time + 1 | ||
|
||
dt = datetime(int(year), int(month), int(day), int(hour), int(minute), 0) | ||
|
||
return int( | ||
((dt - datetime.utcfromtimestamp(0)).total_seconds() * 1000.0) | ||
+ float(second) * 1000 | ||
) | ||
except Exception: | ||
logging.getLogger("rustplus.py").warning( | ||
"[Rustplus.py] Failed to get magic value from RustPlus Server" | ||
) | ||
return 1641359159846 | ||
logging.getLogger("rustplus.py").warning( | ||
"[Rustplus.py] Failed to get magic value from RustPlus Server" | ||
) | ||
return 9999999999999 |