Esempio n. 1
0
def ids(fav1, fav2, fav3):
	favgames = [fav1, fav2, fav3]
	id = []
	result = igdb.games({
		'search': fav1,
		'fields': 'id',
		})
	for game in result.body:
		id.append(game['id'])
		break

	result1 = igdb.games({
		'search': fav2,
		'fields': 'id',
		})
	for game in result1.body:
		id.append(game['id'])
		break

	result2 = igdb.games({
		'search': fav3,
		'fields': 'id',
		})
	for game in result2.body:
		id.append(game['id'])
		break

	return(id)
Esempio n. 2
0
def get_games_name(game_inp):
    #game_inp = input("Input a game to add to your list: ")
    #from SI364final import get_games
    #game_inp = get_games()
    result = igdb.games({'search': game_inp, 'fields': 'name'})
    r = []
    for game in result.body:
        r.append(game["name"])
    return r
Esempio n. 3
0
 def get(self, request):
     result = igdb.games({
         'filters': {
             '[platforms][any]': request.GET.get('platform_id'),
             '[slug][prefix]': slugify(request.GET.get('search'))
         },
         'fields': ['name', 'cover', 'platforms'],
         'limit': 50
     })
     return Response(result.body)
Esempio n. 4
0
def finalgames(gameslist):
	random.shuffle(gameslist)
	gameslist = gameslist[0:5]
	result = igdb.games ({
		"ids": gameslist,
		"fields": "name"
		})
	gnames = []
	for gamename in result.body:
		gnames.append(gamename["name"])
	return(gnames)
Esempio n. 5
0
def finalgames(gameslist):
    #gameslist1 = gameslist[0:len(gameslist):len(gameslist)//4]
    random.shuffle(gameslist)
    gameslist = gameslist[0:5]
    #gameslist1.append(gameslist[1:2])
    #gameslist1.append(gameslist[((len(gameslist)//2)-1), len(gameslist)//2])
    #gameslist1.append(gameslist[len(gameslist)-2, len(gameslist)-1])
    #gameslist1.append(gameslist[((len(gameslist)//3)-1), len(gameslist)//3])
    #gameslist1.append(gameslist[((len(gameslist)//4)-1), len(gameslist)//4])
    result = igdb.games({"ids": gameslist, "fields": "name"})
    gnames = []
    for gamename in result.body:
        gnames.append(gamename["name"])
    return (gnames)
Esempio n. 6
0
def get_release_date_by_plataform():
    global igdb
    plataform_release = []
    info = get_platforms()
    for info2 in info:
        id_plat = info2['id']
        result = igdb.release_dates({
            'filters': {
                "[platform][eq]": id_plat,
                "[date][gt]": int(round(time.time() * 1000)),
            },
            'order': "date:asc",
            'fields': "game"
        })
        for game in result.body:
            result2 = igdb.games(game['game'])
            for game in result2.body:
                for rls_date in game['release_dates']:
                    if rls_date['platform'] == id_plat:
                        if "region" in rls_date:
                            if rls_date['region'] == 2:
                                rl_date = time.strftime(
                                    '%Y-%m-%d',
                                    time.localtime(rls_date['date'] / 1000))
                                plataform_release.append({
                                    'plataform':
                                    info2['name'],
                                    'game':
                                    game['name'],
                                    'release_date':
                                    rl_date
                                })
                            # if rls_date['region'] == 1:
                            #     print "Europe release date: " + rls_date['human']
                            # elif rls_date['region'] == 2:
                            #     print "North America release date: " + rls_date['human']
                            # elif rls_date['region'] == 5:
                            #     print "Japan America release date: " + rls_date['human']
                            # elif rls_date['region'] == 8:
                            #     print "Worldwide release date: " + rls_date['human']
                            # else:
                            #     plataform_release.append(
                            #         {
                            #             'plataform': info2['name'],
                            #             'game': game['name'],
                            #             'release_date': "TBA"
                            #         }
                            #     )
    return plataform_release
Esempio n. 7
0
 async def igdb(self, ctx, *,  search):
     '''Search the Internet Game Database for a game.'''
     data = igdb.games({
         'search':"{}".format(search),
         'fields' : 'name'
         })
     
     IGDBEmbed = discord.Embed(
         colour = discord.Colour.green()
         )
     
     IGDBEmbed.set_author(name="Games:",icon_url='')
     for game in data.body:
         IGDBEmbed.add_field(name="Game name:", value=game['name'],inline= False)
     
     await self.bot.say(embed=IGDBEmbed)
Esempio n. 8
0
def bot():
    """The actual "twitter bot" that will use the mixer function above after grabbing a random game from the video game database
    and a random misconduct from a list and putting them into the mixer function. """
    random_game = random.randint(1, 109335)  ##grabs a random int
    result = igdb.games(random_game)  ##uses the random in as an id for a game
    for game in result.body:  ##this is how the api works to grab a game title, not fully sure how it works under the hood
        chosen_game = game["name"]  ##stores the game name as it's own variable
    misconduct_list = [
        "Overwork", "No Severence Pay", "Losing Sleep", "No Time For Family",
        "Pizza As Payment", "Test Monkey", "Under Paid", "No Healthcare",
        "100 Hour Weeks", "Lay Off", "Crunch", "Abuse of Power"
    ]  ##pretty self explanatory
    chosen_misconduct = misconduct_list[random.randint(
        0,
        len(misconduct_list) - 1)]  ##chooses something form the list at random
    return mixer(chosen_game,
                 chosen_misconduct)  ##calls the mixer function defined above
