wi1-bot 1.4.1__py3-none-any.whl → 1.4.3__py3-none-any.whl
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.
- wi1_bot/_version.py +2 -2
- wi1_bot/config.py +24 -11
- wi1_bot/webhook.py +36 -3
- {wi1_bot-1.4.1.dist-info → wi1_bot-1.4.3.dist-info}/METADATA +8 -10
- {wi1_bot-1.4.1.dist-info → wi1_bot-1.4.3.dist-info}/RECORD +9 -9
- {wi1_bot-1.4.1.dist-info → wi1_bot-1.4.3.dist-info}/WHEEL +1 -1
- {wi1_bot-1.4.1.dist-info → wi1_bot-1.4.3.dist-info}/LICENSE +0 -0
- {wi1_bot-1.4.1.dist-info → wi1_bot-1.4.3.dist-info}/entry_points.txt +0 -0
- {wi1_bot-1.4.1.dist-info → wi1_bot-1.4.3.dist-info}/top_level.txt +0 -0
wi1_bot/_version.py
CHANGED
wi1_bot/config.py
CHANGED
@@ -4,20 +4,21 @@ from typing import TypedDict
|
|
4
4
|
|
5
5
|
import yaml
|
6
6
|
|
7
|
-
_config_path
|
7
|
+
_config_path = os.getenv("WB_CONFIG_PATH")
|
8
8
|
|
9
|
-
if
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
if _config_path is None:
|
10
|
+
if home := os.getenv("HOME"):
|
11
|
+
_path = pathlib.Path(home) / ".config" / "wi1-bot" / "config.yaml"
|
12
|
+
if _path.is_file():
|
13
|
+
_config_path = str(_path.resolve())
|
13
14
|
|
14
|
-
if xdg_config_home := os.getenv("XDG_CONFIG_HOME"):
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
if xdg_config_home := os.getenv("XDG_CONFIG_HOME"):
|
16
|
+
_path = pathlib.Path(xdg_config_home) / "wi1-bot" / "config.yaml"
|
17
|
+
if _path.is_file():
|
18
|
+
_config_path = str(_path.resolve())
|
18
19
|
|
19
|
-
if pathlib.Path("config.yaml").is_file():
|
20
|
-
|
20
|
+
if pathlib.Path("config.yaml").is_file():
|
21
|
+
_config_path = "config.yaml"
|
21
22
|
|
22
23
|
if _config_path is None:
|
23
24
|
raise FileNotFoundError(
|
@@ -99,8 +100,14 @@ class TranscodingConfig(TranscodingConfigOptional):
|
|
99
100
|
profiles: dict[str, TranscodingProfile]
|
100
101
|
|
101
102
|
|
103
|
+
class RemotePathMapping(TypedDict):
|
104
|
+
remote: str
|
105
|
+
local: str
|
106
|
+
|
107
|
+
|
102
108
|
class GeneralConfigOptional(TypedDict, total=False):
|
103
109
|
log_dir: str
|
110
|
+
remote_path_mappings: list[RemotePathMapping]
|
104
111
|
|
105
112
|
|
106
113
|
class GeneralConfig(GeneralConfigOptional):
|
@@ -121,3 +128,9 @@ class Config(ConfigOptional):
|
|
121
128
|
|
122
129
|
with open(_config_path, "r") as f:
|
123
130
|
config: Config = yaml.load(f, Loader=yaml.SafeLoader)
|
131
|
+
|
132
|
+
if log_dir := os.getenv("WB_LOG_DIR"):
|
133
|
+
if "general" not in config:
|
134
|
+
config["general"] = {}
|
135
|
+
|
136
|
+
config["general"]["log_dir"] = log_dir
|
wi1_bot/webhook.py
CHANGED
@@ -8,7 +8,7 @@ from flask import Flask, request
|
|
8
8
|
|
9
9
|
from wi1_bot import push, transcoder
|
10
10
|
from wi1_bot.arr import Radarr, Sonarr
|
11
|
-
from wi1_bot.config import config
|
11
|
+
from wi1_bot.config import RemotePathMapping, config
|
12
12
|
|
13
13
|
app = Flask(__name__)
|
14
14
|
|
@@ -26,6 +26,37 @@ def on_grab(req: dict[str, Any]) -> None:
|
|
26
26
|
)
|
27
27
|
|
28
28
|
|
29
|
+
def replace_remote_paths(path: pathlib.Path) -> pathlib.Path:
|
30
|
+
if "general" not in config or "remote_path_mappings" not in config["general"]:
|
31
|
+
return path
|
32
|
+
|
33
|
+
mappings = config["general"]["remote_path_mappings"]
|
34
|
+
|
35
|
+
most_specific: RemotePathMapping | None = None
|
36
|
+
|
37
|
+
for mapping in mappings:
|
38
|
+
if path.is_relative_to(mapping["remote"]):
|
39
|
+
mapping_len = len(pathlib.Path(mapping["remote"]).parts)
|
40
|
+
most_specific_len = (
|
41
|
+
len(pathlib.Path(most_specific["remote"]).parts)
|
42
|
+
if most_specific is not None
|
43
|
+
else 0
|
44
|
+
)
|
45
|
+
|
46
|
+
if mapping_len > most_specific_len:
|
47
|
+
most_specific = mapping
|
48
|
+
|
49
|
+
if most_specific is not None:
|
50
|
+
remote_path = path
|
51
|
+
path = pathlib.Path(most_specific["local"]) / path.relative_to(
|
52
|
+
most_specific["remote"]
|
53
|
+
)
|
54
|
+
|
55
|
+
logger.debug(f"replaced remote path mapping: {remote_path} -> {path}")
|
56
|
+
|
57
|
+
return path
|
58
|
+
|
59
|
+
|
29
60
|
def on_download(req: dict[str, Any]) -> None:
|
30
61
|
path: pathlib.Path
|
31
62
|
content_id: int
|
@@ -65,6 +96,8 @@ def on_download(req: dict[str, Any]) -> None:
|
|
65
96
|
else:
|
66
97
|
raise ValueError("unknown download request")
|
67
98
|
|
99
|
+
path = replace_remote_paths(path)
|
100
|
+
|
68
101
|
try:
|
69
102
|
quality_options = config["transcoding"]["profiles"][quality_profile]
|
70
103
|
except KeyError:
|
@@ -119,10 +152,10 @@ def index() -> Any:
|
|
119
152
|
def start() -> None:
|
120
153
|
logger.info("starting webhook listener")
|
121
154
|
|
122
|
-
t = threading.Thread(target=app.run, kwargs={"host": "
|
155
|
+
t = threading.Thread(target=app.run, kwargs={"host": "0.0.0.0", "port": 9000})
|
123
156
|
t.daemon = True
|
124
157
|
t.start()
|
125
158
|
|
126
159
|
|
127
160
|
if __name__ == "__main__":
|
128
|
-
app.run(host="
|
161
|
+
app.run(host="0.0.0.0", port=9000)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: wi1-bot
|
3
|
-
Version: 1.4.
|
3
|
+
Version: 1.4.3
|
4
4
|
Summary: Discord bot for Radarr/Sonarr integration
|
5
5
|
Home-page: https://github.com/wthueb/wi1-bot
|
6
6
|
Author-email: William Huebner <wilhueb@gmail.com>
|
@@ -34,20 +34,18 @@ Classifier: Programming Language :: Python :: 3.10
|
|
34
34
|
Requires-Python: >=3.10
|
35
35
|
Description-Content-Type: text/markdown
|
36
36
|
License-File: LICENSE
|
37
|
-
Requires-Dist: discord.py ==2.3.
|
38
|
-
Requires-Dist: Flask ==
|
39
|
-
Requires-Dist: mongoengine ==0.
|
37
|
+
Requires-Dist: discord.py ==2.3.2
|
38
|
+
Requires-Dist: Flask ==3.0.2
|
39
|
+
Requires-Dist: mongoengine ==0.28.1
|
40
40
|
Requires-Dist: pyarr ==5.2.0
|
41
41
|
Requires-Dist: PyYAML ==6.0.1
|
42
42
|
Requires-Dist: requests ==2.31.0
|
43
43
|
Provides-Extra: dev
|
44
|
-
Requires-Dist: black ==23.3.0 ; extra == 'dev'
|
45
|
-
Requires-Dist: flake8 ==6.0.0 ; extra == 'dev'
|
46
|
-
Requires-Dist: isort ==5.12.0 ; extra == 'dev'
|
47
44
|
Requires-Dist: mongo-types ==0.15.1 ; extra == 'dev'
|
48
|
-
Requires-Dist: mypy ==1.
|
49
|
-
Requires-Dist: pre-commit ==3.
|
50
|
-
Requires-Dist:
|
45
|
+
Requires-Dist: mypy ==1.3.0 ; extra == 'dev'
|
46
|
+
Requires-Dist: pre-commit ==3.6.2 ; extra == 'dev'
|
47
|
+
Requires-Dist: ruff ==0.3.0 ; extra == 'dev'
|
48
|
+
Requires-Dist: types-PyYAML ==6.0.12.12 ; extra == 'dev'
|
51
49
|
|
52
50
|
# wi1-bot
|
53
51
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
wi1_bot/__init__.py,sha256=11ozJKiUsqDCZ3_mcAHhGYUyGK_Unl54djVSBBExFB4,59
|
2
|
-
wi1_bot/_version.py,sha256=
|
3
|
-
wi1_bot/config.py,sha256=
|
2
|
+
wi1_bot/_version.py,sha256=cUUlK35wR7qLNaS4SMOrkRP_HG0nSHq0YEIezhPHr3c,411
|
3
|
+
wi1_bot/config.py,sha256=AtzOXvCeat_lb-w_Wy37XyWIpV3LmKh38OGigluJ2nM,3139
|
4
4
|
wi1_bot/push.py,sha256=-Az8c21R3IZAkJVRQmWsbNXMfvBzzpc9pFTWsDy1mJE,789
|
5
|
-
wi1_bot/webhook.py,sha256=
|
5
|
+
wi1_bot/webhook.py,sha256=cVp6USg1vbfL05TPQSDIUUYPHWDjuPGb1IGsqImao6s,4713
|
6
6
|
wi1_bot/arr/__init__.py,sha256=ZIgkW24GBdS4sJmaiEIhueHOB6s2L8y2s9ahgp1USRI,86
|
7
7
|
wi1_bot/arr/download.py,sha256=02AYFglnFdWSG8xj_TaJc6l2wjybyhUW6F97CnoyUFw,1381
|
8
8
|
wi1_bot/arr/episode.py,sha256=j25ljy9hyTXFAEBeUQ4iozKP2YXpZyzauphaXa2oqh8,1057
|
@@ -22,9 +22,9 @@ wi1_bot/scripts/transcode_item.py,sha256=21MeeIZ9wIRhAY-FOEgOdPsg6YOLlSUj59r8NkT
|
|
22
22
|
wi1_bot/transcoder/__init__.py,sha256=B4xr82UtIFc3tyy_MEZdZKMukYW0yejPnfsGowaTIM0,105
|
23
23
|
wi1_bot/transcoder/transcode_queue.py,sha256=W7r2I7OD8QuxseCEb7_ddOvYXiBBLmKLvCs2IgJJ92I,1856
|
24
24
|
wi1_bot/transcoder/transcoder.py,sha256=3MiOnQaXHmS6oQsNEygd9-SeGH7nIipnTK2f7BJFB6Q,8684
|
25
|
-
wi1_bot-1.4.
|
26
|
-
wi1_bot-1.4.
|
27
|
-
wi1_bot-1.4.
|
28
|
-
wi1_bot-1.4.
|
29
|
-
wi1_bot-1.4.
|
30
|
-
wi1_bot-1.4.
|
25
|
+
wi1_bot-1.4.3.dist-info/LICENSE,sha256=6V4_mQoPoLJl77_WMsQRQMDG2mnIhDUdfCmMkqM9Qwc,1072
|
26
|
+
wi1_bot-1.4.3.dist-info/METADATA,sha256=niCQgmOgYsWFR6wp5Ya6aZkhV0MHoaOHJ_CzA5mut3Y,4517
|
27
|
+
wi1_bot-1.4.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
28
|
+
wi1_bot-1.4.3.dist-info/entry_points.txt,sha256=G_NEW2uMHHw4pbmVwGZ6cZaBwGpdkv741jNYtuX-1vM,147
|
29
|
+
wi1_bot-1.4.3.dist-info/top_level.txt,sha256=Q7mTnPLk80Td82YbjlBMO5tvXJoTFHhheHdmwc-c-7I,8
|
30
|
+
wi1_bot-1.4.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|