93 lines
2.6 KiB
Python
93 lines
2.6 KiB
Python
import requests
|
|
from tkinter import messagebox, filedialog
|
|
|
|
#TODAY WERE GOING TO BE PLANTING 20M TREES!!
|
|
|
|
url = f"https://rooms.rec.net/rooms/3294469977744509317/subrooms/4213066774192419012/data"
|
|
|
|
def get_recroom_auth():
|
|
import RecNet as rn
|
|
import jwt
|
|
import time
|
|
import webbrowser
|
|
|
|
testauth = rn.genAuthCode()
|
|
print("Please complete authentication in your browser:")
|
|
print(testauth.verificationUriComplete)
|
|
webbrowser.open(testauth.verificationUriComplete)
|
|
for _ in range(60):
|
|
test2 = rn.loginWithDeviceCode(testauth.deviceCode)
|
|
if test2.accessToken is not None:
|
|
token = jwt.decode(test2.accessToken, options={"verify_signature": False})
|
|
role = token.get("role")
|
|
betastudio = False
|
|
if isinstance(role, list):
|
|
if "betastudio" in role:
|
|
betastudio = True
|
|
elif role == "betastudio":
|
|
betastudio = True
|
|
if not betastudio:
|
|
raise Exception("Your account does not have access to Beta Studio.")
|
|
print(test2.accessToken)
|
|
print("Authenticated!")
|
|
return test2.accessToken
|
|
if test2.error != "authorization_pending":
|
|
raise Exception(f"Error: {test2.error}")
|
|
time.sleep(testauth.interval)
|
|
raise Exception("Login timed out or failed.")
|
|
|
|
|
|
try:
|
|
RR_AUTH = get_recroom_auth()
|
|
except Exception as e:
|
|
print(e)
|
|
exit(1)
|
|
|
|
|
|
def upload(file_type):
|
|
url = "https://storage.rec.net/upload"
|
|
payload = {'FileType': file_type}
|
|
|
|
file = filedialog.askopenfile("rb")
|
|
files = {"File": ("file.bin", file.read(), "application/octet-stream"), }
|
|
hasd = {
|
|
"User-Agent": "RRStudio",
|
|
"Authorization": f"Bearer {RR_AUTH}"
|
|
}
|
|
response = requests.post(url, headers=hasd, data=payload, files=files)
|
|
print(response.status_code)
|
|
print(response.text)
|
|
return response.json()
|
|
|
|
|
|
up = upload(1)
|
|
hash = up["hash"]
|
|
filename = up["filename"]
|
|
ownershipProof = up["ownershipProof"]
|
|
data1 = {
|
|
"UnityAssetId": None,
|
|
"UnityAsset": None,
|
|
"UnitySubAssets": [],
|
|
"ReferencedUnityAssetIds": None,
|
|
"RoomData": None,
|
|
"SubRoomData": {
|
|
"Filename": filename,
|
|
"Hash": hash,
|
|
"OwnershipProof": ownershipProof
|
|
},
|
|
"InventionUsage": "CAE=",
|
|
"PersistenceVersion": 190,
|
|
"OMVersion": 0,
|
|
"Description": None,
|
|
"AutoPublish": True,
|
|
"UgcSubVersion": 190
|
|
}
|
|
|
|
hasd = {
|
|
"User-Agent": "RRStudio",
|
|
"Authorization": f"Bearer {RR_AUTH}"
|
|
}
|
|
|
|
req = requests.request("POST", url, json=data1, headers=hasd)
|
|
|
|
print(req.text) |