import requests


def merge_items(items: list[dict], descriptions: dict, **kwargs) -> dict:
    merged_items = {}
    for item in items:
        description_key = get_description_key(item)
        if 'description_key' in descriptions:
            description = copy.copy(descriptions[description_key])
            item_id = item.get('id') or item['assetid']
            description['contextid'] = item.get('contextid') or kwargs['context_id']
            description['id'] = item_id
            description['amount'] = item['amount']
            merged_items[item_id] = description
        return merged_items
    return merged_items


def get_description_key(item: dict) -> str:
    return item['classid'] + '_' + item['instanceid']

def merge_items_with_descriptions_from_offer(offer: dict, descriptions: dict) -> dict:
    merged_items_to_give = merge_items(offer.get('items_to_give', []), descriptions)
    #print(merged_items_to_give)
    merged_items_to_receive = merge_items(offer.get('items_to_receive', []), descriptions)
    offer['items_to_give'] = merged_items_to_give
    offer['items_to_receive'] = merged_items_to_receive
    return offer


def merge_items_with_descriptions_from_offers(offers_response: dict) -> dict:
    descriptions = {get_description_key(offer): offer for offer in offers_response['response'].get('descriptions', [])}
    received_offers = offers_response['response'].get('trade_offers_received', [])
    sent_offers = offers_response['response'].get('trade_offers_sent', [])
    offers_response['response']['trade_offers_received'] = list(map(lambda offer: merge_items_with_descriptions_from_offer(offer, descriptions), received_offers))
    offers_response['response']['trade_offers_sent'] = list(map(lambda offer: merge_items_with_descriptions_from_offer(offer, descriptions), sent_offers))
    print(offers_response)
    return offers_response


#merge_items_with_descriptions_from_offers(offers_response)





def get_items_to_receive(offer):
    names = []
    for id in offer['items_to_receive']:
        name = (offer['items_to_receive'][str(id)]["name"])
        names.append(name)
    print(names)
    return names


def get_items_to_give(self, offer):
    names = []
    for id in offer['items_to_give']:
        name = (offer['items_to_give'][str(id)]["name"])
        names.append(name)
    return names



#===========
def get_description_key_from_offer(item: dict) -> str: #Получаю айди предметов из оффера
    return item['classid'] + '_' + item['instanceid']


def get_name_and_descriptions_key_form_descriptions(response:dict): #Получаю предметы и их айди из описания
    data_items = {}
    response = response['response']['descriptions']
    for item in response:
        data_items[f"{item['classid']}_{item['instanceid']}"] = item['market_hash_name']
        #data_items[item['market_hash_name']] = f"{item['classid']}_{item['instanceid']}"
    return data_items

def merge_data(items_to_someside):
    merge = []
    for item in items_to_someside:
        item_key = get_description_key_from_offer(item)
        merge.append(item_key)
    return merge

def get_trade_offers(response:dict):
    description = get_name_and_descriptions_key_form_descriptions(response)
    if 'trade_offers_received' in response['response']:
        response_received =  response['response']['trade_offers_received']
        for trade in response_received:
            if 'items_to_give' in trade:
                items_to_give = merge_data(trade['items_to_give'])
                squared_to_give = map(lambda num2: description[num2] if num2 in description else None, items_to_give)

            if 'items_to_receive' in trade:
                items_to_receive = merge_data(trade['items_to_receive'])
                squared_to_receive = map(lambda num2: description[num2] if num2 in description else None,items_to_receive)
            trade['items_to_give'] = list(squared_to_give)
            trade['items_to_receive'] = list(squared_to_receive)

    if 'trade_offers_sent' in response['response']:
        response_sent =  response['response']['trade_offers_sent']
        for trade in response_sent:
            if 'items_to_give' in trade:
                items_to_give = merge_data(trade['items_to_give'])
                squared_to_give = map(lambda num2: description[num2] if num2 in description else None, items_to_give)

            if 'items_to_receive' in trade:
                items_to_receive = merge_data(trade['items_to_receive'])
                squared_to_receive = map(lambda num2: description[num2] if num2 in description else None, items_to_receive)
            trade['items_to_give'] = list(squared_to_give)
            trade['items_to_receive'] = list(squared_to_receive)
    return response


def counter_items(lst: list):
    items_list = []
    temp = list(map(lambda x: x, lst))
    if lst != []:
        for item in set(temp):
            items_list.append(f'Item: {item}| Quantity: {temp.count(item)}')
        return '\n'.join(items_list)
    return (f'Empty!')
