Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- import time
- import threading
- class itemObj:
- def __init__(self):
- self.name = ''
- self.type = ''
- self.quant = 0
- self.iconURL = ''
- self.unitPrice = 0
- self.worth = 0
- self.inventoryID = ''
- def update(itemList, POESESSID, ACCOUNTNAME, LEAGUE, TABCOUNT, displayVars, UPDATETIME, lock):
- while True:
- # with lock:
- #lock.acquire()
- print('Updating...')
- # url call for tab count
- urlTabs = 'https://www.pathofexile.com/character-window/get-stash-items?league=' + \
- LEAGUE+'&tabs=0&accountName=' + ACCOUNTNAME
- response = requests.post(
- urlTabs, headers={'Cookie': 'POESESSID='+POESESSID})
- if response.status_code == 200:
- tabData = response.json()
- TABCOUNT = tabData['numTabs']
- # for testing
- # TABCOUNT = 2
- # print(TABCOUNT)
- # url call for each tab, compiling data into itemList
- for tab in range(TABCOUNT):
- url = 'https://www.pathofexile.com/character-window/get-stash-items?league=' + \
- LEAGUE+'&tabs=0&tabIndex=' + \
- str(tab)+'&accountName=' + ACCOUNTNAME
- # print(url)
- response = requests.post(
- url, headers={'Cookie': 'POESESSID='+POESESSID})
- # print(response.status_code)
- if response.status_code == 200:
- data = response.json()
- items = data['items'] # strips off currency tab info
- # print(items)
- for element in list(items):
- # print(element)
- newItem = itemObj()
- curName = element.get('name')
- if curName:
- newItem.name = curName
- newItem.type = element.get('typeLine')
- newItem.iconURL = element.get('icon')
- newItem.inventoryID = element.get('inventoryId')
- curquant = element.get('stackSize')
- if curquant:
- newItem.quant = curquant
- else:
- newItem.quant = 1
- itemList.append(newItem)
- # market data from compiled List
- # Div Cards
- url = 'https://poe.ninja/api/Data/GetDivinationCardsOverview?league='+LEAGUE
- response = requests.post(url)
- if response.status_code == 200:
- divData = response.json()
- for dEl in list(divData['lines']):
- for iEl in list(itemList):
- if iEl.type == dEl['name']:
- iEl.unitPrice = dEl['chaosValue']
- # Currency
- url = 'https://poe.ninja/api/Data/GetCurrencyOverview?league='+LEAGUE
- response = requests.post(url)
- if response.status_code == 200:
- cData = response.json()
- for cEl in list(cData['lines']):
- for iEl in list(itemList):
- if iEl.type == cEl['currencyTypeName']:
- iEl.unitPrice = cEl['chaosEquivalent']
- elif iEl.type == 'Chaos Orb':
- iEl.unitPrice = iEl.quant
- # Essences
- url = 'https://poe.ninja/api/Data/GetEssenceOverview?league='+LEAGUE
- response = requests.post(url)
- if response.status_code == 200:
- eData = response.json()
- for eEl in list(eData['lines']):
- for iEl in list(itemList):
- if iEl.type == eEl['name']:
- iEl.unitPrice = eEl['chaosValue']
- # Fragments
- url = 'https://poe.ninja/api/Data/GetFragmentOverview?league='+LEAGUE
- response = requests.post(url)
- if response.status_code == 200:
- fData = response.json()
- for fEl in list(fData['lines']):
- for iEl in list(itemList):
- if iEl.type == fEl['currencyTypeName']:
- iEl.unitPrice = fEl['chaosEquivalent']
- # Prophecies
- url = 'https://poe.ninja/api/Data/GetProphecyOverview?league='+LEAGUE
- response = requests.post(url)
- if response.status_code == 200:
- pData = response.json()
- for pEl in list(pData['lines']):
- for iEl in list(itemList):
- if iEl.type == pEl['name']:
- iEl.unitPrice = pEl['chaosValue']
- # Incubators
- # url = 'https://poe.ninja/api/Data/GetIncubatorOverview?league='+LEAGUE
- # response = requests.post(url)
- # if response.status_code == 200:
- # inData = response.json()
- #
- # for inEl in list(inData['lines']):
- # for iEl in list(itemList):
- # if iEl.type == inEl['name']:
- # iEl.unitPrice = inEl['chaosValue']
- # Scarabs
- # url = 'https://poe.ninja/api/Data/GetScarabOverview?league='+LEAGUE
- # response = requests.post(url)
- # if response.status_code == 200:
- # sData = response.json()
- #
- # for sEl in list(sData['lines']):
- # for iEl in list(itemList):
- # if iEl.type == sEl['name']:
- # iEl.unitPrice = sEl['chaosValue']
- # Maps
- url = 'https://poe.ninja/api/Data/GetMapOverview?league='+LEAGUE
- response = requests.post(url)
- if response.status_code == 200:
- mData = response.json()
- for mEl in list(mData['lines']):
- for iEl in list(itemList):
- if iEl.name == '':
- if iEl.type == mEl['name']:
- iEl.unitPrice = mEl['chaosValue']
- # Unique Armor
- url = 'https://poe.ninja/api/Data/GetUniqueArmourOverview?league='+LEAGUE
- response = requests.post(url)
- if response.status_code == 200:
- ufData = response.json()
- for ufEl in list(ufData['lines']):
- for iEl in list(itemList):
- if iEl.name == ufEl['name']:
- iEl.unitPrice = ufEl['chaosValue']
- # Unique Weapon
- url = 'https://poe.ninja/api/Data/GetUniqueWeaponOverview?league='+LEAGUE
- response = requests.post(url)
- if response.status_code == 200:
- ufData = response.json()
- for ufEl in list(ufData['lines']):
- for iEl in list(itemList):
- if iEl.name == ufEl['name']:
- iEl.unitPrice = ufEl['chaosValue']
- # Unique Flask
- url = 'https://poe.ninja/api/Data/GetUniqueFlaskOverview?league='+LEAGUE
- response = requests.post(url)
- if response.status_code == 200:
- ufData = response.json()
- for ufEl in list(ufData['lines']):
- for iEl in list(itemList):
- if iEl.name == ufEl['name']:
- iEl.unitPrice = ufEl['chaosValue']
- # Unique Accessory
- url = 'https://poe.ninja/api/Data/GetUniqueAccessoryOverview?league='+LEAGUE
- response = requests.post(url)
- if response.status_code == 200:
- ujcData = response.json()
- for ujcEl in list(ujcData['lines']):
- for iEl in list(itemList):
- if iEl.name == ujcEl['name']:
- iEl.unitPrice = ujcEl['chaosValue']
- # Unique Jewel
- url = 'https://poe.ninja/api/Data/GetUniqueJewelOverview?league='+LEAGUE
- response = requests.post(url)
- if response.status_code == 200:
- ujData = response.json()
- for ujEl in list(ujData['lines']):
- for iEl in list(itemList):
- if iEl.name == ujEl['name']:
- iEl.unitPrice = ujEl['chaosValue']
- # Unique Map
- url = 'https://poe.ninja/api/Data/GetUniqueMapOverview?league='+LEAGUE
- response = requests.post(url)
- if response.status_code == 200:
- umData = response.json()
- for umEl in list(umData['lines']):
- for iEl in list(itemList):
- if iEl.name == umEl['name']:
- iEl.unitPrice = umEl['chaosValue']
- #lock.release()
- print('Finished updating')
- output(itemList, displayVars, UPDATETIME)
- time.sleep(30)
- def output(itemList, displayVars, UPDATETIME):
- # Overall output
- if displayVars[0] == 'All':
- for el in list(itemList):
- print(el.name, el.type, el.quant, el.iconURL,
- el.unitPrice, el.inventoryID, sep="___")
- else:
- for dVar in list(displayVars):
- for el in list(itemList):
- if el.inventoryID == dVar:
- print(el.name, el.type, el.quant, el.iconURL,
- el.unitPrice, el.inventoryID, sep="___")
- UPDATETIME = time.strftime('%C')
- #print('Last updated: ' + UPDATETIME)
- def userInput(displayVars, itemList, UPDATETIME):
- while True:
- userin = input(
- 'Please enter stash tabs to display or EXIT(default All, format: "Stash1,Stash2...")--> ')
- displayVars = userin.split(',')
- if displayVars[0] == 'EXIT':
- endPgrm()
- output(itemList, displayVars, UPDATETIME)
- def endPgrm():
- exit()
- class inputThread(threading.Thread):
- def __init__(self, t, *args):
- threading.Thread.__init__(self, target=t, args=args)
- self.daemon = True
- self.start()
- class updateThread(threading.Thread):
- def __init__(self, t, *args):
- threading.Thread.__init__(self, target=t, args=args)
- self.daemon = True
- self.start()
- lock = threading.Lock()
- def main():
- # container of usable set items based off data
- itemList = []
- displayVars = ['All']
- POESESSID = "4c836125ea7ecaa0f843af5a5edf8107"
- ACCOUNTNAME = 'CzyPudu'
- LEAGUE = 'Legion'
- TABCOUNT = 0 # gets overwritten on first call
- UPDATETIME = ''
- inputThread(userInput(displayVars, itemList, UPDATETIME))
- updateThread(update(itemList, POESESSID, ACCOUNTNAME, LEAGUE, TABCOUNT, displayVars, UPDATETIME, lock))
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement