Silicaly

Untitled

Jan 5th, 2019
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. import json
  2. import os
  3. import requests
  4.  
  5. TOKEN = "Bearer <TOKEN HERE>"
  6.  
  7.  
  8. def Merge(dict1, dict2):
  9. return(dict2.update(dict1))
  10.  
  11. def combineJson(file_list):
  12. head = {}
  13. with open("result.json", "w") as outfile:
  14. for f in file_list:
  15. with open(f, 'rb') as infile:
  16. file_data = json.load(infile)
  17. Merge(file_data,head)
  18. infile.close()
  19. os.remove(f)
  20. json.dump(head, outfile)
  21.  
  22. URL = "https://nz-tpy.np.community.playstation.net/trophy/v1/trophyTitles"
  23.  
  24. Paramaters = {
  25. "fields":"@default,trophyTitleSmallIconUrl",
  26. "platform":"PS3,PS4,PSVITA",
  27. "limit":128,
  28. "offset":0,
  29. "comparedUser":"",
  30. "npLanguage":"en-GB"}
  31.  
  32. Headers = {
  33. "authorization":TOKEN,
  34. "DNT":"1",
  35. "User-Agent":"Sony Hire Me Please!"
  36. }
  37.  
  38. Paramaters["comparedUser"] = input("Enter ONLINE-ID: ")
  39.  
  40. file_list = []
  41. i = 0
  42.  
  43. #total = getLimit()
  44.  
  45. while True:
  46. r = requests.get(url=URL,params=Paramaters,headers=Headers)
  47. if r.content.__contains__(b"error") or r.content.__contains__(b'"trophyTitles":[]}'):
  48. break
  49. print(r.text)
  50. open(str(i)+".json","wb").write(r.content)
  51. file_list.append(str(i)+".json")
  52. Paramaters["offset"] += 128
  53. i += 1
  54.  
  55. combineJson(file_list)
Advertisement
Add Comment
Please, Sign In to add comment