Esempio n. 9
0
def single_search(game_name):

    info = []
    result = igdb.games({
        'search':
        game_name,
        'fields': [
            "name", "summary", "storyline", "rating", "time_to_beat", "cover",
            "screenshots"
        ],
        'expand': ['developers', 'genres']
    })

    for field in result.body:
        info.append(field)

    return info
Esempio n. 10
0
def searchgames(request):
    key = request.GET.get('term', None)
    games = {}
    if key != None:
        key = key.strip()
        #print key
        result = igdb.games({
            'search': [key],
            'fields': ['name'],
            'limit': 10,
        })
        games = result.body
        # for game in games:
        # 	game['text'] = game.pop('name')

    return HttpResponse(json.dumps({
        'status': "success",
        "games": games
    }),
                        content_type="application/json")
Esempio n. 11
0
def get_all_games():
    """Makes API calls to get game information"""

    platforms = [
        130, 48, 49, 37, 46, 41, 5, 47, 56, 4, 21, 19, 18, 58, 20, 22, 33, 24,
        87, 7, 8, 9, 38, 45, 11, 12, 36, 92, 14, 6, 13, 64, 29, 35, 32, 23, 34,
        39, 86, 51, 15, 13, 79, 80, 119, 120, 135, 136
    ]
    # get the list of games per platform
    systems_json = igdb.platforms({'ids': platforms, 'fields': 'games'})
    # dump the data into a file
    with open('systemsfile2.json', 'w') as fp:
        json.dump(systems_json, fp)

    for platform_id in platforms:
        # loop through each platform and get the game info
        game_ids = igdb.platforms({
            'ids': platform_id,
            'fields': ['games', 'name']
        })[0]["games"]

        num_games = len(game_ids)

        num_iterations = (num_games / 1000) + 1
        fields = [
            'id', 'name', 'genres', 'storyline', 'summary', 'cover',
            'screenshots', 'videos'
        ]

        for i in range(num_iterations):

            platform_games = igdb.games({
                'ids':
                game_ids[i * 1000:i * 1000 + 1000],
                'fields': [
                    'id', 'name', 'genres', 'storyline', 'summary', 'cover',
                    'screenshots', 'videos'
                ]
            })
        with open('testfile' + str(platform_id) + '.json', 'w') as fp:
            json.dump(platform_games, fp)
Esempio n. 12
0
def genres(fav1, fav2, fav3, id):
	id = ids(fav1, fav2, fav3)
	k = 0
	genre = []
	for i in range(3):
		try:
			result = igdb.games({
			'ids': id[i],
			'fields': 'genres',
			})
			for game in result.body:
				genre.append(game['genres'])
		except:
			k += 1
			print("Unable to complete: " + str(id[i]))
	genres = []
	for elem in genre:
		for j in range (len(elem)):
			if elem[j] not in genres:
				genres.append(elem[j])
	return(genres)
Esempio n. 13
0
def keywords(id):
	k = 0
	keys = []
	for i in range(3):
		try:
			result = igdb.games({
			'ids': id[i],
			'fields': 'keywords',
			})
			for game in result.body:
				keys.append(game['keywords'])
		except:
			k += 1
			print("Unable to complete: " + str(id[i]))
	keys1 = []
	for elem in keys:
		for j in range (len(elem)):
			if elem[j] not in keys1:
				keys1.append(elem[j])
	random.shuffle(keys1)
	return(keys1[0:4])
    def handle(self, *args, **options):
        from igdb_api_python.igdb import igdb
        igdb = igdb('0cc499afcdb8b8076835350cd909f9f1')
        result = igdb.platforms({
            'ids': '6',
            'fields': 'games'
        })
        games = ast.literal_eval(result.content)
        games = [str(g) for g in games[0]['games']]

        i = 0
        content = []
        while i < 1000:
            result = igdb.games({
                'ids': games[i + 1:min(i + 1000, 23769)],
                'fields': ['name', 'first_release_date', 'url', 'cover', 'summary'],
            })
            content += (ast.literal_eval(result.content))
            i += 1000

        Game.objects.all().delete()
        for game in content:
            try:
                game['year'] = convert_release_date(game['first_release_date'])
                g = Game(id=game['id'], name=game['name'], year=game['year'], url = game['url'])
            except KeyError:
                g = Game(id=game['id'], name=game['name'], url = game['url'])
            try:
                if game['cover']['url'][0] == 'h':
                    g.cover_url = game['cover']['url'].replace('t_thumb','t_cover_big')
                else:
                    g.cover_url = 'https:' + game['cover']['url'].replace('t_thumb','t_cover_big')

            except KeyError:
                pass
            try:
                g.summary=game['summary']
            except KeyError:
                pass
            g.save()
