def daily(): data = json.loads(fetchapi('https://gdbrowser.com/api/level/daily').read()) total = {} for i in range(0, len(list(data.keys()))): if list(data.keys())[i] == 'data': break total[list(data.keys())[i]] = data[list(data.keys())[i]] total = GDClass(total) return total
def analyze(levelid): if str(levelid).isnumeric() == False: raise ValueError('Requires level ID, not level name') else: data = json.loads( fetchapi('https://gdbrowser.com/api/analyze/' + str(levelid)).read()) total = GDClass(data) return total
def fetchProfile(inputs): data = json.loads( fetchapi('https://gdbrowser.com/api/profile/' + str(urlencode(inputs).replace('+', '%20'))).read()) try: temp = data.keys() except AttributeError: raise ConnectionRefusedError('User not found!') total = GDClass(data) return total
def levelSearch(query): encoded_query = urlencode(query).replace(" ", "%20") data = json.loads( fetchapi('https://gdbrowser.com/api/search/' + str(encoded_query)).read()) try: total = [] for a in range(0, len(data)): total.append(GDClass(data[a])) except: raise ConnectionRefusedError('Level not found') return total
def fetchLevel(levelid): data = json.loads( fetchapi('https://gdbrowser.com/api/level/' + str(levelid)).read()) total = {} try: for i in range(0, len(list(data.keys()))): if list(data.keys())[i] == 'data': break total[list(data.keys())[i]] = data[list(data.keys())[i]] total = GDClass(total) return total except AttributeError: raise ConnectionRefusedError('Level not found!')
def getProfilePosts(userid): if str(userid).isnumeric() == False: raise ValueError('Parameters (user ID) must be integer value.') try: data = json.loads( fetchapi('https://gdbrowser.com/api/comments/' + str(userid) + '?type=profile').read()) total = [] for a in range(0, len(data)): total.append(GDClass(data[a])) return total except: raise ConnectionRefusedError('Invalid User ID.')
def getFromLevel(levelid): if str(levelid).isnumeric() == False: raise ValueError( 'Parameters must be Level ID. (In an integer form)') try: data = json.loads( fetchapi('https://gdbrowser.com/api/comments/' + str(levelid) + '?top').read()) total = [] for a in range(0, len(data)): total.append(GDClass(data[a])) return total except: raise ValueError('Invalid Level ID.')
def topPlayers(count): if count > 5000: raise OverflowError('Too many!') elif count < 1: raise OverflowError('Too small!') else: data = json.loads( fetchapi('https://gdbrowser.com/api/leaderboard?count=' + str(count)).read()) try: total = [] for a in range(0, len(data)): total.append(GDClass(data[a])) except: raise ConnectionRefusedError('Invalid Query') return total
def topCreators(count): if count > 5000: raise OverflowError('Too many!') elif count < 1: raise OverflowError('Too small!') else: data = json.loads( fetchapi( 'https://gdbrowser.com/api/leaderboard?creator&count=' + str(count)).read()) try: total = [] for a in range(0, len(data)): total.append(GDClass(data[a])) return total except Exception as e: return e