Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import os
- import requests
- TOKEN = "Bearer <TOKEN HERE>"
- def Merge(dict1, dict2):
- return(dict2.update(dict1))
- def combineJson(file_list):
- head = {}
- with open("result.json", "w") as outfile:
- for f in file_list:
- with open(f, 'rb') as infile:
- file_data = json.load(infile)
- Merge(file_data,head)
- infile.close()
- os.remove(f)
- json.dump(head, outfile)
- URL = "https://nz-tpy.np.community.playstation.net/trophy/v1/trophyTitles"
- Paramaters = {
- "fields":"@default,trophyTitleSmallIconUrl",
- "platform":"PS3,PS4,PSVITA",
- "limit":128,
- "offset":0,
- "comparedUser":"",
- "npLanguage":"en-GB"}
- Headers = {
- "authorization":TOKEN,
- "DNT":"1",
- "User-Agent":"Sony Hire Me Please!"
- }
- Paramaters["comparedUser"] = input("Enter ONLINE-ID: ")
- file_list = []
- i = 0
- #total = getLimit()
- while True:
- r = requests.get(url=URL,params=Paramaters,headers=Headers)
- if r.content.__contains__(b"error") or r.content.__contains__(b'"trophyTitles":[]}'):
- break
- print(r.text)
- open(str(i)+".json","wb").write(r.content)
- file_list.append(str(i)+".json")
- Paramaters["offset"] += 128
- i += 1
- combineJson(file_list)
Advertisement
Add Comment
Please, Sign In to add comment