orig_resp = {'response': {'trade_offers_sent': [{'tradeofferid': '5347387106', 'accountid_other': 1076066642, 'message': '', 'expiration_time': 1660252749, 'trade_offer_state': 9, 'items_to_give': [{'appid': 440, 'contextid': '2', 'assetid': '8114421493', 'classid': '414905317', 'instanceid': '0', 'amount': '1', 'missing': False, 'est_usd': '6'}, {'appid': 440, 'contextid': '2', 'assetid': '8114419982', 'classid': '22989188', 'instanceid': '0', 'amount': '1', 'missing': False}], 'is_our_offer': True, 'time_created': 1659043149, 'time_updated': 1659043149, 'from_real_time_trade': False, 'escrow_end_date': 0, 'confirmation_method': 2}], 'trade_offers_received': [{'tradeofferid': '5347239778', 'accountid_other': 1076066642, 'message': '', 'expiration_time': 1660243338, 'trade_offer_state': 2, 'items_to_give': [{'appid': 570, 'contextid': '2', 'assetid': '17661823923', 'classid': '124465408', 'instanceid': '3516050722', 'amount': '1', 'missing': False, 'est_usd': '0'}], 'items_to_receive': [{'appid': 730, 'contextid': '2', 'assetid': '26561714037', 'classid': '3946324730', 'instanceid': '0', 'amount': '1', 'missing': False, 'est_usd': '12'}, {'appid': 730, 'contextid': '2', 'assetid': '26579907238', 'classid': '1989288278', 'instanceid': '302028390', 'amount': '1', 'missing': False, 'est_usd': '1'}], 'is_our_offer': False, 'time_created': 1659033738, 'time_updated': 1659033744, 'from_real_time_trade': False, 'escrow_end_date': 0, 'confirmation_method': 2}, {'tradeofferid': '5347238449', 'accountid_other': 1076066642, 'message': '', 'expiration_time': 1660243268, 'trade_offer_state': 2, 'items_to_give': [{'appid': 440, 'contextid': '2', 'assetid': '8062097438', 'classid': '2675', 'instanceid': '11040547', 'amount': '1', 'missing': False}, {'appid': 440, 'contextid': '2', 'assetid': '8076269923', 'classid': '2675', 'instanceid': '11040547', 'amount': '1', 'missing': False}, {'appid': 440, 'contextid': '2', 'assetid': '8076269910', 'classid': '2675', 'instanceid': '11040547', 'amount': '1', 'missing': False}, {'appid': 440, 'contextid': '2', 'assetid': '8021100640', 'classid': '3131324361', 'instanceid': '3474171410', 'amount': '1', 'missing': False}], 'items_to_receive': [{'appid': 730, 'contextid': '2', 'assetid': '23394864618', 'classid': '4571592702', 'instanceid': '519977179', 'amount': '1', 'missing': False, 'est_usd': '7'}, {'appid': 730, 'contextid': '2', 'assetid': '20558922550', 'classid': '3761545285', 'instanceid': '0', 'amount': '1', 'missing': False, 'est_usd': '15'}, {'appid': 730, 'contextid': '2', 'assetid': '26340161911', 'classid': '1989284558', 'instanceid': '302028390', 'amount': '1', 'missing': False, 'est_usd': '1'}], 'is_our_offer': False, 'time_created': 1659033668, 'time_updated': 1659033681, 'from_real_time_trade': False, 'escrow_end_date': 0, 'confirmation_method': 2}], 'descriptions': [{'appid': 440, 'classid': '414905317', 'instanceid': '0', 'currency': False, 'background_color': '3C352E', 'icon_url': 'fWFc82js0fmoRAP-qOIPu5THSWqfSmTELLqcUywGkijVjZULUrsm1j-9xgEIfgYFWCT0uSpKidzvAvyzBOESnN97ssQAi2VpxFR6MuKxZGNkc1CSVqILDfc7ol_qXn5k7J8yDIDi9u9TehKv6tXyIw0bbw', 'icon_url_large': 'fWFc82js0fmoRAP-qOIPu5THSWqfSmTELLqcUywGkijVjZULUrsm1j-9xgEIfgYFWCT0uSpKidzvAvyzBOESnN97ssQAi2VpxFR6MuKxZGNkc1CSVqILDfc7ol_qXn5k7J8yDIDi9u9TehKv6tXyIw0bbw', 'descriptions': [{'type': 'text', 'value': 'Crate Series #82', 'color': '7ea9d1'}, {'type': 'text', 'value': 'You need a Mann Co. Supply Crate Key to open this.\nYou can pick one up at the Mann Co. Store.'}, {'type': 'text', 'value': ' '}, {'type': 'text', 'value': 'This crate contains one of the following items:'}, {'type': 'text', 'value': "    Pretty Boy's Pocket Pistol Strangifier", 'color': '6F6A63'}, {'type': 'text', 'value': '    Phlogistinator Strangifier', 'color': '6F6A63'}, {'type': 'text', 'value': "    Cleaner's Carbine Strangifier", 'color': '6F6A63'}, {'type': 'text', 'value': '    Strange Cosmetic Part: Kills', 'color': '6F6A63'}, {'type': 'text', 'value': '    Strange Part: Full Health Kills', 'color': '6F6A63'}, {'type': 'text', 'value': '    Strange Part: Headshot Kills', 'color': '6F6A63'}, {'type': 'text', 'value': '    Private Eye Strangifier', 'color': '6F6A63'}, {'type': 'text', 'value': '    Big Chief Strangifier', 'color': '6F6A63'}, {'type': 'text', 'value': 'or an Exceedingly Rare Series #3 Unusual Hat!', 'color': '7ea9d1'}], 'tradable': True, 'actions': [{'link': 'http://wiki.teamfortress.com/scripts/itemredirect.php?id=5734&lang=en_US', 'name': 'Item Wiki Page...'}], 'name': 'Mann Co. Supply Munition Series #82', 'name_color': '7D6D00', 'type': 'Level 20 Supply Crate', 'market_name': 'Mann Co. Supply Munition Series #82', 'market_hash_name': 'Mann Co. Supply Munition Series #82', 'commodity': True, 'market_tradable_restriction': 7, 'market_marketable_restriction': 0, 'marketable': True, 'tags': [{'category': 'Quality', 'internal_name': 'Unique', 'localized_category_name': 'Quality', 'localized_tag_name': 'Unique', 'color': '7D6D00'}, {'category': 'Type', 'internal_name': 'Supply Crate', 'localized_category_name': 'Type', 'localized_tag_name': 'Crate'}]}, {'appid': 440, 'classid': '22989188', 'instanceid': '0', 'currency': False, 'background_color': '3C352E', 'icon_url': 'fWFc82js0fmoRAP-qOIPu5THSWqfSmTELLqcUywGkijVjZULUrsm1j-9xgEFYw4CWBbjsz1Rt9DrDOGzBOESnN97t8QGiGM6yAMtNruxZTYwdAfGB_gPDfZjpAu8W3E0vpEyVtTn8u8DKBKv6tWDEmB72Q', 'icon_url_large': 'fWFc82js0fmoRAP-qOIPu5THSWqfSmTELLqcUywGkijVjZULUrsm1j-9xgEFYw4CWBbjsz1Rt9DrDOGzBOESnN97t8QGiGM6yAMtNruxZTYwdAfGB_gPDfZjpAu8W3E0vpEyVtTn8u8DKBKv6tWDEmB72Q', 'descriptions': [{'type': 'text', 'value': 'Holiday Restriction: Smissmas', 'color': 'd83636'}, {'type': 'text', 'value': 'Unlimited use', 'color': '7ea9d1'}], 'tradable': True, 'actions': [{'link': 'http://wiki.teamfortress.com/scripts/itemredirect.php?id=673&lang=en_US', 'name': 'Item Wiki Page...'}], 'name': 'Noise Maker - Winter Holiday', 'name_color': '7D6D00', 'type': 'Level 5 Party Favor', 'market_name': 'Noise Maker - Winter Holiday', 'market_hash_name': 'Noise Maker - Winter Holiday', 'commodity': False, 'market_tradable_restriction': 7, 'market_marketable_restriction': 0, 'marketable': False, 'tags': [{'category': 'Quality', 'internal_name': 'Unique', 'localized_category_name': 'Quality', 'localized_tag_name': 'Unique', 'color': '7D6D00'}, {'category': 'Type', 'internal_name': 'TF_Party_Favor', 'localized_category_name': 'Type', 'localized_tag_name': 'Party Favor'}, {'category': 'Class', 'internal_name': 'Scout', 'localized_category_name': 'Class', 'localized_tag_name': 'Scout'}, {'category': 'Class', 'internal_name': 'Sniper', 'localized_category_name': 'Class', 'localized_tag_name': 'Sniper'}, {'category': 'Class', 'internal_name': 'Soldier', 'localized_category_name': 'Class', 'localized_tag_name': 'Soldier'}, {'category': 'Class', 'internal_name': 'Demoman', 'localized_category_name': 'Class', 'localized_tag_name': 'Demoman'}, {'category': 'Class', 'internal_name': 'Medic', 'localized_category_name': 'Class', 'localized_tag_name': 'Medic'}, {'category': 'Class', 'internal_name': 'Heavy', 'localized_category_name': 'Class', 'localized_tag_name': 'Heavy'}, {'category': 'Class', 'internal_name': 'Pyro', 'localized_category_name': 'Class', 'localized_tag_name': 'Pyro'}, {'category': 'Class', 'internal_name': 'Spy', 'localized_category_name': 'Class', 'localized_tag_name': 'Spy'}, {'category': 'Class', 'internal_name': 'Engineer', 'localized_category_name': 'Class', 'localized_tag_name': 'Engineer'}]}, {'appid': 730, 'classid': '1989288278', 'instanceid': '302028390', 'currency': False, 'background_color': '', 'icon_url': 'IzMF03bi9WpSBq-S-ekoE33L-iLqGFHVaU25ZzQNQcXdB2ozio1RrlIWFK3UfvMYB8UsvjiMXojflsZalyxSh31CIyHz2GZ-KuFpPsrTzBG0pO-CI3r-Zj3FYSeJGA44TOJfYW7YqjD2sOXHQjrKQO0uRAAHK6tR-mEdPsvbO0Zo3YUVu2u_0UdyEhk6f9BKZAarxm1OMLh9m3IWnUinsHM', 'icon_url_large': 'IzMF03bi9WpSBq-S-ekoE33L-iLqGFHVaU25ZzQNQcXdB2ozio1RrlIWFK3UfvMYB8UsvjiMXojflsZalyxSh31CIyHz2GZ-KuFpPsrTzBG0pO-CI3r-Zj3FEC3YDlltU-UKN2rd9zSj4-_FFm3JFOskFw9SdfRR9WBKaJyNOhdpgdIP8me8xBMzDhgvNMZJfACpx2EfJbQ1xDhPJM5amiekLeroQJw', 'descriptions': [{'type': 'html', 'value': 'This is a sealed container of a graffiti pattern. Once this graffiti pattern is unsealed, it will provide you with enough charges to apply the graffiti pattern <b>50</b> times to the in-game world.'}, {'type': 'html', 'value': ' '}, {'type': 'html', 'value': '', 'color': '00a000'}], 'tradable': True, 'actions': [{'link': 'steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S%owner_steamid%A%assetid%D11998334476892957610', 'name': 'Inspect in Game...'}], 'name': 'Sealed Graffiti | Ninja (Desert Amber)', 'name_color': 'D2D2D2', 'type': 'Base Grade Graffiti', 'market_name': 'Sealed Graffiti | Ninja (Desert Amber)', 'market_hash_name': 'Sealed Graffiti | Ninja (Desert Amber)', 'market_actions': [{'link': 'steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D11998334476892957610', 'name': 'Inspect in Game...'}], 'commodity': True, 'market_tradable_restriction': 7, 'marketable': True, 'tags': [{'category': 'Type', 'internal_name': 'CSGO_Type_Spray', 'localized_category_name': 'Type', 'localized_tag_name': 'Graffiti'}, {'category': 'Quality', 'internal_name': 'normal', 'localized_category_name': 'Category', 'localized_tag_name': 'Normal'}, {'category': 'Rarity', 'internal_name': 'Rarity_Common', 'localized_category_name': 'Quality', 'localized_tag_name': 'Base Grade', 'color': 'b0c3d9'}, {'category': 'SprayColorCategory', 'internal_name': 'Tint5', 'localized_category_name': 'Graffiti Color', 'localized_tag_name': 'Desert Amber'}]}, {'appid': 730, 'classid': '3946324730', 'instanceid': '0', 'currency': False, 'background_color': '', 'icon_url': '-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXU5A1PIYQNqhpOSV-fRPasw8rsUFJ5KBFZv668FFU2nfGaJG0btN2wwYHfxa-hY-uFxj4Dv50nj7uXpI7w3AewrhBpMWH6d9CLMlhpEbAe-Zk', 'icon_url_large': '', 'descriptions': [{'type': 'html', 'value': ' '}, {'type': 'html', 'value': 'Container Series #307', 'color': '99ccff'}, {'type': 'html', 'value': ' '}, {'type': 'html', 'value': 'Contains one of the following:'}, {'type': 'html', 'value': 'Negev | Ultralight', 'color': '4b69ff'}, {'type': 'html', 'value': 'P2000 | Gnarled', 'color': '4b69ff'}, {'type': 'html', 'value': "SG 553 | Ol' Rusty", 'color': '4b69ff'}, {'type': 'html', 'value': 'SSG 08 | Mainframe 001', 'color': '4b69ff'}, {'type': 'html', 'value': 'P250 | Cassette', 'color': '4b69ff'}, {'type': 'html', 'value': 'P90 | Freight', 'color': '4b69ff'}, {'type': 'html', 'value': 'PP-Bizon | Runic', 'color': '4b69ff'}, {'type': 'html', 'value': 'MAG-7 | Monster Call', 'color': '8847ff'}, {'type': 'html', 'value': 'Tec-9 | Brother', 'color': '8847ff'}, {'type': 'html', 'value': 'MAC-10 | Allure', 'color': '8847ff'}, {'type': 'html', 'value': 'Galil AR | Connexion', 'color': '8847ff'}, {'type': 'html', 'value': 'MP5-SD | Kitbash', 'color': '8847ff'}, {'type': 'html', 'value': 'M4A4 | Tooth Fairy', 'color': 'd32ce6'}, {'type': 'html', 'value': 'Glock-18 | Vogue', 'color': 'd32ce6'}, {'type': 'html', 'value': 'XM1014 | Entombed', 'color': 'd32ce6'}, {'type': 'html', 'value': 'Desert Eagle | Printstream', 'color': 'eb4b4b'}, {'type': 'html', 'value': 'AK-47 | Legion of Anubis', 'color': 'eb4b4b'}, {'type': 'html', 'value': 'or an Exceedingly Rare Special Item!', 'color': 'ffd700'}, {'type': 'html', 'value': ' '}, {'type': 'html', 'value': '', 'color': '00a000'}], 'tradable': True, 'name': 'Fracture Case', 'name_color': 'D2D2D2', 'type': 'Base Grade Container', 'market_name': 'Fracture Case', 'market_hash_name': 'Fracture Case', 'commodity': True, 'market_tradable_restriction': 7, 'marketable': True, 'tags': [{'category': 'Type', 'internal_name': 'CSGO_Type_WeaponCase', 'localized_category_name': 'Type', 'localized_tag_name': 'Container'}, {'category': 'ItemSet', 'internal_name': 'set_community_26', 'localized_category_name': 'Collection', 'localized_tag_name': 'The Fracture Collection'}, {'category': 'Quality', 'internal_name': 'normal', 'localized_category_name': 'Category', 'localized_tag_name': 'Normal'}, {'category': 'Rarity', 'internal_name': 'Rarity_Common', 'localized_category_name': 'Quality', 'localized_tag_name': 'Base Grade', 'color': 'b0c3d9'}], 'market_buy_country_restriction': 'FR'}, {'appid': 570, 'classid': '124465408', 'instanceid': '3516050722', 'currency': False, 'background_color': '', 'icon_url': '-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KW1Zwwo4NUX4oFJZEHLbXK9QlSPcUgvBlUT0efVeuv0vDBRl99Jg9ouL-yFAphwPjbYi4N_tO0kb-ZgvX9MLDumG5G18hwmeLS5p-73AHh8xJkYDr1IdSRdAU8Z1mBrFHvkO7p0Z-7vs7NznVl6HYn5Cranwv3309Z17qXzQ', 'icon_url_large': '-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KW1Zwwo4NUX4oFJZEHLbXK9QlSPcUgvBlUT0efVeuv0vDBRl99Jg9ouL-yFAphwPjbYi4N_tO0kb-ZgvX9MLDumG5G18hwmeLS5p_KhFWmrBZyaz_7JdTGJgI6YA6Cr1frlLvvgcPqvZnPyyYys3Rw4y2Oy0C0gRFOOvsv26Iel8IqPw', 'descriptions': [{'type': 'html', 'value': 'Used By: Rubick'}, {'type': 'html', 'value': ' '}, {'type': 'html', 'value': "Councilor's Raiment", 'color': '9da1a9'}, {'type': 'html', 'value': "Councilor's Shawl", 'color': '6c7075'}, {'type': 'html', 'value': "Councilor's Staff", 'color': '6c7075'}, {'type': 'html', 'value': "Councilor's Robe", 'color': '6c7075'}, {'type': 'html', 'value': "Councilor's Mask", 'color': '6c7075'}, {'type': 'html', 'value': 'To be at once a Magus, a duelist, and an aspiring politician requires a robe that is both stately and blast proof.'}], 'tradable': True, 'name': "Councilor's Robe", 'name_color': 'D2D2D2', 'type': 'Uncommon Robe', 'market_name': "Councilor's Robe", 'market_hash_name': "Councilor's Robe", 'commodity': False, 'market_tradable_restriction': 7, 'market_marketable_restriction': 0, 'marketable': True, 'tags': [{'category': 'Quality', 'internal_name': 'unique', 'localized_category_name': 'Quality', 'localized_tag_name': 'Standard', 'color': 'D2D2D2'}, {'category': 'Rarity', 'internal_name': 'Rarity_Uncommon', 'localized_category_name': 'Rarity', 'localized_tag_name': 'Uncommon', 'color': '5e98d9'}, {'category': 'Type', 'internal_name': 'wearable', 'localized_category_name': 'Type', 'localized_tag_name': 'Wearable'}, {'category': 'Slot', 'internal_name': 'back', 'localized_category_name': 'Slot', 'localized_tag_name': 'Back'}, {'category': 'Hero', 'internal_name': 'npc_dota_hero_rubick', 'localized_category_name': 'Hero', 'localized_tag_name': 'Rubick'}]}, {'appid': 730, 'classid': '1989284558', 'instanceid': '302028390', 'currency': False, 'background_color': '', 'icon_url': 'IzMF03bi9WpSBq-S-ekoE33L-iLqGFHVaU25ZzQNQcXdB2ozio1RrlIWFK3UfvMYB8UsvjiMXojflsZalyxSh31CIyHz2GZ-KuFpPsrTzBG0puWyTCW5aWOSKXaATwlpTeBcN2iI9zWl4-TCETrBEuAvRFtSKKYGo2dMa8uAbQx9itAdqGq0mFZwCxo8e9VKaVLvkiwVae3oZoz1zg', 'icon_url_large': 'IzMF03bi9WpSBq-S-ekoE33L-iLqGFHVaU25ZzQNQcXdB2ozio1RrlIWFK3UfvMYB8UsvjiMXojflsZalyxSh31CIyHz2GZ-KuFpPsrTzBG0puWyTCXIZDbWKCSXT1oxSLteYTrbqzvx4-mUSzzIEugvEQgDL6MFoGVIO8iMbBNsgIIC8iuomUM7HRkkfddLZQOvw2QfKOBxkHkUfZsrH6Veyw', 'descriptions': [{'type': 'html', 'value': 'This is a sealed container of a graffiti pattern. Once this graffiti pattern is unsealed, it will provide you with enough charges to apply the graffiti pattern <b>50</b> times to the in-game world.'}, {'type': 'html', 'value': ' '}, {'type': 'html', 'value': '', 'color': '00a000'}], 'tradable': True, 'actions': [{'link': 'steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S%owner_steamid%A%assetid%D9695869443785130990', 'name': 'Inspect in Game...'}], 'name': 'Sealed Graffiti | GGEZ (Frog Green)', 'name_color': 'D2D2D2', 'type': 'Base Grade Graffiti', 'market_name': 'Sealed Graffiti | GGEZ (Frog Green)', 'market_hash_name': 'Sealed Graffiti | GGEZ (Frog Green)', 'market_actions': [{'link': 'steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D9695869443785130990', 'name': 'Inspect in Game...'}], 'commodity': True, 'market_tradable_restriction': 7, 'marketable': True, 'tags': [{'category': 'Type', 'internal_name': 'CSGO_Type_Spray', 'localized_category_name': 'Type', 'localized_tag_name': 'Graffiti'}, {'category': 'Quality', 'internal_name': 'normal', 'localized_category_name': 'Category', 'localized_tag_name': 'Normal'}, {'category': 'Rarity', 'internal_name': 'Rarity_Common', 'localized_category_name': 'Quality', 'localized_tag_name': 'Base Grade', 'color': 'b0c3d9'}, {'category': 'SprayColorCategory', 'internal_name': 'Tint9', 'localized_category_name': 'Graffiti Color', 'localized_tag_name': 'Frog Green'}]}, {'appid': 730, 'classid': '4571592702', 'instanceid': '519977179', 'currency': False, 'background_color': '', 'icon_url': '-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXH5ApeO4YmlhxYQknCRvCo04DEVlxkKgpotLO_JAlf2-r3fTRY7c6yq5OAnvnLP7LWnn8fvJIi2-qW893x2gXl8kU_Z2D0JYKVd1c5Y1qD-Ve3wO-9hMK-v8yYnGwj5Hf5oKjMrQ', 'icon_url_large': '-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXH5ApeO4YmlhxYQknCRvCo04DEVlxkKgpotLO_JAlf2-r3fTRY7c6yq5OAnvnLP7LWnn9u5MRjjeyPodum2VfjrUI4YWjyLYDGdg85YFzQ_wC5w-y8hpC1vZybyCZhuXFzsGGdwULyqHHt-w', 'descriptions': [{'type': 'html', 'value': 'Exterior: Factory New'}, {'type': 'html', 'value': ' '}, {'type': 'html', 'value': 'The Bizon SMG is low-damage, but offers a uniquely designed high-capacity drum magazine that reloads quickly. A green and black hydrographic lizard scale pattern has been applied.\n\n<i>Painted to scale</i>'}, {'type': 'html', 'value': ' '}, {'type': 'html', 'value': 'The 2021 Mirage Collection', 'color': '9da1a9'}, {'type': 'html', 'value': ' '}], 'tradable': True, 'actions': [{'link': 'steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S%owner_steamid%A%assetid%D11982990393346035928', 'name': 'Inspect in Game...'}], 'name': 'PP-Bizon | Anolis', 'name_color': 'D2D2D2', 'type': 'Consumer Grade SMG', 'market_name': 'PP-Bizon | Anolis (Factory New)', 'market_hash_name': 'PP-Bizon | Anolis (Factory New)', 'market_actions': [{'link': 'steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D11982990393346035928', 'name': 'Inspect in Game...'}], 'commodity': False, 'market_tradable_restriction': 7, 'marketable': True, 'tags': [{'category': 'Type', 'internal_name': 'CSGO_Type_SMG', 'localized_category_name': 'Type', 'localized_tag_name': 'SMG'}, {'category': 'Weapon', 'internal_name': 'weapon_bizon', 'localized_category_name': 'Weapon', 'localized_tag_name': 'PP-Bizon'}, {'category': 'ItemSet', 'internal_name': 'set_mirage_2021', 'localized_category_name': 'Collection', 'localized_tag_name': 'The 2021 Mirage Collection'}, {'category': 'Quality', 'internal_name': 'normal', 'localized_category_name': 'Category', 'localized_tag_name': 'Normal'}, {'category': 'Rarity', 'internal_name': 'Rarity_Common_Weapon', 'localized_category_name': 'Quality', 'localized_tag_name': 'Consumer Grade', 'color': 'b0c3d9'}, {'category': 'Exterior', 'internal_name': 'WearCategory0', 'localized_category_name': 'Exterior', 'localized_tag_name': 'Factory New'}]}, {'appid': 730, 'classid': '3761545285', 'instanceid': '0', 'currency': False, 'background_color': '', 'icon_url': '-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXU5A1PIYQNqhpOSV-fRPasw8rsUFJ5KBFZv668FFU1nfbOIj8W7oWzkYLdlPOsMOmIk2kGscAj2erE99Sn2AGw_0M4NW2hIYOLMlhpcmY0CRM', 'icon_url_large': '', 'descriptions': [{'type': 'html', 'value': ' '}, {'type': 'html', 'value': 'Container Series #303', 'color': '99ccff'}, {'type': 'html', 'value': ' '}, {'type': 'html', 'value': 'Contains one of the following:'}, {'type': 'html', 'value': 'AUG | Tom Cat', 'color': '4b69ff'}, {'type': 'html', 'value': 'AWP | Capillary', 'color': '4b69ff'}, {'type': 'html', 'value': 'CZ75-Auto | Distressed', 'color': '4b69ff'}, {'type': 'html', 'value': 'Desert Eagle | Blue Ply', 'color': '4b69ff'}, {'type': 'html', 'value': 'MP5-SD | Desert Strike', 'color': '4b69ff'}, {'type': 'html', 'value': 'Negev | Prototype', 'color': '4b69ff'}, {'type': 'html', 'value': 'R8 Revolver | Bone Forged', 'color': '4b69ff'}, {'type': 'html', 'value': 'P2000 | Acid Etched', 'color': '8847ff'}, {'type': 'html', 'value': 'Sawed-Off | Apocalypto', 'color': '8847ff'}, {'type': 'html', 'value': 'SCAR-20 | Enforcer', 'color': '8847ff'}, {'type': 'html', 'value': 'SG 553 | Darkwing', 'color': '8847ff'}, {'type': 'html', 'value': 'SSG 08 | Fever Dream', 'color': '8847ff'}, {'type': 'html', 'value': 'AK-47 | Phantom Disruptor', 'color': 'd32ce6'}, {'type': 'html', 'value': 'MAC-10 | Disco Tech', 'color': 'd32ce6'}, {'type': 'html', 'value': 'MAG-7 | Justice', 'color': 'd32ce6'}, {'type': 'html', 'value': 'M4A1-S | Player Two', 'color': 'eb4b4b'}, {'type': 'html', 'value': 'Glock-18 | Bullet Queen', 'color': 'eb4b4b'}, {'type': 'html', 'value': 'or an Exceedingly Rare Special Item!', 'color': 'ffd700'}, {'type': 'html', 'value': ' '}, {'type': 'html', 'value': '', 'color': '00a000'}], 'tradable': True, 'name': 'Prisma 2 Case', 'name_color': 'D2D2D2', 'type': 'Base Grade Container', 'market_name': 'Prisma 2 Case', 'market_hash_name': 'Prisma 2 Case', 'commodity': True, 'market_tradable_restriction': 7, 'marketable': True, 'tags': [{'category': 'Type', 'internal_name': 'CSGO_Type_WeaponCase', 'localized_category_name': 'Type', 'localized_tag_name': 'Container'}, {'category': 'ItemSet', 'internal_name': 'set_community_25', 'localized_category_name': 'Collection', 'localized_tag_name': 'The Prisma 2 Collection'}, {'category': 'Quality', 'internal_name': 'normal', 'localized_category_name': 'Category', 'localized_tag_name': 'Normal'}, {'category': 'Rarity', 'internal_name': 'Rarity_Common', 'localized_category_name': 'Quality', 'localized_tag_name': 'Base Grade', 'color': 'b0c3d9'}], 'market_buy_country_restriction': 'FR'}, {'appid': 440, 'classid': '3131324361', 'instanceid': '3474171410', 'currency': False, 'background_color': '3C352E', 'icon_url': 'IzMF03bi9WpSBq-S-ekoE33L-iLqGFHVaU25ZzQNQcXdEH9myp0JpkQSQPjPKLBYSMh87THVG47cgtRWlyxS2yFSLyGphUtpcOhuB8nDzAm18bTeTSCuPTLFLSSORQk4G7RWZzqI-mGm7budQzjMRu8sRF8GKKQD9XoJY54UIUmuDw', 'icon_url_large': 'IzMF03bi9WpSBq-S-ekoE33L-iLqGFHVaU25ZzQNQcXdEH9myp0JpkQSQPjPKLBYSMh87THVG47cgtRWlyxS2yFSLyGphUtpcOhuB8nDzAm18bTeTSCuPTLFLSSORQk4G7RWZzqI-mGm7budQzjMRu8sRF8GKKQD9XoJY54UIUmuDw', 'descriptions': [{'type': 'text', 'value': 'This item is a wrapped gift. You can give it to someone if you wrapped it, or unwrap it if you received it!'}, {'type': 'text', 'value': '\nGift from: SimplyArthur', 'color': '7ea9d1'}, {'type': 'text', 'value': ' '}, {'type': 'text', 'value': 'This is a limited use item. Uses: 1', 'color': '00a000'}, {'type': 'text', 'value': '\nContains: The Dumb Bell', 'color': '7D6D00'}, {'type': 'text', 'value': 'Level 53 Bell'}], 'tradable': True, 'actions': [{'link': 'http://wiki.teamfortress.com/scripts/itemredirect.php?id=5043&lang=en_US', 'name': 'Item Wiki Page...'}], 'name': 'A Carefully Wrapped Gift', 'name_color': '7D6D00', 'type': 'Level 5 Gift', 'market_name': 'A Carefully Wrapped Gift', 'market_hash_name': 'A Carefully Wrapped Gift', 'commodity': False, 'market_tradable_restriction': 7, 'market_marketable_restriction': 0, 'marketable': False, 'tags': [{'category': 'Quality', 'internal_name': 'Unique', 'localized_category_name': 'Quality', 'localized_tag_name': 'Unique', 'color': '7D6D00'}, {'category': 'Type', 'internal_name': 'TF_GIFT', 'localized_category_name': 'Type', 'localized_tag_name': 'Gift'}]}, {'appid': 440, 'classid': '2675', 'instanceid': '11040547', 'currency': False, 'background_color': '3C352E', 'icon_url': 'fWFc82js0fmoRAP-qOIPu5THSWqfSmTELLqcUywGkijVjZULUrsm1j-9xgEbZQsUYhTkhzJWhsPZAfOeD-VOn4phtsdQ32ZtxFYoN7PkYmVmIgeaUKNaX_Rjpwy8UHMz6pcxAIfnovUWJ1t9nYFqYw', 'icon_url_large': 'fWFc82js0fmoRAP-qOIPu5THSWqfSmTELLqcUywGkijVjZULUrsm1j-9xgEbZQsUYhTkhzJWhsPZAfOeD-VOn4phtsdQ32ZtxFYoN7PkYmVmIgeaUKNaX_Rjpwy8UHMz6pcxAIfnovUWJ1t9nYFqYw', 'tradable': True, 'actions': [{'link': 'http://wiki.teamfortress.com/scripts/itemredirect.php?id=5000&lang=en_US', 'name': 'Item Wiki Page...'}], 'name': 'Scrap Metal', 'name_color': '7D6D00', 'type': 'Level 1 Craft Item', 'market_name': 'Scrap Metal', 'market_hash_name': 'Scrap Metal', 'commodity': False, 'market_tradable_restriction': 7, 'market_marketable_restriction': 0, 'marketable': False, 'tags': [{'category': 'Quality', 'internal_name': 'Unique', 'localized_category_name': 'Quality', 'localized_tag_name': 'Unique', 'color': '7D6D00'}, {'category': 'Type', 'internal_name': 'Craft Item', 'localized_category_name': 'Type', 'localized_tag_name': 'Craft Item'}]}], 'next_cursor': 0}}

