CoCalc Shared Filesnewupdate / getitem.pyOpen in CoCalc with one click!
Author: Gaz Lloyd
Views : 8
1
import requests
2
import json
3
4
index = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789*-"
5
6
def decode(s):
7
total = ""
8
for i in s:
9
total += '{:06b}'.format(index.index(i))
10
return int(total, 2)
11
12
def getstring(n):
13
id1 = "AEAAAADFO8ojAADKJADKJcomA*SXGgAAAAAAABAQyAAAAAAAAAAAAAAAAAAAAAANOQAAAA"
14
return encode(decode(id1)+(n)*2**(66*6))
15
16
def baseN(num,b,numerals="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789*-"):
17
return ((num == 0) and numerals[0]) or (baseN(num // b, b, numerals).lstrip(numerals[0]) + numerals[num % b])
18
19
def encode(n):
20
return "A" + baseN(n, 64)
21
22
def getitem(i):
23
try:
24
print("getting: " + str(i))
25
print("http://services.runescape.com/m=adventurers-log/avatardetails.json?details=" + getstring(i))
26
r = requests.get("http://services.runescape.com/m=adventurers-log/avatardetails.json?details=" + getstring(i))
27
content = r.json()
28
item = content['worn'][0]
29
if item == 'undefined':
30
return "undefined"
31
item['item_id'] = i
32
return content['worn'][0]
33
except:
34
return None