Skip to content

Instantly share code, notes, and snippets.

@alikrc
Created December 27, 2020 18:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alikrc/31e6a47d58f0a343289290de558faeee to your computer and use it in GitHub Desktop.
Save alikrc/31e6a47d58f0a343289290de558faeee to your computer and use it in GitHub Desktop.
python script for pulling and saving your vault data to a json file. Also saves vault items ordered by rating
import requests
import json
import math
elementsList = []
itemPerPage = 100
epicClientSessionCookieValue = 'EPIC_CLIENT_SESSION_COOKIE_HERE'
epicSSOCookieValue = "EPIC_SSO_COOKIE_HERE"
pageStartItemNo = 1
templateUrl = 'https://www.unrealengine.com/marketplace/api/assets/vault?lang=en-US&count={itemPerPage}&start={pageStartItemNo}'
requestUrl = templateUrl.format(itemPerPage=itemPerPage,
pageStartItemNo=pageStartItemNo)
cookies = dict(EPIC_CLIENT_SESSION=epicClientSessionCookieValue,
EPIC_SSO=epicSSOCookieValue)
response = requests.get(requestUrl, cookies=cookies)
# https://www.unrealengine.com/marketplace/api/assets/vault?lang=en-US&start=0&count=100
def addElementsToDic(elements):
for elementItem in elements:
order = len(elementsList) + 1
if not 'rating' in elementItem:
continue
elementsList.append({
"order": order,
"title": elementItem["title"],
"rating": elementItem["rating"]["total"]
})
pass
pass
data = response.json()["data"]
elements = data["elements"]
addElementsToDic(elements)
totalItemCount = data["paging"]["total"] # 477
totalPageCount = math.floor(totalItemCount / itemPerPage) + 1
for i in range(1, totalPageCount + 1):
pageStartItemNo = i * itemPerPage + 1
requestUrl = templateUrl.format(itemPerPage=itemPerPage,
pageStartItemNo=pageStartItemNo)
response = requests.get(requestUrl, cookies=cookies)
data = response.json()["data"]
elements = data["elements"]
addElementsToDic(elements)
pass
with open('ueVault.json', 'w', encoding='utf-8') as f:
json.dump(elementsList, f, ensure_ascii=False, indent=4)
with open('ueVaultSortedByRating.json', 'w', encoding='utf-8') as f:
elementsList.sort(key=lambda k: k['rating'], reverse=True)
json.dump(elementsList, f, ensure_ascii=False, indent=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment