raiju-dtek 0.1.0__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.
- raiju_dtek-0.1.0/LICENSE +22 -0
- raiju_dtek-0.1.0/PKG-INFO +41 -0
- raiju_dtek-0.1.0/README.md +27 -0
- raiju_dtek-0.1.0/pyproject.toml +30 -0
- raiju_dtek-0.1.0/pyproject.toml.orig +29 -0
- raiju_dtek-0.1.0/src/raiju/__init__.py +3 -0
- raiju_dtek-0.1.0/src/raiju/__main__.py +3 -0
- raiju_dtek-0.1.0/src/raiju/cli.py +87 -0
- raiju_dtek-0.1.0/src/raiju/schedule.py +29 -0
raiju_dtek-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 rvdxse
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: raiju-dtek
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: DTEK outage schedule for Kyiv in your terminal
|
|
5
|
+
Author: rvdxse
|
|
6
|
+
Author-email: rvdxse <kirillfilch@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: dtek-blackout-client>=0.1.12
|
|
10
|
+
Requires-Dist: iterfzf>=1.9.0.67.0
|
|
11
|
+
Requires-Python: >=3.13
|
|
12
|
+
Project-URL: Homepage, https://github.com/rvdxse/raiju
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# raiju-dtek
|
|
16
|
+
|
|
17
|
+
DTEK power outage schedule for Kyiv, right in your terminal. Pick your street and house with fuzzy search, get today's outage intervals.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
uv tool install raiju-dtek
|
|
23
|
+
uvx playwright install chromium # one-time browser download
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
raiju
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Type to filter, `Enter` to select, `Esc` to cancel.
|
|
33
|
+
|
|
34
|
+
## Requirements
|
|
35
|
+
|
|
36
|
+
- Python 3.10+
|
|
37
|
+
- Chromium via Playwright (used to pass the DTEK site protection)
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
MIT
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# raiju-dtek
|
|
2
|
+
|
|
3
|
+
DTEK power outage schedule for Kyiv, right in your terminal. Pick your street and house with fuzzy search, get today's outage intervals.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
uv tool install raiju-dtek
|
|
9
|
+
uvx playwright install chromium # one-time browser download
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
raiju
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Type to filter, `Enter` to select, `Esc` to cancel.
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
- Python 3.10+
|
|
23
|
+
- Chromium via Playwright (used to pass the DTEK site protection)
|
|
24
|
+
|
|
25
|
+
## License
|
|
26
|
+
|
|
27
|
+
MIT
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "raiju-dtek"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "DTEK outage schedule for Kyiv in your terminal"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.13"
|
|
9
|
+
dependencies = [
|
|
10
|
+
"dtek-blackout-client>=0.1.12",
|
|
11
|
+
"iterfzf>=1.9.0.67.0",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[[project.authors]]
|
|
15
|
+
name = "rvdxse"
|
|
16
|
+
email = "kirillfilch@gmail.com"
|
|
17
|
+
|
|
18
|
+
[project.urls]
|
|
19
|
+
Homepage = "https://github.com/rvdxse/raiju"
|
|
20
|
+
|
|
21
|
+
[project.scripts]
|
|
22
|
+
raiju = "raiju.cli:run"
|
|
23
|
+
raiju-dtek = "raiju.cli:run"
|
|
24
|
+
|
|
25
|
+
[tool.uv.build-backend]
|
|
26
|
+
module-name = "raiju"
|
|
27
|
+
|
|
28
|
+
[build-system]
|
|
29
|
+
requires = ["uv_build>=0.13.6,<0.14.0"]
|
|
30
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "raiju-dtek"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "DTEK outage schedule for Kyiv in your terminal"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "rvdxse", email = "kirillfilch@gmail.com" }
|
|
10
|
+
]
|
|
11
|
+
requires-python = ">=3.13"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"dtek-blackout-client>=0.1.12",
|
|
14
|
+
"iterfzf>=1.9.0.67.0",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
[project.urls]
|
|
18
|
+
Homepage = "https://github.com/rvdxse/raiju"
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
raiju = "raiju.cli:run"
|
|
22
|
+
raiju-dtek = "raiju.cli:run"
|
|
23
|
+
|
|
24
|
+
[tool.uv.build-backend]
|
|
25
|
+
module-name = "raiju"
|
|
26
|
+
|
|
27
|
+
[build-system]
|
|
28
|
+
requires = ["uv_build>=0.13.6,<0.14.0"]
|
|
29
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
from curl_cffi.requests import AsyncSession
|
|
5
|
+
from dtek_client import DtekClient
|
|
6
|
+
from dtek_client.browser_auth import get_cleared_cookies
|
|
7
|
+
from dtek_client.exceptions import DtekDataError
|
|
8
|
+
from iterfzf import iterfzf
|
|
9
|
+
|
|
10
|
+
from .schedule import format_interval, get_outage_intervals
|
|
11
|
+
|
|
12
|
+
BASE_URL = "https://www.dtek-kem.com.ua"
|
|
13
|
+
SCHEDULE_URL = f"{BASE_URL}/ua/shutdowns"
|
|
14
|
+
CITY = "м. Київ"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def pick(options: list[str], prompt: str) -> str:
|
|
18
|
+
choice = iterfzf(options, prompt=prompt)
|
|
19
|
+
if choice is None: # Esc / Ctrl-C
|
|
20
|
+
raise SystemExit(1)
|
|
21
|
+
return choice
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
async def make_session() -> AsyncSession:
|
|
25
|
+
cookies, csrf_token = await get_cleared_cookies(SCHEDULE_URL)
|
|
26
|
+
headers = {
|
|
27
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
|
|
28
|
+
"Accept": "application/json, text/javascript, */*; q=0.01",
|
|
29
|
+
"Accept-Language": "uk,en;q=0.9",
|
|
30
|
+
"Origin": BASE_URL,
|
|
31
|
+
"Referer": SCHEDULE_URL,
|
|
32
|
+
"X-Requested-With": "XMLHttpRequest",
|
|
33
|
+
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
|
34
|
+
}
|
|
35
|
+
if csrf_token:
|
|
36
|
+
headers["X-CSRF-Token"] = csrf_token
|
|
37
|
+
return AsyncSession(
|
|
38
|
+
timeout=15.0, headers=headers, cookies=cookies, impersonate="chrome120"
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def print_schedule(response, number: str) -> None:
|
|
43
|
+
house = response.houses[number]
|
|
44
|
+
if house.is_excluded:
|
|
45
|
+
print("Address is not in schedule")
|
|
46
|
+
return
|
|
47
|
+
if response.fact is None:
|
|
48
|
+
print("Графік зараз недоступний")
|
|
49
|
+
return
|
|
50
|
+
|
|
51
|
+
for group_id in house.group_ids:
|
|
52
|
+
print(f"\n{group_id}")
|
|
53
|
+
schedule = response.fact.get_group_today(group_id)
|
|
54
|
+
if schedule is None:
|
|
55
|
+
print("No schedule available")
|
|
56
|
+
continue
|
|
57
|
+
|
|
58
|
+
intervals = get_outage_intervals(schedule)
|
|
59
|
+
if intervals:
|
|
60
|
+
print("Відключення світла:")
|
|
61
|
+
for start, end in intervals:
|
|
62
|
+
print(f"🔴 {format_interval(start, end)}")
|
|
63
|
+
else:
|
|
64
|
+
print("🟢 Відключень не планується")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
async def main() -> None:
|
|
68
|
+
session = await make_session()
|
|
69
|
+
async with DtekClient(
|
|
70
|
+
"kem", ajax_url=f"{BASE_URL}/ua/ajax", session=session
|
|
71
|
+
) as client:
|
|
72
|
+
streets = await client.get_streets(CITY)
|
|
73
|
+
street = pick([s.name for s in streets], "Вулиця> ")
|
|
74
|
+
|
|
75
|
+
response = await client.get_home_num(city=CITY, street=street)
|
|
76
|
+
number = pick(list(response.houses), "Будинок> ")
|
|
77
|
+
|
|
78
|
+
print_schedule(response, number)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def run() -> None:
|
|
82
|
+
try:
|
|
83
|
+
asyncio.run(main())
|
|
84
|
+
except DtekDataError as e:
|
|
85
|
+
sys.exit(f"Помилка DTEK: {e}")
|
|
86
|
+
except KeyboardInterrupt:
|
|
87
|
+
sys.exit(130)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
HALVES = {
|
|
2
|
+
"yes": (False, False),
|
|
3
|
+
"no": (True, True),
|
|
4
|
+
"first": (True, False),
|
|
5
|
+
"second": (False, True),
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def get_outage_intervals(schedule: dict) -> list[tuple[int, int]]:
|
|
10
|
+
"""Возвращает интервалы отключений в минутах от начала суток."""
|
|
11
|
+
cells: list[bool] = []
|
|
12
|
+
for _, status in sorted(schedule.items(), key=lambda x: int(x[0])):
|
|
13
|
+
cells.extend(HALVES.get(str(status).lower(), (False, False)))
|
|
14
|
+
|
|
15
|
+
intervals = []
|
|
16
|
+
start = None
|
|
17
|
+
for i, off in enumerate(cells):
|
|
18
|
+
if off and start is None:
|
|
19
|
+
start = i
|
|
20
|
+
elif not off and start is not None:
|
|
21
|
+
intervals.append((start * 30, i * 30))
|
|
22
|
+
start = None
|
|
23
|
+
if start is not None:
|
|
24
|
+
intervals.append((start * 30, len(cells) * 30))
|
|
25
|
+
return intervals
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def format_interval(start: int, end: int) -> str:
|
|
29
|
+
return f"{start // 60:02d}:{start % 60:02d}–{end // 60:02d}:{end % 60:02d}"
|