subzeroid / instagrapi

🔥 The fastest and powerful Python library for Instagram Private API 2024
https://hikerapi.com/p/bkXQlaVe
MIT License
4.41k stars 691 forks source link

[BUG] The `set_settings()` method ignores the `country` key when setting settings from the dictionary #2065

Open obervinov opened 6 days ago

obervinov commented 6 days ago

Describe the bug When I set the instance settings via dictionary in the set_settings() method, all parameters are assigned correctly except country. Instead, the default value from the module code is set to US.

To Reproduce

  1. Create a dictionary with session configuration
    
    from instagrapi import Client

client = Client() config = { "country": "UK", "country_code": 1, "locale": "en_US", "timezone_offset": 3600 } client.set_settings(config)

2. Get the parameters of the current session configuration
```python
print(client.get_settings())

{'uuids': {...}, 'mid': None, 'ig_u_rur': None, 'ig_www_claim': None, 'authorization_data': {}, 'cookies': {}, 'last_login': None, 'device_settings': {...}, 'user_agent': '...', 'country': 'US', 'country_code': 1, 'locale': 'en_US', 'timezone_offset': 3600}
  1. If I explicitly call the set_country() method it works
    
    client.set_country('UK')
    print(client.get_settings())

{'uuids': {...}, 'mid': None, 'ig_u_rur': None, 'ig_www_claim': None, 'authorization_data': {}, 'cookies': {}, 'last_login': None, 'device_settings': {...}, 'user_agent': '...', 'country': 'UK', 'country_code': 1, 'locale': 'en_US', 'timezone_offset': 3600}



**Traceback**
None

**Expected behavior**
I expect that all dictionary keys passed to `client.set_settings()` will be propagated to the session attributes. 

**Screenshots**
None

**Desktop (please complete the following information):**
 - OS: Ubuntu 21.04
 - Python version 3.12.7
 - instagrapi version 2.1.2

**Additional context**
Also `client.load_settings()` ignores the `country` dictionary key saved via `client.dump_settings()`