wi1-bot 1.4.1__py3-none-any.whl → 1.4.2__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 CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '1.4.1'
16
- __version_tuple__ = version_tuple = (1, 4, 1)
15
+ __version__ = version = '1.4.2'
16
+ __version_tuple__ = version_tuple = (1, 4, 2)
wi1_bot/config.py CHANGED
@@ -99,8 +99,14 @@ class TranscodingConfig(TranscodingConfigOptional):
99
99
  profiles: dict[str, TranscodingProfile]
100
100
 
101
101
 
102
+ class RemotePathMapping(TypedDict):
103
+ remote: str
104
+ local: str
105
+
106
+
102
107
  class GeneralConfigOptional(TypedDict, total=False):
103
108
  log_dir: str
109
+ remote_path_mappings: list[RemotePathMapping]
104
110
 
105
111
 
106
112
  class GeneralConfig(GeneralConfigOptional):
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": "localhost", "port": 9000})
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="localhost", port=9000)
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.1
3
+ Version: 1.4.2
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.1
38
- Requires-Dist: Flask ==2.3.2
39
- Requires-Dist: mongoengine ==0.27.0
37
+ Requires-Dist: discord.py ==2.3.2
38
+ Requires-Dist: Flask ==3.0.2
39
+ Requires-Dist: mongoengine ==0.28.0
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.2.0 ; extra == 'dev'
49
- Requires-Dist: pre-commit ==3.2.2 ; extra == 'dev'
50
- Requires-Dist: types-PyYAML ==6.0.12.9 ; extra == 'dev'
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=oFZsPxoSsCY6D2DiWMSueNvMDRRQN5ssWrPdQtlLJ_o,411
3
- wi1_bot/config.py,sha256=cWgpI7GUwqUed43RZhD1ruZT0A5RoN8VESbSo8uwr5A,2797
2
+ wi1_bot/_version.py,sha256=tX44urJsC0QN5SJ51xsM0HeojA_8Xx7NXFEGAkYlNE4,411
3
+ wi1_bot/config.py,sha256=YmO_wLHMBm0PmFEeRru4Y3H4B1a2heDbSHU_sEcgfHs,2916
4
4
  wi1_bot/push.py,sha256=-Az8c21R3IZAkJVRQmWsbNXMfvBzzpc9pFTWsDy1mJE,789
5
- wi1_bot/webhook.py,sha256=SEKd11Hkcewf9Y_DvMKfo2TEP6wgqAGWUlGls7t0gso,3685
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.1.dist-info/LICENSE,sha256=6V4_mQoPoLJl77_WMsQRQMDG2mnIhDUdfCmMkqM9Qwc,1072
26
- wi1_bot-1.4.1.dist-info/METADATA,sha256=lh8bpMXqsnTC3910f3MSWoH9bxsLaRhi4l5e3kzmVBI,4612
27
- wi1_bot-1.4.1.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
28
- wi1_bot-1.4.1.dist-info/entry_points.txt,sha256=G_NEW2uMHHw4pbmVwGZ6cZaBwGpdkv741jNYtuX-1vM,147
29
- wi1_bot-1.4.1.dist-info/top_level.txt,sha256=Q7mTnPLk80Td82YbjlBMO5tvXJoTFHhheHdmwc-c-7I,8
30
- wi1_bot-1.4.1.dist-info/RECORD,,
25
+ wi1_bot-1.4.2.dist-info/LICENSE,sha256=6V4_mQoPoLJl77_WMsQRQMDG2mnIhDUdfCmMkqM9Qwc,1072
26
+ wi1_bot-1.4.2.dist-info/METADATA,sha256=6LkLpNIuvRfDesYyFwIgc-Bc3_SonPsSfB3NMlnG4Og,4517
27
+ wi1_bot-1.4.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
28
+ wi1_bot-1.4.2.dist-info/entry_points.txt,sha256=G_NEW2uMHHw4pbmVwGZ6cZaBwGpdkv741jNYtuX-1vM,147
29
+ wi1_bot-1.4.2.dist-info/top_level.txt,sha256=Q7mTnPLk80Td82YbjlBMO5tvXJoTFHhheHdmwc-c-7I,8
30
+ wi1_bot-1.4.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.2)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5