Esempio n. 15
0
def get_new_games(to_add):
    """Make API calls to get game information"""

    for system, games in to_add.items():

        num_games = len(games)

        num_iterations = (num_games / 1000) + 1
        fields = [
            'id', 'name', 'genres', 'storyline', 'summary', 'cover',
            'screenshots', 'videos'
        ]

        for i in range(num_iterations):

            platform_games = igdb.games({
                'ids': games[i * 1000:i * 1000 + 1000],
                'fields': fields
            })

            for game in platform_games:
                add_games_to_database(game, system)
Esempio n. 16
0
def add_platform_filter(game_name, platform_name):

    result = igdb.games({'search': game_name, 'fields': ['name']})
    filter = igdb.platforms({'search': platform_name, 'filter': ['name']})
Esempio n. 17
0
def generate_search_list(game_name):

    result = igdb.games({'search': game_name, 'fields': ["name"], 'limit': 5})
    return result
Esempio n. 18
0
# Add User1 into the database
user1 = User(username="******", email="*****@*****.**",
             picture='static/img/black_user.GIF')
session.add(user1)
session.commit()
# Get 10 themes from the igdb api
result = igdb.themes({
    'ids': [18, 19, 20, 21, 22, 23, 27, 28, 31, 32]
})

counter = 1
# Iterate from one theme, get game_id from theme
for theme in result.body:
    for i in range(40):
        # Get properties from each game on that theme
        r = igdb.games(theme['games'][i])
        # Make sure the game we gather has all the properties we want
        if 'summary' not in r.body[0]:
            print "summary"
            continue
        if 'date' not in r.body[0]['release_dates'][0]:
            print "dates"
            continue
        else:
            # Add each game into database
            for game in r.body:
                game1 = Game(name=game['name'], cover=game['cover']['url'],
                             release_date=game['release_dates'][0]['human'],
                             release_date_number=game['release_dates'][0]['date'],
                             url=game['url'], user_id=1,
                             summary=game['summary'], theme_id=counter)
Esempio n. 19
0
def product_detail(request, id, slug):
    product = get_object_or_404(Product, id=id, slug=slug, available=True)
    cart_product_form = CartAddProductForm()
    result = igdb.games({
        'ids': [
            1942, 5503, 27081, 7346, 1905, 25657, 19565, 19560, 7331, 37777,
            26758, 25076, 359, 11156, 8173, 103054, 28540, 3750, 9498, 7334,
            9630, 11133, 9176, 76885, 12571, 11800, 19470, 36926, 7603, 19562
        ],
        'fields': ['cover', 'slug', 'name', 'summary', 'rating']
    })
    results = igdb.companies({'ids': [70, 168, 51], 'fields': 'name'})
    game1 = json.dumps(result.body[0]['summary'])
    games1 = json.loads(game1)
    game2 = json.dumps(result.body[1]['summary'])
    games2 = json.loads(game2)
    game3 = json.dumps(result.body[2]['summary'])
    games3 = json.loads(game3)
    game4 = json.dumps(result.body[3]['summary'])
    games4 = json.loads(game4)
    game5 = json.dumps(result.body[4]['summary'])
    games5 = json.loads(game5)
    game6 = json.dumps(result.body[5]['summary'])
    games6 = json.loads(game6)
    game7 = json.dumps(result.body[6]['summary'])
    games7 = json.loads(game7)
    game8 = json.dumps(result.body[7]['summary'])
    games8 = json.loads(game8)
    game9 = json.dumps(result.body[8]['summary'])
    games9 = json.loads(game9)
    game10 = json.dumps(result.body[9]['summary'])
    games10 = json.loads(game10)
    game11 = json.dumps(result.body[10]['summary'])
    games11 = json.loads(game11)
    game12 = json.dumps(result.body[11]['summary'])
    games12 = json.loads(game12)
    game13 = json.dumps(result.body[12]['summary'])
    games13 = json.loads(game13)
    game14 = json.dumps(result.body[13]['summary'])
    games14 = json.loads(game14)
    game15 = json.dumps(result.body[14]['summary'])
    games15 = json.loads(game15)
    game16 = json.dumps(result.body[15]['summary'])
    games16 = json.loads(game16)
    game17 = json.dumps(result.body[16]['summary'])
    games17 = json.loads(game17)
    game18 = json.dumps(result.body[17]['summary'])
    games18 = json.loads(game18)
    game19 = json.dumps(result.body[18]['summary'])
    games19 = json.loads(game19)
    game20 = json.dumps(result.body[19]['summary'])
    games20 = json.loads(game20)
    game21 = json.dumps(result.body[20]['summary'])
    games21 = json.loads(game21)
    game22 = json.dumps(result.body[21]['summary'])
    games22 = json.loads(game22)
    game23 = json.dumps(result.body[22]['summary'])
    games23 = json.loads(game23)
    game24 = json.dumps(result.body[23]['summary'])
    games24 = json.loads(game24)
    game25 = json.dumps(result.body[24]['summary'])
    games25 = json.loads(game25)
    game26 = json.dumps(result.body[25]['summary'])
    games26 = json.loads(game26)
    game27 = json.dumps(result.body[26]['summary'])
    games27 = json.loads(game27)
    game28 = json.dumps(result.body[27]['summary'])
    games28 = json.loads(game28)
    game29 = json.dumps(result.body[28]['summary'])
    games29 = json.loads(game29)
    game30 = json.dumps(result.body[29]['summary'])
    games30 = json.loads(game30)
    co1 = json.dumps(results.body[0]['name'])
    comp1 = json.loads(co1)
    co2 = json.dumps(results.body[1]['name'])
    comp2 = json.loads(co2)
    co3 = json.dumps(results.body[2]['name'])
    comp3 = json.loads(co3)
    return render(
        request, 'shop/product/detail.html', {
            'product': product,
            'cart_product_form': cart_product_form,
            'games1': games1,
            'games2': games2,
            'games3': games3,
            'games4': games4,
            'games5': games5,
            'games6': games6,
            'games7': games7,
            'games8': games8,
            'games9': games9,
            'games10': games10,
            'games11': games11,
            'games12': games12,
            'games13': games13,
            'games14': games14,
            'games15': games15,
            'games16': games16,
            'games17': games17,
            'games18': games18,
            'games19': games19,
            'games20': games20,
            'games21': games21,
            'games22': games22,
            'games23': games23,
            'games24': games24,
            'games25': games25,
            'games26': games26,
            'games27': games27,
            'games28': games28,
            'games29': games29,
            'games30': games30,
            'comp1': comp1,
            'comp2': comp2,
            'comp3': comp3,
        })