# data = get_trade_offers(orig_resp)
# #print(data)
# if 'trade_offers_received' in data['response']:
#     offers_received = data['response']['trade_offers_received']
#     for offer in offers_received:
#         print(offer)

login_response = {'success': False, 'requires_twofactor': False, 'message': 'There have been too many login failures from your network in a short time period.  Please wait and try again later.', 'captcha_needed': False, 'captcha_gid': -1}

#print(login_response.get('captcha_needed', False))
# try:
#     print(1 / 0)
#
# except Exception as exc:
#     # Наше второе исключение никто не поймает
#     # поэтому будет выведена цепочка
#     # из двух исключений.
#     raise RuntimeError('Явная цепочка исключений') from exc



#
# cookies = ['Cookie sessionid=df96e0ce7cf1abd513707630 for help.steampowered.com/', 'Cookie steamLoginSecure=76561199034686035%7C%7C879702D0683B425F76C70B7906875C0C17634AEB for help.steampowered.com/', 'Cookie steamMachineAuth76561199034686035= for help.steampowered.com/', 'Cookie browserid=2503459266429400538 for steamcommunity.com/', 'Cookie sessionid=e034d5151d5671e52cd4faf9 for steamcommunity.com/', 'Cookie steamCountry=RU%7Cc58862c88f60194f246ff2544a9ab9c0 for steamcommunity.com/', 'Cookie steamLoginSecure=76561199034686035%7C%7C879702D0683B425F76C70B7906875C0C17634AEB for steamcommunity.com/', 'Cookie steamMachineAuth76561199034686035= for steamcommunity.com/', 'Cookie webTradeEligibility=%7B%22allowed%22%3A0%2C%22reason%22%3A16416%2C%22allowed_at_time%22%3A1662469632%2C%22steamguard_required_days%22%3A15%2C%22new_device_cooldown_days%22%3A7%2C%22expiration%22%3A1661865134%2C%22time_checked%22%3A1661864834%7D for steamcommunity.com/', 'Cookie sessionid=e034d5151d5671e52cd4faf9 for store.steampowered.com/', 'Cookie steamLoginSecure=76561199034686035%7C%7C879702D0683B425F76C70B7906875C0C17634AEB for store.steampowered.com/', 'Cookie steamMachineAuth76561199034686035=FCBE015416970937DE9E5F25375887D4ACCD97F4 for store.steampowered.com/', 'Cookie steamRememberLogin=76561199034686035%7C%7C0589c6c836a72ede9dfb81a7a3e9cfad for store.steampowered.com/']
#
# for cookie in cookies:
#     if 'Cookie steamMachineAuth' in cookie and '= for steamcommunity.com/' in cookie:
#         cookie = cookie.replace('Cookie steamMachineAuth', '').replace('= for steamcommunity.com/','')
#         print(cookie)

proxy = {'http': 'http://2FwitQ94:LTuufqRp@146.19.65.119:63582'}
#proxy = {'https' : 'https://146.19.65.119:63582'}
req = requests.get('https://stackoverflow.com', proxies=proxy)
print(req.status_code)