wi1-bot 1.4.1__tar.gz → 1.4.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.
- wi1-bot-1.4.2/.pre-commit-config.yaml +18 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/PKG-INFO +1 -1
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/config.yaml.template +4 -1
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/pyproject.toml +19 -33
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/_version.py +2 -2
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/config.py +6 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/webhook.py +36 -3
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot.egg-info/PKG-INFO +1 -1
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot.egg-info/SOURCES.txt +0 -1
- wi1-bot-1.4.2/wi1_bot.egg-info/requires.txt +13 -0
- wi1-bot-1.4.1/.flake8 +0 -4
- wi1-bot-1.4.1/.pre-commit-config.yaml +0 -29
- wi1-bot-1.4.1/wi1_bot.egg-info/requires.txt +0 -15
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/.github/workflows/pypi-publish.yml +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/.gitignore +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/.vscode/launch.json +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/.vscode/settings.json +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/LICENSE +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/README.md +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/setup.cfg +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/tests/movie_downloaded.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/__init__.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/arr/__init__.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/arr/download.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/arr/episode.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/arr/movie.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/arr/radarr.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/arr/sonarr.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/discord/__init__.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/discord/bot.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/discord/cogs/__init__.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/discord/cogs/movie.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/discord/cogs/series.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/discord/helpers.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/push.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/scripts/__init__.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/scripts/add_tag.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/scripts/start.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/scripts/transcode_item.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/transcoder/__init__.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/transcoder/transcode_queue.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot/transcoder/transcoder.py +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot.egg-info/dependency_links.txt +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot.egg-info/entry_points.txt +0 -0
- {wi1-bot-1.4.1 → wi1-bot-1.4.2}/wi1_bot.egg-info/top_level.txt +0 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
fail_fast: false
|
2
|
+
|
3
|
+
repos:
|
4
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
5
|
+
rev: v0.3.0
|
6
|
+
hooks:
|
7
|
+
- id: ruff
|
8
|
+
args: [ --fix ]
|
9
|
+
- id: ruff-format
|
10
|
+
|
11
|
+
- repo: local
|
12
|
+
hooks:
|
13
|
+
- id: mypy
|
14
|
+
name: mypy
|
15
|
+
language: system
|
16
|
+
entry: mypy
|
17
|
+
pass_filenames: false
|
18
|
+
types: [python]
|
@@ -2,6 +2,10 @@
|
|
2
2
|
general:
|
3
3
|
# log file directory, optional
|
4
4
|
log_dir: /var/log/wi1-bot
|
5
|
+
# remote path mappings, optional
|
6
|
+
remote_path_mappings:
|
7
|
+
- remote: /data
|
8
|
+
local: /mnt/plex
|
5
9
|
|
6
10
|
radarr:
|
7
11
|
# radarr url you use to get to the dashboard
|
@@ -49,7 +53,6 @@ pushover:
|
|
49
53
|
transcoding:
|
50
54
|
# -hwaccel in ffmpeg, optional
|
51
55
|
hwaccel: cuda
|
52
|
-
|
53
56
|
profiles:
|
54
57
|
# name of profile must match name in radarr/sonarr
|
55
58
|
good:
|
@@ -1,7 +1,3 @@
|
|
1
|
-
[build-system]
|
2
|
-
requires = ["setuptools==61.*", "setuptools-scm"]
|
3
|
-
build-backend = "setuptools.build_meta"
|
4
|
-
|
5
1
|
[project]
|
6
2
|
name = "wi1-bot"
|
7
3
|
description = "Discord bot for Radarr/Sonarr integration"
|
@@ -16,25 +12,14 @@ classifiers = [
|
|
16
12
|
dynamic = ["version"]
|
17
13
|
requires-python = ">=3.10"
|
18
14
|
dependencies = [
|
19
|
-
"discord.py==2.3.
|
20
|
-
"Flask==
|
21
|
-
"mongoengine==0.
|
15
|
+
"discord.py==2.3.2",
|
16
|
+
"Flask==3.0.2",
|
17
|
+
"mongoengine==0.28.0",
|
22
18
|
"pyarr==5.2.0",
|
23
19
|
"PyYAML==6.0.1",
|
24
20
|
"requests==2.31.0"
|
25
21
|
]
|
26
22
|
|
27
|
-
[project.optional-dependencies]
|
28
|
-
dev = [
|
29
|
-
"black==23.3.0",
|
30
|
-
"flake8==6.0.0",
|
31
|
-
"isort==5.12.0",
|
32
|
-
"mongo-types==0.15.1",
|
33
|
-
"mypy==1.2.0",
|
34
|
-
"pre-commit==3.2.2",
|
35
|
-
"types-PyYAML==6.0.12.9",
|
36
|
-
]
|
37
|
-
|
38
23
|
[project.urls]
|
39
24
|
Homepage = "https://github.com/wthueb/wi1-bot"
|
40
25
|
|
@@ -43,27 +28,28 @@ wi1-bot = "wi1_bot.scripts.start:main"
|
|
43
28
|
transcode-item = "wi1_bot.scripts.transcode_item:main"
|
44
29
|
add-tag = "wi1_bot.scripts.add_tag:main"
|
45
30
|
|
31
|
+
[project.optional-dependencies]
|
32
|
+
dev = [
|
33
|
+
"mongo-types==0.15.1",
|
34
|
+
"mypy==1.3.0",
|
35
|
+
"pre-commit==3.6.2",
|
36
|
+
"ruff==0.3.0",
|
37
|
+
"types-PyYAML==6.0.12.12",
|
38
|
+
]
|
39
|
+
|
40
|
+
[build-system]
|
41
|
+
requires = ["setuptools==61.*", "setuptools-scm"]
|
42
|
+
build-backend = "setuptools.build_meta"
|
43
|
+
|
46
44
|
[tool.setuptools]
|
47
45
|
packages = ["wi1_bot"]
|
48
46
|
|
49
47
|
[tool.setuptools_scm]
|
50
48
|
write_to = "wi1_bot/_version.py"
|
51
49
|
|
50
|
+
[tool.ruff.lint]
|
51
|
+
select = ["E", "F", "I"]
|
52
|
+
|
52
53
|
[tool.mypy]
|
53
54
|
packages = "wi1_bot"
|
54
55
|
strict = true
|
55
|
-
|
56
|
-
[[tool.mypy.overrides]]
|
57
|
-
module = [
|
58
|
-
"pushover",
|
59
|
-
"pyarr",
|
60
|
-
]
|
61
|
-
ignore_missing_imports = true
|
62
|
-
|
63
|
-
[tool.black]
|
64
|
-
line-length = 88
|
65
|
-
target-version = ["py310"]
|
66
|
-
|
67
|
-
[tool.isort]
|
68
|
-
profile = "black"
|
69
|
-
known_first_party = ["wi1_bot"]
|
@@ -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):
|
@@ -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)
|
wi1-bot-1.4.1/.flake8
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
fail_fast: false
|
2
|
-
|
3
|
-
repos:
|
4
|
-
- repo: local
|
5
|
-
hooks:
|
6
|
-
- id: isort
|
7
|
-
name: isort
|
8
|
-
language: system
|
9
|
-
entry: isort
|
10
|
-
types: [python]
|
11
|
-
|
12
|
-
- id: black
|
13
|
-
name: black
|
14
|
-
language: system
|
15
|
-
entry: black
|
16
|
-
types: [python]
|
17
|
-
|
18
|
-
- id: flake8
|
19
|
-
name: flake8
|
20
|
-
language: system
|
21
|
-
entry: flake8
|
22
|
-
types: [python]
|
23
|
-
|
24
|
-
- id: mypy
|
25
|
-
name: mypy
|
26
|
-
language: system
|
27
|
-
entry: mypy
|
28
|
-
pass_filenames: false
|
29
|
-
types: [python]
|
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
|
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
|
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
|
File without changes
|
File without changes
|