Esempio n. 20
0
from igdb_api_python.igdb import igdb

igdb = igdb("d6c559be64b7dc44efe1828bd44f85da")

result = igdb.games({'ids': [27193, 23212, 1942]})

for game in result.body:
    print("Retrieved: " + game["name"])
Esempio n. 21
0
import json
import os

#ids_list = [130, 87,99,33,22,19,58,21,4,5,159,20,37,41,137,18,24] #nintendo
#ids_list = [7, 8, 38, 46, 48, 9] #sony
#ids_list = [12, 11, 49] #microsoft
ids_list = [64, 29, 78, 35, 30, 32, 23]  #sega

for id in ids_list:
    result = igdb.platforms({
        # 'ids':[130, 87,99,33,22,19,58,21,4,5,159,20,37,41,137,18,24],
        'ids': [id],
        'fields': ['games', 'name']
    })

    platform_name = result.body[0]['name']

    if not os.path.exists(str('games_json/' + platform_name)):
        os.makedirs(str('games_json/' + platform_name))

    games_id = result.body[0]['games']
    for i in range(0, len(games_id), 100):

        result = igdb.games({'ids': games_id[i:i + 100]})

        for game in result.body:
            game_json = open(
                'games_json/' + platform_name + '/' +
                game['name'].replace('/', '_') + '.json', 'w')
            game_json.write(json.dumps(game, indent=4, sort_keys=True))
            game_json.close()
