Example #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
Example #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
Example #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
Example #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
Example #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!')
Example #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.')
Example #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.')
Example #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
Example #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