Пример #1
0
def gameslist_genres(genres):
	for i in range(len(genres)):
		result = igdb.genres({
			'ids': genres[i],
			'fields': 'games',
			})
		gameslist = []
		for game in result.body:
			gameslist.append(game['games'])
		gameslist = gameslist[0]
		return(gameslist)
Пример #2
0
def get_genres():
    print("getting genre data...")
    result = igdb.genres({ #there are only 20 genres

        'fields': "name",
        'limit':20
    })

    list_of_genres = []
    # xcount = result.headers["X-Count"]
    # print(xcount)
    # timestoscroll = (math.ceil((int(xcount)) / 20)) - 1
    # print(timestoscroll)
    for x in result.body:
        empty_dict = {}
        try:

            empty_dict["id"] = x["id"]
        except:
            empty_dict["id"] = ""
        try:
            empty_dict["name"] = x["name"]
        except:
            empty_dict["name"] = ""
        list_of_genres.append(empty_dict)


    # loaded_json = json.loads(newresult.text)
    dumped_json = json.dumps(list_of_genres, indent = 4)
    fw = open(genre_cache,"w")
    fw.write(dumped_json)
    fw.close()
    CACHE_DICTION["genre"] = time.strftime("%a %b %d %H:%M:%S %Y")
    dumped_json = json.dumps(CACHE_DICTION, indent = 4)
    fw = open(CACHE_FNAME,"w")
    fw.write(dumped_json)
    fw.close()
Пример #3
0
import json
from igdb_api_python.igdb import igdb as igdb
import time, os
import pymongo
from pymongo i1port MongoClient

client = MongoClient()
client = MongoClient('localhost', 27017)
db = client.gameDB
games = db.genres
#ENTER YOUR KEY HERE
igdb = igdb('a5b58ad9a031a212726ac14390047c4f')
data = {}
a = 0 ## La lista va en el #4899
for i in range(1):
        id_list = []
        b = a + 50
        for j in range(a, b):
                id_list.append(j)
        result = igdb.genres({
            'fields':['name'], #no se incluyo el summary
                'limit': 50,
                'ids': id_list
        })
        print(result.body)
        for game in result.body:
                print(game)
                games.insert(game)        

        a += 50