Esempio n. 22
0
def game_reviews(request):
    result = igdb.games({
        'ids': [
            1942, 5503, 27081, 7346, 1905, 25657, 19565, 19560, 7331, 37777,
            26758, 25076, 359, 11156, 8173, 103054, 28540, 3750, 9498, 7334,
            9630, 11133, 9176, 76885, 12571, 11800, 19470, 36926, 7603, 19562
        ],
        'fields': ['cover', 'slug', 'name', 'summary', 'rating']
    })
    game1 = json.dumps(result.body[0]['rating'])
    games1 = json.loads(game1)
    game2 = json.dumps(result.body[1]['rating'])
    games2 = json.loads(game2)
    game3 = json.dumps(result.body[2]['rating'])
    games3 = json.loads(game3)
    game4 = json.dumps(result.body[3]['rating'])
    games4 = json.loads(game4)
    game5 = json.dumps(result.body[4]['rating'])
    games5 = json.loads(game5)
    game6 = json.dumps(result.body[5]['rating'])
    games6 = json.loads(game6)
    game7 = json.dumps(result.body[6]['rating'])
    games7 = json.loads(game7)
    game8 = json.dumps(result.body[7]['rating'])
    games8 = json.loads(game8)
    game9 = json.dumps(result.body[8]['rating'])
    games9 = json.loads(game9)
    game10 = json.dumps(result.body[9]['rating'])
    games10 = json.loads(game10)
    game11 = json.dumps(result.body[10]['rating'])
    games11 = json.loads(game11)
    game12 = json.dumps(result.body[11]['rating'])
    games12 = json.loads(game12)
    game13 = json.dumps(result.body[12]['rating'])
    games13 = json.loads(game13)
    game14 = json.dumps(result.body[13]['rating'])
    games14 = json.loads(game14)
    game15 = json.dumps(result.body[14]['rating'])
    games15 = json.loads(game15)
    game16 = json.dumps(result.body[15]['rating'])
    games16 = json.loads(game16)
    game17 = json.dumps(result.body[16]['rating'])
    games17 = json.loads(game17)
    game18 = json.dumps(result.body[17]['rating'])
    games18 = json.loads(game18)
    game19 = json.dumps(result.body[18]['rating'])
    games19 = json.loads(game19)
    game20 = json.dumps(result.body[19]['rating'])
    games20 = json.loads(game20)
    game21 = json.dumps(result.body[20]['rating'])
    games21 = json.loads(game21)
    game22 = json.dumps(result.body[21]['rating'])
    games22 = json.loads(game22)
    game23 = json.dumps(result.body[22]['rating'])
    games23 = json.loads(game23)
    game24 = json.dumps(result.body[23]['rating'])
    games24 = json.loads(game24)
    game25 = json.dumps(result.body[24]['rating'])
    games25 = json.loads(game25)
    game26 = json.dumps(result.body[25]['rating'])
    games26 = json.loads(game26)
    game27 = json.dumps(result.body[26]['rating'])
    games27 = json.loads(game27)
    game28 = json.dumps(result.body[27]['rating'])
    games28 = json.loads(game28)
    game29 = json.dumps(result.body[28]['rating'])
    games29 = json.loads(game29)
    game30 = json.dumps(result.body[29]['rating'])
    games30 = json.loads(game30)
    gname1 = json.dumps(result.body[0]['name'])
    name1 = json.loads(gname1)
    gname2 = json.dumps(result.body[1]['name'])
    name2 = json.loads(gname2)
    gname3 = json.dumps(result.body[2]['name'])
    name3 = json.loads(gname3)
    gname4 = json.dumps(result.body[3]['name'])
    name4 = json.loads(gname4)
    gname5 = json.dumps(result.body[4]['name'])
    name5 = json.loads(gname5)
    gname6 = json.dumps(result.body[5]['name'])
    name6 = json.loads(gname6)
    gname7 = json.dumps(result.body[6]['name'])
    name7 = json.loads(gname7)
    gname8 = json.dumps(result.body[7]['name'])
    name8 = json.loads(gname8)
    gname9 = json.dumps(result.body[8]['name'])
    name9 = json.loads(gname9)
    gname10 = json.dumps(result.body[9]['name'])
    name10 = json.loads(gname10)
    gname11 = json.dumps(result.body[10]['name'])
    name11 = json.loads(gname11)
    gname12 = json.dumps(result.body[11]['name'])
    name12 = json.loads(gname12)
    gname13 = json.dumps(result.body[12]['name'])
    name13 = json.loads(gname13)
    gname14 = json.dumps(result.body[13]['name'])
    name14 = json.loads(gname14)
    gname15 = json.dumps(result.body[14]['name'])
    name15 = json.loads(gname15)
    gname16 = json.dumps(result.body[15]['name'])
    name16 = json.loads(gname16)
    gname17 = json.dumps(result.body[16]['name'])
    name17 = json.loads(gname17)
    gname18 = json.dumps(result.body[17]['name'])
    name18 = json.loads(gname18)
    gname19 = json.dumps(result.body[18]['name'])
    name19 = json.loads(gname19)
    gname20 = json.dumps(result.body[19]['name'])
    name20 = json.loads(gname20)
    gname21 = json.dumps(result.body[20]['name'])
    name21 = json.loads(gname21)
    gname22 = json.dumps(result.body[21]['name'])
    name22 = json.loads(gname22)
    gname23 = json.dumps(result.body[22]['name'])
    name23 = json.loads(gname23)
    gname24 = json.dumps(result.body[23]['name'])
    name24 = json.loads(gname24)
    gname25 = json.dumps(result.body[24]['name'])
    name25 = json.loads(gname25)
    gname26 = json.dumps(result.body[25]['name'])
    name26 = json.loads(gname26)
    gname27 = json.dumps(result.body[26]['name'])
    name27 = json.loads(gname27)
    gname28 = json.dumps(result.body[27]['name'])
    name28 = json.loads(gname28)
    gname29 = json.dumps(result.body[28]['name'])
    name29 = json.loads(gname29)
    gname30 = json.dumps(result.body[29]['name'])
    name30 = json.loads(gname30)
    return render(
        request, 'shop/product/reviews.html', {
            'games1': games1,
            'games2': games2,
            'games3': games3,
            'games4': games4,
            'games5': games5,
            'games6': games6,
            'games7': games7,
            'games8': games8,
            'games9': games9,
            'games10': games10,
            'games11': games11,
            'games12': games12,
            'games13': games13,
            'games14': games14,
            'games15': games15,
            'games16': games16,
            'games17': games17,
            'games18': games18,
            'games19': games19,
            'games20': games20,
            'games21': games21,
            'games22': games22,
            'games23': games23,
            'games24': games24,
            'games25': games25,
            'games26': games26,
            'games27': games27,
            'games28': games28,
            'games29': games29,
            'games30': games30,
            'name1': name1,
            'name2': name2,
            'name3': name3,
            'name4': name4,
            'name5': name5,
            'name6': name6,
            'name7': name7,
            'name8': name8,
            'name9': name9,
            'name10': name10,
            'name11': name11,
            'name12': name12,
            'name13': name13,
            'name14': name14,
            'name15': name15,
            'name16': name16,
            'name17': name17,
            'name18': name18,
            'name19': name19,
            'name20': name20,
            'name21': name21,
            'name22': name22,
            'name23': name23,
            'name24': name24,
            'name25': name25,
            'name26': name26,
            'name27': name27,
            'name28': name28,
            'name29': name29,
            'name30': name30,
        })
Esempio n. 23
0
def get_game(title):
    result = igdb.games({'search': title, 'fields': 'name'}).body[0]

    result = igdb.games({'ids': result['id'], 'expand': ['developers']})
    return result.body[0]
