pynintendoparental 1.0.1__tar.gz → 1.0.2__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.
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/PKG-INFO +1 -1
- pynintendoparental-1.0.2/pynintendoparental/_version.py +1 -0
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental/api.py +19 -0
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental/const.py +6 -2
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental/device.py +59 -29
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental.egg-info/PKG-INFO +1 -1
- pynintendoparental-1.0.1/pynintendoparental/_version.py +0 -1
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/LICENSE +0 -0
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/README.md +0 -0
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental/__init__.py +0 -0
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental/application.py +0 -0
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental/authenticator/__init__.py +0 -0
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental/authenticator/const.py +0 -0
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental/enum.py +0 -0
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental/exceptions.py +0 -0
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental/player.py +0 -0
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental/py.typed +0 -0
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental/utils.py +0 -0
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental.egg-info/SOURCES.txt +0 -0
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental.egg-info/dependency_links.txt +0 -0
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental.egg-info/requires.txt +0 -0
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental.egg-info/top_level.txt +0 -0
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pyproject.toml +0 -0
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/setup.cfg +0 -0
- {pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/setup.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.0.2"
|
|
@@ -192,3 +192,22 @@ class Api:
|
|
|
192
192
|
"unlockCode": new_code
|
|
193
193
|
}
|
|
194
194
|
)
|
|
195
|
+
|
|
196
|
+
async def async_update_extra_playing_time(
|
|
197
|
+
self,
|
|
198
|
+
device_id: str,
|
|
199
|
+
additional_time: int
|
|
200
|
+
) -> dict:
|
|
201
|
+
"""Update device extra playing time."""
|
|
202
|
+
body = {
|
|
203
|
+
"deviceId": device_id,
|
|
204
|
+
"additionalTime": additional_time,
|
|
205
|
+
"status": "TO_ADDED"
|
|
206
|
+
}
|
|
207
|
+
if additional_time == -1:
|
|
208
|
+
body["status"] = "TO_INFINITY"
|
|
209
|
+
body.pop("additionalTime")
|
|
210
|
+
return await self.send_request(
|
|
211
|
+
endpoint="update_extra_playing_time",
|
|
212
|
+
body=body
|
|
213
|
+
)
|
|
@@ -5,8 +5,8 @@ import logging
|
|
|
5
5
|
|
|
6
6
|
_LOGGER = logging.getLogger(__package__)
|
|
7
7
|
MOBILE_APP_PKG = "com.nintendo.znma"
|
|
8
|
-
MOBILE_APP_VERSION = "2.
|
|
9
|
-
MOBILE_APP_BUILD = "
|
|
8
|
+
MOBILE_APP_VERSION = "2.1.1"
|
|
9
|
+
MOBILE_APP_BUILD = "540"
|
|
10
10
|
OS_NAME = "ANDROID"
|
|
11
11
|
OS_VERSION = "33"
|
|
12
12
|
OS_STR = f"{OS_NAME} {OS_VERSION}"
|
|
@@ -52,5 +52,9 @@ ENDPOINTS = {
|
|
|
52
52
|
"get_device_monthly_summary": {
|
|
53
53
|
"url": "{BASE_URL}/actions/playSummary/fetchMonthlySummary?deviceId={DEVICE_ID}&year={YEAR}&month={MONTH}&containLatest=false",
|
|
54
54
|
"method": "GET"
|
|
55
|
+
},
|
|
56
|
+
"update_extra_playing_time": {
|
|
57
|
+
"url": "{BASE_URL}/actions/device/updateExtraPlayingTime",
|
|
58
|
+
"method": "POST"
|
|
55
59
|
}
|
|
56
60
|
}
|
|
@@ -63,11 +63,7 @@ class Device:
|
|
|
63
63
|
else:
|
|
64
64
|
for player in self.players:
|
|
65
65
|
player.update_from_daily_summary(self.daily_summaries)
|
|
66
|
-
|
|
67
|
-
if is_awaitable(cb):
|
|
68
|
-
await cb()
|
|
69
|
-
else:
|
|
70
|
-
cb()
|
|
66
|
+
await self._execute_callbacks()
|
|
71
67
|
|
|
72
68
|
def add_device_callback(self, callback):
|
|
73
69
|
"""Add a callback to the device."""
|
|
@@ -83,6 +79,14 @@ class Device:
|
|
|
83
79
|
if callback in self._callbacks:
|
|
84
80
|
self._callbacks.remove(callback)
|
|
85
81
|
|
|
82
|
+
async def _execute_callbacks(self):
|
|
83
|
+
"""Execute all callbacks."""
|
|
84
|
+
for cb in self._callbacks:
|
|
85
|
+
if is_awaitable(cb):
|
|
86
|
+
await cb()
|
|
87
|
+
else:
|
|
88
|
+
cb()
|
|
89
|
+
|
|
86
90
|
async def set_new_pin(self, pin: str):
|
|
87
91
|
"""Updates the pin for the device."""
|
|
88
92
|
_LOGGER.debug(">> Device.set_new_pin(pin=REDACTED)")
|
|
@@ -92,6 +96,17 @@ class Device:
|
|
|
92
96
|
device_id=self.device_id
|
|
93
97
|
)
|
|
94
98
|
self._parse_parental_control_setting(response["json"])
|
|
99
|
+
await self._execute_callbacks()
|
|
100
|
+
|
|
101
|
+
async def add_extra_time(self, minutes: int):
|
|
102
|
+
"""Add extra time to the device."""
|
|
103
|
+
_LOGGER.debug(">> Device.add_extra_time(minutes=%s)", minutes)
|
|
104
|
+
await self._api.async_update_extra_playing_time(
|
|
105
|
+
device_id=self.device_id,
|
|
106
|
+
additional_time=minutes
|
|
107
|
+
)
|
|
108
|
+
await self._execute_callbacks()
|
|
109
|
+
|
|
95
110
|
|
|
96
111
|
async def set_restriction_mode(self, mode: RestrictionMode):
|
|
97
112
|
"""Updates the restriction mode of the device."""
|
|
@@ -104,6 +119,7 @@ class Device:
|
|
|
104
119
|
}
|
|
105
120
|
)
|
|
106
121
|
self._parse_parental_control_setting(response["json"])
|
|
122
|
+
await self._execute_callbacks()
|
|
107
123
|
|
|
108
124
|
async def set_bedtime_alarm(self, end_time: time = None, enabled: bool = True):
|
|
109
125
|
"""Update the bedtime alarm for the device."""
|
|
@@ -134,6 +150,8 @@ class Device:
|
|
|
134
150
|
}
|
|
135
151
|
)
|
|
136
152
|
self._parse_parental_control_setting(response["json"])
|
|
153
|
+
self._calculate_times()
|
|
154
|
+
await self._execute_callbacks()
|
|
137
155
|
|
|
138
156
|
async def update_max_daily_playtime(self, minutes: int = 0):
|
|
139
157
|
"""Updates the maximum daily playtime of a device."""
|
|
@@ -176,6 +194,8 @@ class Device:
|
|
|
176
194
|
}
|
|
177
195
|
)
|
|
178
196
|
self._parse_parental_control_setting(response["json"])
|
|
197
|
+
self._calculate_times()
|
|
198
|
+
await self._execute_callbacks()
|
|
179
199
|
|
|
180
200
|
def _update_applications(self):
|
|
181
201
|
"""Updates applications from daily summary."""
|
|
@@ -229,31 +249,22 @@ class Device:
|
|
|
229
249
|
self._update_day_of_week_regulations()
|
|
230
250
|
self._update_applications()
|
|
231
251
|
|
|
232
|
-
|
|
233
|
-
"""
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
self.daily_summaries = response["json"]["dailySummaries"]
|
|
247
|
-
_LOGGER.debug("New daily summary %s", self.daily_summaries)
|
|
248
|
-
try:
|
|
249
|
-
today_playing_time = self.get_date_summary()[0].get("playingTime", 0)
|
|
250
|
-
self.today_playing_time = 0 if today_playing_time is None else today_playing_time
|
|
251
|
-
today_disabled_time = self.get_date_summary()[0].get("disabledTime", 0)
|
|
252
|
-
self.today_disabled_time = 0 if today_disabled_time is None else today_disabled_time
|
|
253
|
-
today_exceeded_time = self.get_date_summary()[0].get("exceededTime", 0)
|
|
254
|
-
self.today_exceeded_time = 0 if today_exceeded_time is None else today_exceeded_time
|
|
255
|
-
_LOGGER.debug("Cached playing, disabled and exceeded time for today for device %s",
|
|
252
|
+
def _calculate_times(self):
|
|
253
|
+
"""Calculate times from parental control settings."""
|
|
254
|
+
if not isinstance(self.daily_summaries, list) or not self.daily_summaries:
|
|
255
|
+
return
|
|
256
|
+
if len(self.daily_summaries) == 0:
|
|
257
|
+
return
|
|
258
|
+
_LOGGER.debug(">> Device._calculate_times()")
|
|
259
|
+
today_playing_time = self.daily_summaries[0].get("playingTime", 0)
|
|
260
|
+
self.today_playing_time = 0 if today_playing_time is None else today_playing_time
|
|
261
|
+
today_disabled_time = self.daily_summaries[0].get("disabledTime", 0)
|
|
262
|
+
self.today_disabled_time = 0 if today_disabled_time is None else today_disabled_time
|
|
263
|
+
today_exceeded_time = self.daily_summaries[0].get("exceededTime", 0)
|
|
264
|
+
self.today_exceeded_time = 0 if today_exceeded_time is None else today_exceeded_time
|
|
265
|
+
_LOGGER.debug("Cached playing, disabled and exceeded time for today for device %s",
|
|
256
266
|
self.device_id)
|
|
267
|
+
try:
|
|
257
268
|
now = datetime.now()
|
|
258
269
|
current_minutes_past_midnight = now.hour * 60 + now.minute
|
|
259
270
|
minutes_in_day = 1440 # 24 * 60
|
|
@@ -328,6 +339,25 @@ class Device:
|
|
|
328
339
|
_LOGGER.debug("Unable to retrieve applications for device %s: %s", self.name, err)
|
|
329
340
|
self.application_update_failed = True
|
|
330
341
|
|
|
342
|
+
async def _get_parental_control_setting(self):
|
|
343
|
+
"""Retreives parental control settings from the API."""
|
|
344
|
+
_LOGGER.debug(">> Device._get_parental_control_setting()")
|
|
345
|
+
response = await self._api.async_get_device_parental_control_setting(
|
|
346
|
+
device_id=self.device_id
|
|
347
|
+
)
|
|
348
|
+
self._parse_parental_control_setting(response["json"])
|
|
349
|
+
self._calculate_times()
|
|
350
|
+
|
|
351
|
+
async def _get_daily_summaries(self):
|
|
352
|
+
"""Retrieve daily summaries."""
|
|
353
|
+
_LOGGER.debug(">> Device._get_daily_summaries()")
|
|
354
|
+
response = await self._api.async_get_device_daily_summaries(
|
|
355
|
+
device_id = self.device_id
|
|
356
|
+
)
|
|
357
|
+
self.daily_summaries = response["json"]["dailySummaries"]
|
|
358
|
+
_LOGGER.debug("New daily summary %s", self.daily_summaries)
|
|
359
|
+
self._calculate_times()
|
|
360
|
+
|
|
331
361
|
async def _get_extras(self):
|
|
332
362
|
"""Retrieve extra properties."""
|
|
333
363
|
_LOGGER.debug(">> Device._get_extras()")
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.0.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental/authenticator/__init__.py
RENAMED
|
File without changes
|
{pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental/authenticator/const.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental.egg-info/requires.txt
RENAMED
|
File without changes
|
{pynintendoparental-1.0.1 → pynintendoparental-1.0.2}/pynintendoparental.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|