mijiaAPI 1.4.4__tar.gz → 1.4.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: mijiaAPI
3
- Version: 1.4.4
3
+ Version: 1.4.5
4
4
  Summary: A Python API for Xiaomi Mijia
5
5
  License: GPLv3
6
6
  Author: Do1e
@@ -74,7 +74,7 @@ class mijiaLogin(object):
74
74
  })
75
75
  return data
76
76
 
77
- def _get_account(self, user_id: str) -> dict[str, str]:
77
+ def _get_account_info(self, user_id: str) -> dict[str, str]:
78
78
  """
79
79
  获取账户信息。
80
80
 
@@ -87,14 +87,13 @@ class mijiaLogin(object):
87
87
  Raises:
88
88
  LoginError: 获取账户信息失败时抛出。
89
89
  """
90
- ret = self.session.get(accountURL + str(user_id))
91
- if ret.status_code != 200:
92
- raise LoginError(ret.status_code, f'Failed to get account page, {ret.text}')
93
- ret_data = json.loads(ret.text[11:])['data']
94
- data = {
95
- k: v for k, v in ret_data.items()
96
- if k in ['account', 'gender', 'nickName', 'icon']
97
- }
90
+ try:
91
+ ret = self.session.get(accountURL + str(user_id))
92
+ if ret.status_code != 200:
93
+ raise LoginError(ret.status_code, f'Failed to get account page, {ret.text}')
94
+ data = json.loads(ret.text[11:])['data']
95
+ except (KeyError, json.JSONDecodeError) as e:
96
+ data = {}
98
97
  return data
99
98
 
100
99
  @staticmethod
@@ -190,7 +189,7 @@ class mijiaLogin(object):
190
189
  'deviceId': data['deviceId'],
191
190
  'serviceToken': cookies['serviceToken'],
192
191
  'expireTime': self._extract_latest_gmt_datetime(cookies).strftime('%Y-%m-%d %H:%M:%S'),
193
- **self._get_account(ret_data['userId'])
192
+ 'account_info': self._get_account_info(ret_data['userId'])
194
193
  }
195
194
 
196
195
  self._save_auth()
@@ -275,7 +274,7 @@ class mijiaLogin(object):
275
274
  'deviceId': data['deviceId'],
276
275
  'serviceToken': cookies['serviceToken'],
277
276
  'expireTime': self._extract_latest_gmt_datetime(cookies).strftime('%Y-%m-%d %H:%M:%S'),
278
- **self._get_account(ret_data['userId'])
277
+ 'account_info': self._get_account_info(ret_data['userId'])
279
278
  }
280
279
 
281
280
  self._save_auth()
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mijiaAPI"
3
- version = "1.4.4"
3
+ version = "1.4.5"
4
4
  description = "A Python API for Xiaomi Mijia"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.9,<4.0"
@@ -15,7 +15,7 @@ mijiaAPI = "mijiaAPI.__main__:cli"
15
15
 
16
16
  [tool.poetry]
17
17
  name = "mijiaAPI"
18
- version = "1.4.4"
18
+ version = "1.4.5"
19
19
  description = "A Python API for Xiaomi Mijia"
20
20
  authors = ["Do1e <dpj.email@qq.com>"]
21
21
  license = "GPLv3"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes