Closed jam-time closed 7 years ago
'insert code' didn't work above, but all but the first line is supposed to be in the code
which wiki page is this supposed to go on? Might also be cleaner to submit a pastebin code snippet just in case the issue tracker messes with the code formatting.
It's for the python section of this section:
http://destinydevs.github.io/BungieNetPlatform/docs/Manifest
Really there's only a few differences here and there, mainly, but it's enough of a difference to be annoying to switch it all over.
There's the python 3.X code
Added this code to the Manifest page. Sorry for the delay, it slipped my mind!
I redid the code to work in 3.X, in the event someone might want it. `#All of these imports used, if the code is broken down into several sections like it is on the wiki,
might not make sense to include all of them at the beginning, but will save time for new devs
import requests import zipfile import os import pickle import json import sqlite3
def get_manifest(): manifest_url = 'http://www.bungie.net/Platform/Destiny/Manifest/'
hashes = { 'DestinyActivityDefinition': 'activityHash', 'DestinyActivityTypeDefinition': 'activityTypeHash', 'DestinyClassDefinition': 'classHash', 'DestinyGenderDefinition': 'genderHash', 'DestinyInventoryBucketDefinition': 'bucketHash', 'DestinyInventoryItemDefinition': 'itemHash', 'DestinyProgressionDefinition': 'progressionHash', 'DestinyRaceDefinition': 'raceHash', 'DestinyTalentGridDefinition': 'gridHash', 'DestinyUnlockFlagDefinition': 'flagHash', 'DestinyHistoricalStatsDefinition': 'statId', 'DestinyDirectorBookDefinition': 'bookHash', 'DestinyStatDefinition': 'statHash', 'DestinySandboxPerkDefinition': 'perkHash', 'DestinyDestinationDefinition': 'destinationHash', 'DestinyPlaceDefinition': 'placeHash', 'DestinyActivityBundleDefinition': 'bundleHash', 'DestinyStatGroupDefinition': 'statGroupHash', 'DestinySpecialEventDefinition': 'eventHash', 'DestinyFactionDefinition': 'factionHash', 'DestinyVendorCategoryDefinition': 'categoryHash', 'DestinyEnemyRaceDefinition': 'raceHash', 'DestinyScriptedSkullDefinition': 'skullHash', 'DestinyGrimoireCardDefinition': 'cardId' }
hashes_trunc = { 'DestinyInventoryItemDefinition': 'itemHash', 'DestinyTalentGridDefinition': 'gridHash', 'DestinyHistoricalStatsDefinition': 'statId', 'DestinyStatDefinition': 'statHash', 'DestinySandboxPerkDefinition': 'perkHash', 'DestinyStatGroupDefinition': 'statGroupHash' }
def build_dict(hash_dict):
connect to the manifest
check if pickle exists, if not create one.
if os.path.isfile(r'path\to\file\manifest.content') == False: get_manifest()
all_data = build_dict(hashes) with open('manifest.pickle', 'wb') as data: pickle.dump(all_data, data) print("'manifest.pickle' created!\nDONE!") else: print('Pickle Exists')
with open('manifest.pickle', 'rb') as data: all_data = pickle.load(data)
hash = 1274330687 ghorn = all_data['DestinyInventoryItemDefinition'][hash]
print('Name: '+ghorn['itemName']) print('Type: '+ghorn['itemTypeName']) print('Tier: '+ghorn['tierTypeName']) print(ghorn['itemDescription'])`