Esempio n. 24
0
igdb = igdb('f7274ba495a7897e39cc471d61b368aa')
data = {}
a_1 = 85116  ## La lista va en el #4926
a_2 = 88399
a = 0
game_list = []
for i in range(2200):
    id_list = []
    b = a + 50
    id_list.extend(range(a, b))
    result = igdb.games({
        'fields': [
            'id', 'name', 'genres', 'first_release_date', 'popularity',
            'total_rating', 'storyline', 'platforms', 'game_engines', 'hypes',
            'pegi', 'publishers', 'developers', 'keywords', 'game_modes',
            'player_perspectives'
        ],
        'limit':
        50,
        'ids':
        id_list
    })
    game_list.extend(result.body)
    if len(game_list) >= 1000:
        games.insert_many(game_list)
        game_list = []
    a += 50

if len(game_list):
    games.insert_many(game_list)

    # for game in result.body:
Esempio n. 25
0
import json
from igdb_api_python.igdb import igdb

igdb = igdb("CHAVE_DA_IPA")

for i in range (0, 100):
    result = igdb.games({
        'filters' :{
            "[summary][exists]": '',
            "[storyline][exists]": '',
            "[genres][exists]": '',
            "[themes][exists]": '',
            "[game_modes][exists]": '',
            "[player_perspectives][exists]": '',
            "[aggregated_rating][exists]": ''
        },
        'limit': 50,
        'offset': i*50,
        'order':"date:asc",
        'fields': [ 'summary',
                    'storyline',
                    'genres',
                    'themes',
                    'game_modes',
                    'player_perspectives',
                    'aggregated_rating'
                ]
    })
    filename = 'datasetigdb.json'
    with open(filename, 'a') as outfile:
        json.dump(result.body, outfile)
Esempio n. 26
0
def get_games_all():
    game_inp = input("Input a game to add to your list: ")
    result = igdb.games({'search': game_inp, 'fields': 'name'})
    print(result.body)
Esempio n. 27
0
def product_detail(request, id, slug):
    product = get_object_or_404(Product, id=id, slug=slug, available=True)
    cart_product_form = CartAddProductForm()

    #Overwatch (8713), RDR2 (25076), God of War (19560), BOTW (7346), Fortnite (1905)
    result = igdb.games({
        'ids': [8173, 25076, 19560, 7346, 1905],
        'fields': ['name', 'summary']
    })

    #overwatch dumps / loads
    ov_name_d = json.dumps(result.body[0]['name'])
    ov_name_l = json.loads(ov_name_d)
    ov_sum_d = json.dumps(result.body[0]['summary'])
    ov_sum_l = json.loads(ov_sum_d)
    ov_date = 'May 24 2016'

    #RDR2 dumps / loads
    rdr_name_d = json.dumps(result.body[1]['name'])
    rdr_name_l = json.loads(rdr_name_d)
    rdr_sum_d = json.dumps(result.body[1]['summary'])
    rdr_sum_l = json.loads(rdr_sum_d)
    rdr_date = "October 26th 2018"

    #GOW dumps / loads
    gow_name_d = json.dumps(result.body[2]['name'])
    gow_name_l = json.loads(gow_name_d)
    gow_sum_d = json.dumps(result.body[2]['summary'])
    gow_sum_l = json.loads(gow_sum_d)
    gow_date = "April 20th 2018"

    # BOTW dumps / loads

    botw_name_d = json.dumps(result.body[3]['name'])
    botw_name_l = json.loads(botw_name_d)
    botw_sum_d = json.dumps(result.body[3]['summary'])
    botw_sum_l = json.loads(botw_sum_d)
    botw_date = "March 3rd 2017"

    # Fortnite dumps / loads

    fort_name_d = json.dumps(result.body[4]['name'])
    fort_name_l = json.loads(fort_name_d)
    fort_sum_d = json.dumps(result.body[4]['summary'])
    fort_sum_l = json.loads(fort_sum_d)
    fort_date = "July 25 2017"

    #if statements

    if slug == 'fortnite':
        name = fort_name_l
        summary = fort_sum_l
        rel_date = fort_date
    elif slug == 'god-war':
        name = gow_name_l
        summary = gow_sum_l
        rel_date = gow_date
    elif slug == 'overwatch':
        name = ov_name_l
        summary = ov_sum_l
        rel_date = ov_date
    elif slug == 'red-dead-redemption-2':
        name = rdr_name_l
        summary = rdr_sum_l
        rel_date = rdr_date
    elif slug == 'zelda-breath-wild':
        name = botw_name_l
        summary = botw_sum_l
        rel_date = botw_date
    else:
        name = 'ERROR'
        summary = 'ERROR'
        rel_date = 'ERROR'

    return render(
        request, 'shop/product/detail.html', {
            'product': product,
            'cart_product_form': cart_product_form,
            'name': name,
            'summary': summary,
            'rel_date': rel_date
        })
Esempio n. 28
0
def Streaming(request, slug):

    stream_get = get_object_or_404(Stream, slug=slug)
    #Model availability:

    stream_model = Stream.objects.all()

    #twitch

    ov_vid_d = json.dumps(
        client.videos.get_top(1, 0, 'Overwatch', 'week', 'highlight')[0]['id'])
    ov_vid_l = json.loads(ov_vid_d)
    ov_vid_s = str(ov_vid_l)
    ov_vid_s = ov_vid_s.strip("v")
    ov_vid_url = "https://player.twitch.tv/?video=" + ov_vid_s + "&autoplay=false"

    rdr_vid_d = json.dumps(
        client.videos.get_top(1, 0, 'Red Dead Redemption 2', 'week',
                              'highlight')[0]['id'])
    rdr_vid_l = json.loads(rdr_vid_d)
    rdr_vid_s = str(rdr_vid_l)
    rdr_vid_s = rdr_vid_s.strip("v")
    rdr_vid_url = "https://player.twitch.tv/?video=" + rdr_vid_s + "&autoplay=false"

    gow_vid_d = json.dumps(
        client.videos.get_top(1, 0, 'God of War', 'week',
                              'highlight')[0]['id'])
    gow_vid_l = json.loads(gow_vid_d)
    gow_vid_s = str(gow_vid_l)
    gow_vid_s = gow_vid_s.strip("v")
    gow_vid_url = "https://player.twitch.tv/?video=" + gow_vid_s + "&autoplay=false"

    fort_vid_d = json.dumps(
        client.videos.get_top(1, 0, 'Fortnite', 'week', 'highlight')[0]['id'])
    fort_vid_l = json.loads(fort_vid_d)
    fort_vid_s = str(fort_vid_l)
    fort_vid_s = fort_vid_s.strip("v")
    fort_vid_url = "https://player.twitch.tv/?video=" + fort_vid_s + "&autoplay=false"

    botw_vid_d = json.dumps(
        client.videos.get_top(1, 0, 'The Legend of Zelda: Breath of the Wild',
                              'week', 'highlight')[0]['id'])
    botw_vid_l = json.loads(botw_vid_d)
    botw_vid_s = str(botw_vid_l)
    botw_vid_s = botw_vid_s.strip("v")
    botw_vid_url = "https://player.twitch.tv/?video=" + botw_vid_s + "&autoplay=false"

    #Overwatch (8713), RDR2 (25076), God of War (19560), BOTW (7346), Fortnite (1905)
    result = igdb.games({
        'ids': [8173, 25076, 19560, 7346, 1905],
        'expand':
        "developers",
        'fields': [
            'name', 'total_rating', 'total_rating_count', 'summary',
            'popularity', 'developers.name'
        ]
    })

    #overwatch dumps / loads
    ov_name_d = json.dumps(result.body[0]['name'])
    ov_name_l = json.loads(ov_name_d)
    ov_tr_d = json.dumps(result.body[0]['total_rating'])
    ov_tr_l = json.loads(ov_tr_d)
    ov_trc_d = json.dumps(result.body[0]['total_rating_count'])
    ov_trc_l = json.loads(ov_trc_d)
    ov_sum_d = json.dumps(result.body[0]['summary'])
    ov_sum_l = json.loads(ov_sum_d)
    ov_pop_d = json.dumps(result.body[0]['popularity'])
    ov_pop_l = json.loads(ov_pop_d)
    ov_dev_d = json.dumps(result.body[0]['developers'])
    ov_dev_l = json.loads(ov_dev_d)
    ov_date = 'May 24 2016'

    #overwatch input processing

    ov_tr_r = round(ov_tr_l)
    ov_trc_r = round(ov_trc_l)
    ov_pop_r = round(ov_pop_l)
    ov_dev_s = str(ov_dev_l)
    ov_dev_s = ov_dev_s.split(': ')
    ov_dev_s = str(ov_dev_s[2])
    ov_dev_s = ov_dev_s.strip("'}]")

    #RDR2 dumps / loads
    rdr_name_d = json.dumps(result.body[1]['name'])
    rdr_name_l = json.loads(rdr_name_d)
    rdr_tr_d = json.dumps(result.body[1]['total_rating'])
    rdr_tr_l = json.loads(rdr_tr_d)
    rdr_trc_d = json.dumps(result.body[1]['total_rating_count'])
    rdr_trc_l = json.loads(rdr_trc_d)
    rdr_sum_d = json.dumps(result.body[1]['summary'])
    rdr_sum_l = json.loads(rdr_sum_d)
    rdr_pop_d = json.dumps(result.body[1]['popularity'])
    rdr_pop_l = json.loads(rdr_pop_d)
    rdr_dev_d = json.dumps(result.body[1]['developers'])
    rdr_dev_l = json.loads(rdr_dev_d)
    rdr_date = "October 26th 2018"

    #RDR2 input processing

    rdr_tr_r = round(rdr_tr_l)
    rdr_trc_r = round(rdr_trc_l)
    rdr_pop_r = round(rdr_pop_l)
    rdr_dev_s = str(rdr_dev_l)
    rdr_dev_s = rdr_dev_s.split(': ')
    rdr_dev_s = str(rdr_dev_s[2])
    rdr_dev_s = rdr_dev_s.strip("'}]")

    #GOW dumps / loads
    gow_name_d = json.dumps(result.body[2]['name'])
    gow_name_l = json.loads(gow_name_d)
    gow_tr_d = json.dumps(result.body[2]['total_rating'])
    gow_tr_l = json.loads(gow_tr_d)
    gow_trc_d = json.dumps(result.body[2]['total_rating_count'])
    gow_trc_l = json.loads(gow_trc_d)
    gow_sum_d = json.dumps(result.body[2]['summary'])
    gow_sum_l = json.loads(gow_sum_d)
    gow_pop_d = json.dumps(result.body[2]['popularity'])
    gow_pop_l = json.loads(gow_pop_d)
    gow_dev_d = json.dumps(result.body[2]['developers'])
    gow_dev_l = json.loads(gow_dev_d)
    gow_date = "April 20th 2018"

    #GOW input processing

    gow_tr_r = round(gow_tr_l)
    gow_trc_r = round(gow_trc_l)
    gow_pop_r = round(gow_pop_l)
    gow_dev_s = str(gow_dev_l)
    gow_dev_s = gow_dev_s.split(': ')
    gow_dev_s = str(gow_dev_s[2])
    gow_dev_s = gow_dev_s.strip("'}]")

    # BOTW dumps / loads

    botw_name_d = json.dumps(result.body[3]['name'])
    botw_name_l = json.loads(botw_name_d)
    botw_tr_d = json.dumps(result.body[3]['total_rating'])
    botw_tr_l = json.loads(botw_tr_d)
    botw_trc_d = json.dumps(result.body[3]['total_rating_count'])
    botw_trc_l = json.loads(botw_trc_d)
    botw_sum_d = json.dumps(result.body[3]['summary'])
    botw_sum_l = json.loads(botw_sum_d)
    botw_pop_d = json.dumps(result.body[3]['popularity'])
    botw_pop_l = json.loads(botw_pop_d)
    botw_dev_d = json.dumps(result.body[3]['developers'])
    botw_dev_l = json.loads(botw_dev_d)
    botw_date = "March 3rd 2017"

    # BOTW input processing

    botw_tr_r = round(botw_tr_l)
    botw_trc_r = round(botw_trc_l)
    botw_pop_r = round(botw_pop_l)
    botw_dev_s = str(botw_dev_l)
    botw_dev_s = botw_dev_s.split(': ')
    botw_dev_s = str(botw_dev_s[2])
    botw_dev_s = botw_dev_s.strip("'}]")

    # Fortnite dumps / loads

    fort_name_d = json.dumps(result.body[4]['name'])
    fort_name_l = json.loads(fort_name_d)
    fort_tr_d = json.dumps(result.body[4]['total_rating'])
    fort_tr_l = json.loads(fort_tr_d)
    fort_trc_d = json.dumps(result.body[4]['total_rating_count'])
    fort_trc_l = json.loads(fort_trc_d)
    fort_sum_d = json.dumps(result.body[4]['summary'])
    fort_sum_l = json.loads(fort_sum_d)
    fort_pop_d = json.dumps(result.body[4]['popularity'])
    fort_pop_l = json.loads(fort_pop_d)
    fort_dev_d = json.dumps(result.body[4]['developers'])
    fort_dev_l = json.loads(fort_dev_d)
    fort_date = "July 25 2017"

    # Fortnite input processing

    fort_tr_r = round(fort_tr_l)
    fort_trc_r = round(fort_trc_l)
    fort_pop_r = round(fort_pop_l)
    fort_dev_s = str(fort_dev_l)
    fort_dev_s = fort_dev_s.split(': ')
    fort_dev_s = str(fort_dev_s[2])
    fort_dev_s = fort_dev_s.strip("'}]")

    #if statements

    if slug == 'fortnite':
        name = fort_name_l
        total_r = fort_tr_r
        total_rc = fort_trc_r
        summary = fort_sum_l
        popularity = fort_pop_r
        developer = fort_dev_s
        rel_date = fort_date
        url_link = fort_vid_url
    elif slug == 'god-war':
        name = gow_name_l
        total_r = gow_tr_r
        total_rc = gow_trc_r
        summary = gow_sum_l
        popularity = gow_pop_r
        developer = gow_dev_s
        rel_date = gow_date
        url_link = gow_vid_url
    elif slug == 'overwatch':
        name = ov_name_l
        total_r = ov_tr_r
        total_rc = ov_trc_r
        summary = ov_sum_l
        popularity = ov_pop_r
        developer = ov_dev_s
        rel_date = ov_date
        url_link = ov_vid_url
    elif slug == 'red-dead-redemption-2':
        name = rdr_name_l
        total_r = rdr_tr_r
        total_rc = rdr_trc_r
        summary = rdr_sum_l
        popularity = rdr_pop_r
        developer = rdr_dev_s
        rel_date = rdr_date
        url_link = rdr_vid_url
    elif slug == 'zelda-breath-wild':
        name = botw_name_l
        total_r = botw_tr_r
        total_rc = botw_trc_r
        summary = botw_sum_l
        popularity = botw_pop_r
        developer = botw_dev_s
        rel_date = botw_date
        url_link = botw_vid_url
    else:
        name = 'ERROR'
        total_r = 'ERROR'
        total_rc = 'ERROR'
        summary = 'ERROR'
        popularity = 'ERROR'
        developer = 'ERROR'
        rel_date = 'ERROR'
        url_link = 'ERROR'

    return render(
        request, 'videos.html', {
            'stream_get': stream_get,
            'stream_model': stream_model,
            'developer': developer,
            'name': name,
            'total_r': total_r,
            'total_rc': total_rc,
            'summary': summary,
            'rel_date': rel_date,
            'popularity': popularity,
            'url_link': url_link
        })