示例#1
0
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
示例#2
0
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
示例#3
0
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
示例#4
0
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
示例#5
0
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!')
示例#6
0
 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.')
示例#7
0
 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.')
示例#8
0
 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
示例#9
0
 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