-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
56 lines (51 loc) · 2.45 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from price import Price, ItemCantSellException, CalculationFormulaWrongException
from steam.api import get_inventory
from common.variables import config
from item import retrieve_items, hash_descriptions
import logging
from steam.exceptions import *
from requests.exceptions import RequestException
logger = logging.getLogger(__name__)
def start() -> None:
assets, descriptions = get_inventory(config.steam_id, config.app_id, config.context_id,
config.language, config.steam_login_secure)
descriptions = hash_descriptions(descriptions)
items = retrieve_items(assets, descriptions)
del assets, descriptions
total_sales = 0
for item in items:
if item.judge_can_sell():
try:
item.price = Price(item.appid, item.market_hash_name)
except LoginCookieExpiredException:
raise LoginCookieExpiredException
except (ApiDoesntReturnSuccessException, RequestException,
UnknownSteamErrorException, ApiDoesntReturnNeededParameterException):
continue
try:
item.price.calculate_price()
except ItemCantSellException:
logger.info(
"Item: %s, Asset ID: %s can't be sold Reason: orders not meet the config" %
(item.market_hash_name, item.assetid))
continue
except Exception:
raise CalculationFormulaWrongException
else:
if item.judge_price_can_sell():
logger.info("Item: %s, Asset ID: %s, Sell Price: %f" % (item.market_hash_name,
item.assetid,
item.price.sell_price))
item.sell_on_market()
total_sales += 1
else:
logger.info(
"Item: %s, Asset ID: %s can't be sold Reason: price not meet the config" %
(item.market_hash_name, item.assetid))
else:
logger.info(
"Item: %s, Asset ID: %s can't be sold Reason: not allowed in config" % (item.market_hash_name,
item.assetid))
logger.info("Total listed %d items" % total_sales)
if __name__ == '__main__':
start()