wi1-bot 1.4.4__py3-none-any.whl → 1.4.6__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/arr/radarr.py +2 -2
- wi1_bot/scripts/rescan.py +57 -0
- wi1_bot/transcoder/transcoder.py +30 -30
- {wi1_bot-1.4.4.dist-info → wi1_bot-1.4.6.dist-info}/METADATA +1 -1
- {wi1_bot-1.4.4.dist-info → wi1_bot-1.4.6.dist-info}/RECORD +10 -9
- {wi1_bot-1.4.4.dist-info → wi1_bot-1.4.6.dist-info}/entry_points.txt +1 -0
- {wi1_bot-1.4.4.dist-info → wi1_bot-1.4.6.dist-info}/LICENSE +0 -0
- {wi1_bot-1.4.4.dist-info → wi1_bot-1.4.6.dist-info}/WHEEL +0 -0
- {wi1_bot-1.4.4.dist-info → wi1_bot-1.4.6.dist-info}/top_level.txt +0 -0
wi1_bot/_version.py
CHANGED
wi1_bot/arr/radarr.py
CHANGED
@@ -149,10 +149,10 @@ class Radarr:
|
|
149
149
|
raise ValueError(f"no quality profile with the id {profile_id}")
|
150
150
|
|
151
151
|
def rescan_movie(self, movie_id: int) -> None:
|
152
|
-
self._radarr.post_command("RescanMovie", movieId=movie_id)
|
152
|
+
self._radarr.post_command("RescanMovie", movieId=movie_id)
|
153
153
|
|
154
154
|
def refresh_movie(self, movie_id: int) -> None:
|
155
|
-
self._radarr.post_command("RefreshMovie", movieIds=[movie_id])
|
155
|
+
self._radarr.post_command("RefreshMovie", movieIds=[movie_id])
|
156
156
|
|
157
157
|
def search_missing(self) -> None:
|
158
158
|
self._radarr.post_command(name="MissingMoviesSearch")
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import argparse
|
2
|
+
from time import sleep
|
3
|
+
from typing import cast
|
4
|
+
|
5
|
+
from wi1_bot.arr.radarr import Radarr
|
6
|
+
from wi1_bot.arr.sonarr import Sonarr
|
7
|
+
from wi1_bot.config import config
|
8
|
+
|
9
|
+
|
10
|
+
def rescan_radarr() -> None:
|
11
|
+
radarr = Radarr(config["radarr"]["url"], config["radarr"]["api_key"])
|
12
|
+
|
13
|
+
all_movies = radarr._radarr.get_movie()
|
14
|
+
assert isinstance(all_movies, list)
|
15
|
+
all_movies.sort(key=lambda m: cast(str, m["title"]))
|
16
|
+
|
17
|
+
for movie in all_movies:
|
18
|
+
assert isinstance(movie, dict)
|
19
|
+
print(f"Rescanning {movie['title']}...")
|
20
|
+
radarr.refresh_movie(movie["id"])
|
21
|
+
sleep(3)
|
22
|
+
|
23
|
+
|
24
|
+
def rescan_sonarr() -> None:
|
25
|
+
sonarr = Sonarr(config["sonarr"]["url"], config["sonarr"]["api_key"])
|
26
|
+
|
27
|
+
all_series = sonarr._sonarr.get_series()
|
28
|
+
assert isinstance(all_series, list)
|
29
|
+
all_series.sort(key=lambda s: cast(str, s["title"]))
|
30
|
+
|
31
|
+
for series in all_series:
|
32
|
+
assert isinstance(series, dict)
|
33
|
+
print(f"Rescanning {series['title']}...")
|
34
|
+
sonarr.rescan_series(series["id"])
|
35
|
+
sleep(5)
|
36
|
+
|
37
|
+
|
38
|
+
def main() -> None:
|
39
|
+
parser = argparse.ArgumentParser(description="Rescan all movies/shows")
|
40
|
+
|
41
|
+
parser.add_argument(
|
42
|
+
"service", nargs="?", choices=["radarr", "sonarr"], help="radarr or sonarr"
|
43
|
+
)
|
44
|
+
|
45
|
+
args = parser.parse_args()
|
46
|
+
|
47
|
+
if args.service == "radarr":
|
48
|
+
rescan_radarr()
|
49
|
+
elif args.service == "sonarr":
|
50
|
+
rescan_sonarr()
|
51
|
+
else:
|
52
|
+
rescan_radarr()
|
53
|
+
rescan_sonarr()
|
54
|
+
|
55
|
+
|
56
|
+
if __name__ == "__main__":
|
57
|
+
main()
|
wi1_bot/transcoder/transcoder.py
CHANGED
@@ -46,17 +46,10 @@ class Transcoder:
|
|
46
46
|
continue
|
47
47
|
|
48
48
|
try:
|
49
|
-
self._do_transcode(item)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
pass
|
54
|
-
except FileNotFoundError:
|
55
|
-
# don't retry
|
56
|
-
queue.remove(item)
|
57
|
-
except UnknownError:
|
58
|
-
# don't retry
|
59
|
-
queue.remove(item)
|
49
|
+
remove = self._do_transcode(item)
|
50
|
+
|
51
|
+
if remove:
|
52
|
+
queue.remove(item)
|
60
53
|
except Exception:
|
61
54
|
self.logger.warning(
|
62
55
|
"got exception when trying to transcode", exc_info=True
|
@@ -64,14 +57,14 @@ class Transcoder:
|
|
64
57
|
|
65
58
|
sleep(3)
|
66
59
|
|
67
|
-
def _do_transcode(self, item: TranscodeItem) ->
|
60
|
+
def _do_transcode(self, item: TranscodeItem) -> bool:
|
68
61
|
path = pathlib.Path(item.path)
|
69
62
|
|
70
|
-
self.logger.
|
63
|
+
self.logger.info(f"attempting to transcode {path.name}")
|
71
64
|
|
72
65
|
if path.suffix == ".avi":
|
73
|
-
self.logger.
|
74
|
-
return
|
66
|
+
self.logger.info(f"cannot transcode {path.name}: .avi not supported")
|
67
|
+
return True
|
75
68
|
|
76
69
|
# push.send(f"{basename}", title="starting transcode")
|
77
70
|
|
@@ -103,29 +96,34 @@ class Transcoder:
|
|
103
96
|
tmp_log_path = tmp_folder / "wi1_bot.transcoder.log"
|
104
97
|
|
105
98
|
with open(tmp_log_path, "w") as ffmpeg_log_file:
|
106
|
-
|
99
|
+
assert proc.stdout is not None
|
100
|
+
for line in proc.stdout:
|
107
101
|
ffmpeg_log_file.write(line)
|
108
102
|
last_output = line.strip()
|
109
103
|
|
110
104
|
status = proc.wait()
|
111
105
|
|
112
106
|
if status != 0:
|
113
|
-
|
107
|
+
transcode_to.unlink()
|
114
108
|
|
115
|
-
if
|
116
|
-
|
117
|
-
and "shared object file" not in last_output
|
118
|
-
):
|
119
|
-
self.logger.debug(
|
109
|
+
if "Error opening input files" in last_output:
|
110
|
+
self.logger.info(
|
120
111
|
f"file does not exist: {path}, skipping transcoding"
|
121
112
|
)
|
122
|
-
|
113
|
+
return True
|
123
114
|
|
124
115
|
if "received signal 15" in last_output:
|
125
|
-
self.logger.
|
116
|
+
self.logger.info(
|
126
117
|
f"transcoding interrupted by signal: {path}, will retry"
|
127
118
|
)
|
128
|
-
|
119
|
+
return False
|
120
|
+
|
121
|
+
if "cannot open shared object file" in last_output:
|
122
|
+
self.logger.error(
|
123
|
+
"ffmpeg error: missing shared object file, will retry"
|
124
|
+
)
|
125
|
+
push.send(f"ffmpeg error: {last_output}", title="ffmpeg error")
|
126
|
+
return False
|
129
127
|
|
130
128
|
perm_log_path = tmp_folder / f"{path.stem}.log"
|
131
129
|
|
@@ -136,6 +134,8 @@ class Transcoder:
|
|
136
134
|
perm_log_path.parent.mkdir(parents=True, exist_ok=True)
|
137
135
|
|
138
136
|
shutil.copy(tmp_log_path, perm_log_path)
|
137
|
+
|
138
|
+
self.logger.error(f"ffmpeg failed (status {status}): {last_output}")
|
139
139
|
self.logger.error(f"log file: {perm_log_path}")
|
140
140
|
|
141
141
|
push.send(
|
@@ -143,9 +143,7 @@ class Transcoder:
|
|
143
143
|
title="transcoding error",
|
144
144
|
)
|
145
145
|
|
146
|
-
|
147
|
-
|
148
|
-
new_path = path.parent / transcode_to.name
|
146
|
+
return True
|
149
147
|
|
150
148
|
if not path.exists():
|
151
149
|
self.logger.debug(
|
@@ -153,8 +151,9 @@ class Transcoder:
|
|
153
151
|
)
|
154
152
|
|
155
153
|
transcode_to.unlink()
|
156
|
-
return
|
154
|
+
return True
|
157
155
|
|
156
|
+
new_path = path.parent / transcode_to.name
|
158
157
|
shutil.move(transcode_to, new_path)
|
159
158
|
path.unlink()
|
160
159
|
|
@@ -163,8 +162,9 @@ class Transcoder:
|
|
163
162
|
self.logger.info(f"transcoded: {path.name} -> {new_path.name}")
|
164
163
|
# push.send(f"{path.name} -> {new_path.name}", title="file transcoded")
|
165
164
|
|
165
|
+
return True
|
166
|
+
|
166
167
|
def _rescan_content(self, item: TranscodeItem, new_path: str) -> None:
|
167
|
-
# FIXME: don't hardcode library paths (config)
|
168
168
|
if item.content_id is not None:
|
169
169
|
if new_path.startswith(config["radarr"]["root_folder"]):
|
170
170
|
self.radarr.rescan_movie(item.content_id)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
wi1_bot/__init__.py,sha256=11ozJKiUsqDCZ3_mcAHhGYUyGK_Unl54djVSBBExFB4,59
|
2
|
-
wi1_bot/_version.py,sha256=
|
2
|
+
wi1_bot/_version.py,sha256=HFQuEZSl62eJNTO3Swl0voif7bfUlhX7pVxUC5X9W7g,411
|
3
3
|
wi1_bot/config.py,sha256=AtzOXvCeat_lb-w_Wy37XyWIpV3LmKh38OGigluJ2nM,3139
|
4
4
|
wi1_bot/push.py,sha256=-Az8c21R3IZAkJVRQmWsbNXMfvBzzpc9pFTWsDy1mJE,789
|
5
5
|
wi1_bot/webhook.py,sha256=cVp6USg1vbfL05TPQSDIUUYPHWDjuPGb1IGsqImao6s,4713
|
@@ -7,7 +7,7 @@ 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
|
9
9
|
wi1_bot/arr/movie.py,sha256=9cpJZcoW3r4op6X8Fkr4Cv0BsiWfqKD8MkBfEpTcT8k,741
|
10
|
-
wi1_bot/arr/radarr.py,sha256=
|
10
|
+
wi1_bot/arr/radarr.py,sha256=sZ2zVhSDir3T3THW2vvIgWPdsvoEsYZLualeY8UCIr4,5711
|
11
11
|
wi1_bot/arr/sonarr.py,sha256=OouuorRHBMFAOy5oDeJZ5H6WZ-95-N01EHtpOTVMTCo,5970
|
12
12
|
wi1_bot/discord/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
13
|
wi1_bot/discord/bot.py,sha256=puBlprcGqoC-m98DDZuM7Q7zhfTHSsqJIw2ptNrE4_M,5080
|
@@ -17,14 +17,15 @@ wi1_bot/discord/cogs/movie.py,sha256=J-1wahJLdIk9WhgQlva4zp9AK__2Vw1M8JoPvhcwzbw
|
|
17
17
|
wi1_bot/discord/cogs/series.py,sha256=AfUfWuU-vUlID-gW7GWu9w-GiwWzZ4Cxm49_FjgvJik,4837
|
18
18
|
wi1_bot/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
19
|
wi1_bot/scripts/add_tag.py,sha256=mWwo8egk2Y5XRiQCpfkA11-3rcxZoD0JOJKxV0LguLk,586
|
20
|
+
wi1_bot/scripts/rescan.py,sha256=2V7a3GSP8owLxdJ0J6nG98M-PqPWfRRhfJuDOgWQgnU,1488
|
20
21
|
wi1_bot/scripts/start.py,sha256=vNa_iHkx10D5YWonyRW0f5nG8uE3_JtwJ-XZ-c0hWCs,2477
|
21
22
|
wi1_bot/scripts/transcode_item.py,sha256=21MeeIZ9wIRhAY-FOEgOdPsg6YOLlSUj59r8NkTfixw,1155
|
22
23
|
wi1_bot/transcoder/__init__.py,sha256=B4xr82UtIFc3tyy_MEZdZKMukYW0yejPnfsGowaTIM0,105
|
23
24
|
wi1_bot/transcoder/transcode_queue.py,sha256=W7r2I7OD8QuxseCEb7_ddOvYXiBBLmKLvCs2IgJJ92I,1856
|
24
|
-
wi1_bot/transcoder/transcoder.py,sha256=
|
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/transcoder/transcoder.py,sha256=g82E_X37tG2GStbMPA9cgPpZ43kpZKi4LpR7_iKdc78,8767
|
26
|
+
wi1_bot-1.4.6.dist-info/LICENSE,sha256=6V4_mQoPoLJl77_WMsQRQMDG2mnIhDUdfCmMkqM9Qwc,1072
|
27
|
+
wi1_bot-1.4.6.dist-info/METADATA,sha256=laH8OH_m7-0OAAcDJHVGhTakuTNAo-9vgd_6ADNrhQ0,4530
|
28
|
+
wi1_bot-1.4.6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
29
|
+
wi1_bot-1.4.6.dist-info/entry_points.txt,sha256=pF5EawAQsUNMHs5exynpNdRq9g4dODg-RaPkx2MyYLU,184
|
30
|
+
wi1_bot-1.4.6.dist-info/top_level.txt,sha256=Q7mTnPLk80Td82YbjlBMO5tvXJoTFHhheHdmwc-c-7I,8
|
31
|
+
wi1_bot-1.4.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|