rayohx-cli 0.1.0__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.
- rayohx_cli/__init__.py +3 -0
- rayohx_cli/__main__.py +6 -0
- rayohx_cli/cli/__init__.py +26 -0
- rayohx_cli/cli/clean.py +59 -0
- rayohx_cli/cli/common.py +108 -0
- rayohx_cli/cli/config.py +82 -0
- rayohx_cli/cli/download.py +262 -0
- rayohx_cli/cli/info.py +121 -0
- rayohx_cli/cli/lifecycle.py +190 -0
- rayohx_cli/cli/root.py +105 -0
- rayohx_cli/events.py +40 -0
- rayohx_cli/format.py +34 -0
- rayohx_cli/output.py +119 -0
- rayohx_cli/params/__init__.py +147 -0
- rayohx_cli/params/display.py +35 -0
- rayohx_cli/params/engine.py +106 -0
- rayohx_cli/params/network.py +227 -0
- rayohx_cli/params/output.py +77 -0
- rayohx_cli/params/panels.py +7 -0
- rayohx_cli/params/selection.py +187 -0
- rayohx_cli/progress/__init__.py +24 -0
- rayohx_cli/progress/_factory.py +20 -0
- rayohx_cli/progress/_text.py +47 -0
- rayohx_cli/progress/reporters/__init__.py +8 -0
- rayohx_cli/progress/reporters/bar.py +60 -0
- rayohx_cli/progress/reporters/base.py +19 -0
- rayohx_cli/progress/reporters/null.py +16 -0
- rayohx_cli/progress/reporters/plain.py +38 -0
- rayohx_cli/py.typed +0 -0
- rayohx_cli/render.py +122 -0
- rayohx_cli/settings.py +78 -0
- rayohx_cli/values.py +284 -0
- rayohx_cli-0.1.0.dist-info/METADATA +92 -0
- rayohx_cli-0.1.0.dist-info/RECORD +37 -0
- rayohx_cli-0.1.0.dist-info/WHEEL +4 -0
- rayohx_cli-0.1.0.dist-info/entry_points.txt +2 -0
- rayohx_cli-0.1.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"""Download engine options."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Annotated
|
|
5
|
+
|
|
6
|
+
import typer
|
|
7
|
+
from rayohx import StorageStrategy
|
|
8
|
+
|
|
9
|
+
from rayohx_cli.params.panels import ENGINE
|
|
10
|
+
|
|
11
|
+
Concurrency = Annotated[
|
|
12
|
+
int | None,
|
|
13
|
+
typer.Option(
|
|
14
|
+
"--concurrency",
|
|
15
|
+
"-j",
|
|
16
|
+
envvar="RAYOHX_CONCURRENCY",
|
|
17
|
+
min=1,
|
|
18
|
+
max=64,
|
|
19
|
+
help="Segments to download at the same time (default 4).",
|
|
20
|
+
rich_help_panel=ENGINE,
|
|
21
|
+
),
|
|
22
|
+
]
|
|
23
|
+
Resume = Annotated[
|
|
24
|
+
bool,
|
|
25
|
+
typer.Option(
|
|
26
|
+
"--resume/--no-resume",
|
|
27
|
+
envvar="RAYOHX_RESUME",
|
|
28
|
+
help="Continue an interrupted download where it stopped.",
|
|
29
|
+
rich_help_panel=ENGINE,
|
|
30
|
+
),
|
|
31
|
+
]
|
|
32
|
+
Storage = Annotated[
|
|
33
|
+
StorageStrategy,
|
|
34
|
+
typer.Option(
|
|
35
|
+
"--storage",
|
|
36
|
+
envvar="RAYOHX_STORAGE",
|
|
37
|
+
case_sensitive=False,
|
|
38
|
+
help="Where finished segments wait: auto, direct, streaming, buffered, temporary, hybrid.",
|
|
39
|
+
rich_help_panel=ENGINE,
|
|
40
|
+
),
|
|
41
|
+
]
|
|
42
|
+
Workspace = Annotated[
|
|
43
|
+
Path | None,
|
|
44
|
+
typer.Option(
|
|
45
|
+
"--workspace",
|
|
46
|
+
envvar="RAYOHX_WORKSPACE",
|
|
47
|
+
help="A folder for working files (default: beside the output).",
|
|
48
|
+
rich_help_panel=ENGINE,
|
|
49
|
+
),
|
|
50
|
+
]
|
|
51
|
+
BufferSize = Annotated[
|
|
52
|
+
str | None,
|
|
53
|
+
typer.Option(
|
|
54
|
+
"--buffer-size",
|
|
55
|
+
envvar="RAYOHX_BUFFER_SIZE",
|
|
56
|
+
help="Memory for the segment buffer, for example 64M.",
|
|
57
|
+
rich_help_panel=ENGINE,
|
|
58
|
+
),
|
|
59
|
+
]
|
|
60
|
+
MaxTempSize = Annotated[
|
|
61
|
+
str | None,
|
|
62
|
+
typer.Option(
|
|
63
|
+
"--max-temp-size",
|
|
64
|
+
envvar="RAYOHX_MAX_TEMP_SIZE",
|
|
65
|
+
help="Most working disk space to use, for example 2G.",
|
|
66
|
+
rich_help_panel=ENGINE,
|
|
67
|
+
),
|
|
68
|
+
]
|
|
69
|
+
SpaceCheck = Annotated[
|
|
70
|
+
bool,
|
|
71
|
+
typer.Option(
|
|
72
|
+
"--space-check/--no-space-check",
|
|
73
|
+
envvar="RAYOHX_SPACE_CHECK",
|
|
74
|
+
help="Check that the disk has room (turn off if the free space is reported wrongly).",
|
|
75
|
+
rich_help_panel=ENGINE,
|
|
76
|
+
),
|
|
77
|
+
]
|
|
78
|
+
ReserveSpace = Annotated[
|
|
79
|
+
str | None,
|
|
80
|
+
typer.Option(
|
|
81
|
+
"--reserve-space",
|
|
82
|
+
envvar="RAYOHX_RESERVE_SPACE",
|
|
83
|
+
help="Free disk space that must remain after the download, for example 1G "
|
|
84
|
+
"(default 256M; 0 for none).",
|
|
85
|
+
rich_help_panel=ENGINE,
|
|
86
|
+
),
|
|
87
|
+
]
|
|
88
|
+
KeepState = Annotated[
|
|
89
|
+
bool,
|
|
90
|
+
typer.Option(
|
|
91
|
+
"--keep-state/--no-keep-state",
|
|
92
|
+
envvar="RAYOHX_KEEP_STATE",
|
|
93
|
+
help="Keep what a resume needs after a failure or Ctrl-C (on by default).",
|
|
94
|
+
rich_help_panel=ENGINE,
|
|
95
|
+
),
|
|
96
|
+
]
|
|
97
|
+
AllowFileKeys = Annotated[
|
|
98
|
+
bool,
|
|
99
|
+
typer.Option(
|
|
100
|
+
"--allow-file-keys/--no-allow-file-keys",
|
|
101
|
+
envvar="RAYOHX_ALLOW_FILE_KEYS",
|
|
102
|
+
help="Let a playlist's file: key addresses read a key from this machine. Off by default; "
|
|
103
|
+
"only for streams you trust.",
|
|
104
|
+
rich_help_panel=ENGINE,
|
|
105
|
+
),
|
|
106
|
+
]
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"""Network options."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Annotated
|
|
5
|
+
|
|
6
|
+
import typer
|
|
7
|
+
|
|
8
|
+
from rayohx_cli.params.panels import NETWORK
|
|
9
|
+
|
|
10
|
+
Header = Annotated[
|
|
11
|
+
list[str] | None,
|
|
12
|
+
typer.Option(
|
|
13
|
+
"--header",
|
|
14
|
+
"-H",
|
|
15
|
+
help="Send a header, as 'Name: value' (repeatable). @file reads them from a file.",
|
|
16
|
+
rich_help_panel=NETWORK,
|
|
17
|
+
),
|
|
18
|
+
]
|
|
19
|
+
Cookie = Annotated[
|
|
20
|
+
list[str] | None,
|
|
21
|
+
typer.Option(
|
|
22
|
+
"--cookie",
|
|
23
|
+
help="Send a cookie, as name=value (repeatable). @file reads them from a file.",
|
|
24
|
+
rich_help_panel=NETWORK,
|
|
25
|
+
),
|
|
26
|
+
]
|
|
27
|
+
UserAgent = Annotated[
|
|
28
|
+
str | None,
|
|
29
|
+
typer.Option(
|
|
30
|
+
"--user-agent",
|
|
31
|
+
envvar="RAYOHX_USER_AGENT",
|
|
32
|
+
help="The User-Agent to send.",
|
|
33
|
+
rich_help_panel=NETWORK,
|
|
34
|
+
),
|
|
35
|
+
]
|
|
36
|
+
Referer = Annotated[
|
|
37
|
+
str | None,
|
|
38
|
+
typer.Option(
|
|
39
|
+
"--referer", envvar="RAYOHX_REFERER", help="The Referer to send.", rich_help_panel=NETWORK
|
|
40
|
+
),
|
|
41
|
+
]
|
|
42
|
+
Origin = Annotated[
|
|
43
|
+
str | None,
|
|
44
|
+
typer.Option(
|
|
45
|
+
"--origin", envvar="RAYOHX_ORIGIN", help="The Origin to send.", rich_help_panel=NETWORK
|
|
46
|
+
),
|
|
47
|
+
]
|
|
48
|
+
Proxy = Annotated[
|
|
49
|
+
str | None,
|
|
50
|
+
typer.Option(
|
|
51
|
+
"--proxy",
|
|
52
|
+
envvar="RAYOHX_PROXY",
|
|
53
|
+
help="An http://, https://, socks5:// or socks5h:// proxy, for example "
|
|
54
|
+
"http://user:pass@host:3128. "
|
|
55
|
+
"Prefer the environment variable, since command lines can be seen by other users.",
|
|
56
|
+
rich_help_panel=NETWORK,
|
|
57
|
+
),
|
|
58
|
+
]
|
|
59
|
+
Insecure = Annotated[
|
|
60
|
+
bool,
|
|
61
|
+
typer.Option(
|
|
62
|
+
"--insecure",
|
|
63
|
+
envvar="RAYOHX_INSECURE",
|
|
64
|
+
help="Do not check TLS certificates. Only for servers you trust.",
|
|
65
|
+
rich_help_panel=NETWORK,
|
|
66
|
+
),
|
|
67
|
+
]
|
|
68
|
+
CaBundle = Annotated[
|
|
69
|
+
Path | None,
|
|
70
|
+
typer.Option(
|
|
71
|
+
"--ca-bundle",
|
|
72
|
+
envvar="RAYOHX_CA_BUNDLE",
|
|
73
|
+
help="A file of trusted certificate authorities (PEM), instead of the system's.",
|
|
74
|
+
rich_help_panel=NETWORK,
|
|
75
|
+
),
|
|
76
|
+
]
|
|
77
|
+
ConnectTimeout = Annotated[
|
|
78
|
+
float | None,
|
|
79
|
+
typer.Option(
|
|
80
|
+
"--connect-timeout",
|
|
81
|
+
envvar="RAYOHX_CONNECT_TIMEOUT",
|
|
82
|
+
help="Seconds to wait to connect.",
|
|
83
|
+
rich_help_panel=NETWORK,
|
|
84
|
+
),
|
|
85
|
+
]
|
|
86
|
+
ReadTimeout = Annotated[
|
|
87
|
+
float | None,
|
|
88
|
+
typer.Option(
|
|
89
|
+
"--read-timeout",
|
|
90
|
+
envvar="RAYOHX_READ_TIMEOUT",
|
|
91
|
+
help="Seconds to wait for data.",
|
|
92
|
+
rich_help_panel=NETWORK,
|
|
93
|
+
),
|
|
94
|
+
]
|
|
95
|
+
Timeout = Annotated[
|
|
96
|
+
float | None,
|
|
97
|
+
typer.Option(
|
|
98
|
+
"--timeout",
|
|
99
|
+
envvar="RAYOHX_TIMEOUT",
|
|
100
|
+
help="Most seconds one request may take, retries included.",
|
|
101
|
+
rich_help_panel=NETWORK,
|
|
102
|
+
),
|
|
103
|
+
]
|
|
104
|
+
Retries = Annotated[
|
|
105
|
+
int | None,
|
|
106
|
+
typer.Option(
|
|
107
|
+
"--retries",
|
|
108
|
+
envvar="RAYOHX_RETRIES",
|
|
109
|
+
min=0,
|
|
110
|
+
help="Extra attempts after a failure.",
|
|
111
|
+
rich_help_panel=NETWORK,
|
|
112
|
+
),
|
|
113
|
+
]
|
|
114
|
+
Backoff = Annotated[
|
|
115
|
+
float | None,
|
|
116
|
+
typer.Option(
|
|
117
|
+
"--backoff",
|
|
118
|
+
envvar="RAYOHX_BACKOFF",
|
|
119
|
+
min=0,
|
|
120
|
+
help="Back-off factor between retries: the wait is this times 2 to the attempt number "
|
|
121
|
+
"(default 0.5 seconds).",
|
|
122
|
+
rich_help_panel=NETWORK,
|
|
123
|
+
),
|
|
124
|
+
]
|
|
125
|
+
MaxRedirects = Annotated[
|
|
126
|
+
int | None,
|
|
127
|
+
typer.Option(
|
|
128
|
+
"--max-redirects",
|
|
129
|
+
envvar="RAYOHX_MAX_REDIRECTS",
|
|
130
|
+
min=0,
|
|
131
|
+
help="Most redirects to follow for one request (default 10).",
|
|
132
|
+
rich_help_panel=NETWORK,
|
|
133
|
+
),
|
|
134
|
+
]
|
|
135
|
+
ProxyUsername = Annotated[
|
|
136
|
+
str | None,
|
|
137
|
+
typer.Option(
|
|
138
|
+
"--proxy-username",
|
|
139
|
+
envvar="RAYOHX_PROXY_USERNAME",
|
|
140
|
+
help="The proxy user name, if it is not in the --proxy address. Needs --proxy-password.",
|
|
141
|
+
rich_help_panel=NETWORK,
|
|
142
|
+
),
|
|
143
|
+
]
|
|
144
|
+
ProxyPassword = Annotated[
|
|
145
|
+
str | None,
|
|
146
|
+
typer.Option(
|
|
147
|
+
"--proxy-password",
|
|
148
|
+
envvar="RAYOHX_PROXY_PASSWORD",
|
|
149
|
+
help="The proxy password. Prefer the environment variable, since command lines can be "
|
|
150
|
+
"seen by other users.",
|
|
151
|
+
rich_help_panel=NETWORK,
|
|
152
|
+
),
|
|
153
|
+
]
|
|
154
|
+
CookieFile = Annotated[
|
|
155
|
+
Path | None,
|
|
156
|
+
typer.Option(
|
|
157
|
+
"--cookie-file",
|
|
158
|
+
envvar="RAYOHX_COOKIE_FILE",
|
|
159
|
+
help="Read cookies from a Netscape-format cookies.txt file (as exported by browsers). "
|
|
160
|
+
"Domains are not checked: every cookie follows the same rules as --cookie.",
|
|
161
|
+
rich_help_panel=NETWORK,
|
|
162
|
+
),
|
|
163
|
+
]
|
|
164
|
+
BaseUrl = Annotated[
|
|
165
|
+
str | None,
|
|
166
|
+
typer.Option(
|
|
167
|
+
"--base-url",
|
|
168
|
+
help="When the playlist is a local file, resolve its relative addresses against this "
|
|
169
|
+
"web address instead of the one given.",
|
|
170
|
+
rich_help_panel=NETWORK,
|
|
171
|
+
),
|
|
172
|
+
]
|
|
173
|
+
RateLimit = Annotated[
|
|
174
|
+
str | None,
|
|
175
|
+
typer.Option(
|
|
176
|
+
"--rate-limit",
|
|
177
|
+
envvar="RAYOHX_RATE_LIMIT",
|
|
178
|
+
help="Most bytes per second to download in total, for example 2M.",
|
|
179
|
+
rich_help_panel=NETWORK,
|
|
180
|
+
),
|
|
181
|
+
]
|
|
182
|
+
CredentialHost = Annotated[
|
|
183
|
+
list[str] | None,
|
|
184
|
+
typer.Option(
|
|
185
|
+
"--credential-host",
|
|
186
|
+
help="Also send headers like Authorization and your cookies to this host (repeatable). "
|
|
187
|
+
"By default they go only to the host of the URL.",
|
|
188
|
+
rich_help_panel=NETWORK,
|
|
189
|
+
),
|
|
190
|
+
]
|
|
191
|
+
EnvProxy = Annotated[
|
|
192
|
+
bool,
|
|
193
|
+
typer.Option(
|
|
194
|
+
"--env-proxy/--no-env-proxy",
|
|
195
|
+
envvar="RAYOHX_ENV_PROXY",
|
|
196
|
+
help="Use the HTTP_PROXY, HTTPS_PROXY, ALL_PROXY and NO_PROXY environment variables "
|
|
197
|
+
"when --proxy is not given. Off by default.",
|
|
198
|
+
rich_help_panel=NETWORK,
|
|
199
|
+
),
|
|
200
|
+
]
|
|
201
|
+
ClientCert = Annotated[
|
|
202
|
+
Path | None,
|
|
203
|
+
typer.Option(
|
|
204
|
+
"--client-cert",
|
|
205
|
+
envvar="RAYOHX_CLIENT_CERT",
|
|
206
|
+
help="A client certificate (PEM) for servers that require mutual TLS.",
|
|
207
|
+
rich_help_panel=NETWORK,
|
|
208
|
+
),
|
|
209
|
+
]
|
|
210
|
+
ClientKey = Annotated[
|
|
211
|
+
Path | None,
|
|
212
|
+
typer.Option(
|
|
213
|
+
"--client-key",
|
|
214
|
+
envvar="RAYOHX_CLIENT_KEY",
|
|
215
|
+
help="The private key (PEM) for --client-cert, if it is not in the same file.",
|
|
216
|
+
rich_help_panel=NETWORK,
|
|
217
|
+
),
|
|
218
|
+
]
|
|
219
|
+
ClientKeyPassword = Annotated[
|
|
220
|
+
str | None,
|
|
221
|
+
typer.Option(
|
|
222
|
+
"--client-key-password",
|
|
223
|
+
envvar="RAYOHX_CLIENT_KEY_PASSWORD",
|
|
224
|
+
help="The password of an encrypted client key. Prefer the environment variable.",
|
|
225
|
+
rich_help_panel=NETWORK,
|
|
226
|
+
),
|
|
227
|
+
]
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""Output options."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Annotated
|
|
5
|
+
|
|
6
|
+
import typer
|
|
7
|
+
from rayohx import OutputFormat, RemuxBackend
|
|
8
|
+
|
|
9
|
+
from rayohx_cli.params.panels import OUTPUT
|
|
10
|
+
|
|
11
|
+
OutputPath = Annotated[
|
|
12
|
+
Path | None,
|
|
13
|
+
typer.Option(
|
|
14
|
+
"--output",
|
|
15
|
+
"-o",
|
|
16
|
+
help="Where to save. A name without an extension gets the right one. "
|
|
17
|
+
"By default it is named after the address, in the current folder.",
|
|
18
|
+
rich_help_panel=OUTPUT,
|
|
19
|
+
),
|
|
20
|
+
]
|
|
21
|
+
Directory = Annotated[
|
|
22
|
+
Path | None,
|
|
23
|
+
typer.Option(
|
|
24
|
+
"--directory",
|
|
25
|
+
"-d",
|
|
26
|
+
envvar="RAYOHX_DIRECTORY",
|
|
27
|
+
help="The folder for a file that --output does not name. Created if missing.",
|
|
28
|
+
rich_help_panel=OUTPUT,
|
|
29
|
+
),
|
|
30
|
+
]
|
|
31
|
+
Format = Annotated[
|
|
32
|
+
OutputFormat,
|
|
33
|
+
typer.Option(
|
|
34
|
+
"--format",
|
|
35
|
+
envvar="RAYOHX_FORMAT",
|
|
36
|
+
case_sensitive=False,
|
|
37
|
+
help="auto, ts, mp4, or segments (one file per segment, in a folder).",
|
|
38
|
+
rich_help_panel=OUTPUT,
|
|
39
|
+
),
|
|
40
|
+
]
|
|
41
|
+
Overwrite = Annotated[
|
|
42
|
+
bool,
|
|
43
|
+
typer.Option(
|
|
44
|
+
"--overwrite/--no-overwrite",
|
|
45
|
+
envvar="RAYOHX_OVERWRITE",
|
|
46
|
+
help="Replace an existing output file.",
|
|
47
|
+
rich_help_panel=OUTPUT,
|
|
48
|
+
),
|
|
49
|
+
]
|
|
50
|
+
Validate = Annotated[
|
|
51
|
+
bool,
|
|
52
|
+
typer.Option(
|
|
53
|
+
"--validate/--no-validate",
|
|
54
|
+
envvar="RAYOHX_VALIDATE",
|
|
55
|
+
help="Check the finished file before putting it in place.",
|
|
56
|
+
rich_help_panel=OUTPUT,
|
|
57
|
+
),
|
|
58
|
+
]
|
|
59
|
+
RemuxBackendOption = Annotated[
|
|
60
|
+
RemuxBackend,
|
|
61
|
+
typer.Option(
|
|
62
|
+
"--remux-backend",
|
|
63
|
+
envvar="RAYOHX_REMUX_BACKEND",
|
|
64
|
+
case_sensitive=False,
|
|
65
|
+
help="Who re-wraps streams into MP4: auto (built in, then FFmpeg), native or ffmpeg.",
|
|
66
|
+
rich_help_panel=OUTPUT,
|
|
67
|
+
),
|
|
68
|
+
]
|
|
69
|
+
Ffmpeg = Annotated[
|
|
70
|
+
Path | None,
|
|
71
|
+
typer.Option(
|
|
72
|
+
"--ffmpeg",
|
|
73
|
+
envvar="RAYOHX_FFMPEG",
|
|
74
|
+
help="The FFmpeg program to use, if it is not on the PATH. FFmpeg is optional.",
|
|
75
|
+
rich_help_panel=OUTPUT,
|
|
76
|
+
),
|
|
77
|
+
]
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"""Choosing what to download."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Annotated
|
|
5
|
+
|
|
6
|
+
import typer
|
|
7
|
+
|
|
8
|
+
from rayohx_cli.params.panels import SELECTION
|
|
9
|
+
|
|
10
|
+
Url = Annotated[
|
|
11
|
+
str,
|
|
12
|
+
typer.Argument(
|
|
13
|
+
help="The address of the playlist (.m3u8). Quote it if it contains & or ?.",
|
|
14
|
+
metavar="URL",
|
|
15
|
+
),
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
Urls = Annotated[
|
|
19
|
+
list[str] | None,
|
|
20
|
+
typer.Argument(
|
|
21
|
+
help="The addresses of the playlists (.m3u8). Quote them if they contain & or ?.",
|
|
22
|
+
metavar="[URL]...",
|
|
23
|
+
),
|
|
24
|
+
]
|
|
25
|
+
InputFile = Annotated[
|
|
26
|
+
Path | None,
|
|
27
|
+
typer.Option(
|
|
28
|
+
"--input-file",
|
|
29
|
+
"-i",
|
|
30
|
+
help="Also download the addresses listed in this file, one per line (- for standard "
|
|
31
|
+
"input). Blank lines and lines starting with # are skipped.",
|
|
32
|
+
rich_help_panel=SELECTION,
|
|
33
|
+
),
|
|
34
|
+
]
|
|
35
|
+
PlaylistFile = Annotated[
|
|
36
|
+
Path | None,
|
|
37
|
+
typer.Option(
|
|
38
|
+
"--playlist-file",
|
|
39
|
+
help="Read the playlist from this file instead of fetching it. The address is still "
|
|
40
|
+
"needed: relative addresses in the playlist are resolved against it.",
|
|
41
|
+
rich_help_panel=SELECTION,
|
|
42
|
+
),
|
|
43
|
+
]
|
|
44
|
+
StopOnError = Annotated[
|
|
45
|
+
bool,
|
|
46
|
+
typer.Option(
|
|
47
|
+
"--stop-on-error/--no-stop-on-error",
|
|
48
|
+
envvar="RAYOHX_STOP_ON_ERROR",
|
|
49
|
+
help="With several addresses, stop at the first one that fails. Off by default.",
|
|
50
|
+
rich_help_panel=SELECTION,
|
|
51
|
+
),
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
Quality = Annotated[
|
|
55
|
+
str,
|
|
56
|
+
typer.Option(
|
|
57
|
+
"--quality",
|
|
58
|
+
envvar="RAYOHX_QUALITY",
|
|
59
|
+
help="best, worst, auto (up to 1080p), or a height such as 720p (the best at or below it).",
|
|
60
|
+
rich_help_panel=SELECTION,
|
|
61
|
+
),
|
|
62
|
+
]
|
|
63
|
+
MaxResolution = Annotated[
|
|
64
|
+
str | None,
|
|
65
|
+
typer.Option(
|
|
66
|
+
"--max-resolution",
|
|
67
|
+
envvar="RAYOHX_MAX_RESOLUTION",
|
|
68
|
+
help="Never pick a picture taller than this, for example 1080p.",
|
|
69
|
+
rich_help_panel=SELECTION,
|
|
70
|
+
),
|
|
71
|
+
]
|
|
72
|
+
MaxBitrate = Annotated[
|
|
73
|
+
str | None,
|
|
74
|
+
typer.Option(
|
|
75
|
+
"--max-bitrate",
|
|
76
|
+
envvar="RAYOHX_MAX_BITRATE",
|
|
77
|
+
help="Never pick a stream above this many bits per second, for example 4M.",
|
|
78
|
+
rich_help_panel=SELECTION,
|
|
79
|
+
),
|
|
80
|
+
]
|
|
81
|
+
Variant = Annotated[
|
|
82
|
+
int | None,
|
|
83
|
+
typer.Option(
|
|
84
|
+
"--variant",
|
|
85
|
+
envvar="RAYOHX_VARIANT",
|
|
86
|
+
min=1,
|
|
87
|
+
help="Download this stream, by its number in `rayohx info` (the first is 1).",
|
|
88
|
+
rich_help_panel=SELECTION,
|
|
89
|
+
),
|
|
90
|
+
]
|
|
91
|
+
Resolution = Annotated[
|
|
92
|
+
str | None,
|
|
93
|
+
typer.Option(
|
|
94
|
+
"--resolution",
|
|
95
|
+
envvar="RAYOHX_RESOLUTION",
|
|
96
|
+
help="Only streams with exactly this size, such as 1280x720.",
|
|
97
|
+
rich_help_panel=SELECTION,
|
|
98
|
+
),
|
|
99
|
+
]
|
|
100
|
+
Bandwidth = Annotated[
|
|
101
|
+
str | None,
|
|
102
|
+
typer.Option(
|
|
103
|
+
"--bandwidth",
|
|
104
|
+
envvar="RAYOHX_BANDWIDTH",
|
|
105
|
+
help="Only streams with exactly this bit rate, in bits per second (for example 2800000).",
|
|
106
|
+
rich_help_panel=SELECTION,
|
|
107
|
+
),
|
|
108
|
+
]
|
|
109
|
+
VariantName = Annotated[
|
|
110
|
+
str | None,
|
|
111
|
+
typer.Option(
|
|
112
|
+
"--variant-name",
|
|
113
|
+
envvar="RAYOHX_VARIANT_NAME",
|
|
114
|
+
help="Only streams with exactly this name (ignoring case).",
|
|
115
|
+
rich_help_panel=SELECTION,
|
|
116
|
+
),
|
|
117
|
+
]
|
|
118
|
+
Codec = Annotated[
|
|
119
|
+
str | None,
|
|
120
|
+
typer.Option(
|
|
121
|
+
"--codec",
|
|
122
|
+
envvar="RAYOHX_CODEC",
|
|
123
|
+
help="Prefer this video codec: h264, hevc, vp9 or av1. Others are used if it is missing.",
|
|
124
|
+
rich_help_panel=SELECTION,
|
|
125
|
+
),
|
|
126
|
+
]
|
|
127
|
+
VideoRange = Annotated[
|
|
128
|
+
str | None,
|
|
129
|
+
typer.Option(
|
|
130
|
+
"--video-range",
|
|
131
|
+
envvar="RAYOHX_VIDEO_RANGE",
|
|
132
|
+
help="Prefer this dynamic range: sdr, pq, hlg or hdr (pq or hlg).",
|
|
133
|
+
rich_help_panel=SELECTION,
|
|
134
|
+
),
|
|
135
|
+
]
|
|
136
|
+
MaxFrameRate = Annotated[
|
|
137
|
+
float | None,
|
|
138
|
+
typer.Option(
|
|
139
|
+
"--max-frame-rate",
|
|
140
|
+
envvar="RAYOHX_MAX_FRAME_RATE",
|
|
141
|
+
help="Never pick a stream above this many frames per second, for example 30.",
|
|
142
|
+
rich_help_panel=SELECTION,
|
|
143
|
+
),
|
|
144
|
+
]
|
|
145
|
+
Audio = Annotated[
|
|
146
|
+
list[str] | None,
|
|
147
|
+
typer.Option(
|
|
148
|
+
"--audio",
|
|
149
|
+
"-a",
|
|
150
|
+
help="Audio language to download (repeat for several), for example en.",
|
|
151
|
+
rich_help_panel=SELECTION,
|
|
152
|
+
),
|
|
153
|
+
]
|
|
154
|
+
AudioName = Annotated[
|
|
155
|
+
list[str] | None,
|
|
156
|
+
typer.Option(
|
|
157
|
+
"--audio-name",
|
|
158
|
+
help="Download the audio track with this exact name (repeatable).",
|
|
159
|
+
rich_help_panel=SELECTION,
|
|
160
|
+
),
|
|
161
|
+
]
|
|
162
|
+
Subtitles = Annotated[
|
|
163
|
+
list[str] | None,
|
|
164
|
+
typer.Option(
|
|
165
|
+
"--subtitles",
|
|
166
|
+
"-s",
|
|
167
|
+
help="Subtitle language to save beside the video (repeat for several).",
|
|
168
|
+
rich_help_panel=SELECTION,
|
|
169
|
+
),
|
|
170
|
+
]
|
|
171
|
+
SubtitleName = Annotated[
|
|
172
|
+
list[str] | None,
|
|
173
|
+
typer.Option(
|
|
174
|
+
"--subtitle-name",
|
|
175
|
+
help="Save the subtitle track with this exact name (repeatable).",
|
|
176
|
+
rich_help_panel=SELECTION,
|
|
177
|
+
),
|
|
178
|
+
]
|
|
179
|
+
VideoOnly = Annotated[
|
|
180
|
+
bool,
|
|
181
|
+
typer.Option(
|
|
182
|
+
"--video-only",
|
|
183
|
+
envvar="RAYOHX_VIDEO_ONLY",
|
|
184
|
+
help="Download only the video, leaving out separate audio and subtitle tracks.",
|
|
185
|
+
rich_help_panel=SELECTION,
|
|
186
|
+
),
|
|
187
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Showing a download's events: a progress bar, plain lines, or nothing.
|
|
2
|
+
|
|
3
|
+
The library reports what happens as events. These reporters turn them into text, using the
|
|
4
|
+
error console (stderr) so that a command's result on stdout stays clean.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from rayohx_cli.progress._factory import MODES, make_reporter
|
|
8
|
+
from rayohx_cli.progress._text import narrate
|
|
9
|
+
from rayohx_cli.progress.reporters import (
|
|
10
|
+
BarReporter,
|
|
11
|
+
NullReporter,
|
|
12
|
+
PlainReporter,
|
|
13
|
+
Reporter,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"MODES",
|
|
18
|
+
"BarReporter",
|
|
19
|
+
"NullReporter",
|
|
20
|
+
"PlainReporter",
|
|
21
|
+
"Reporter",
|
|
22
|
+
"make_reporter",
|
|
23
|
+
"narrate",
|
|
24
|
+
]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Choosing how to show a download's progress."""
|
|
2
|
+
|
|
3
|
+
from rich.console import Console
|
|
4
|
+
|
|
5
|
+
from rayohx_cli.progress.reporters import BarReporter, NullReporter, PlainReporter, Reporter
|
|
6
|
+
|
|
7
|
+
MODES = ("auto", "bar", "plain", "none")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def make_reporter(
|
|
11
|
+
mode: str, console: Console, *, quiet: bool, json_output: bool, verbose: bool
|
|
12
|
+
) -> Reporter:
|
|
13
|
+
"""Choose how to show progress. Quiet and JSON output show none."""
|
|
14
|
+
if quiet or json_output or mode == "none":
|
|
15
|
+
return NullReporter()
|
|
16
|
+
if mode == "plain":
|
|
17
|
+
return PlainReporter(console, verbose=verbose)
|
|
18
|
+
if mode == "bar" or (mode == "auto" and console.is_terminal):
|
|
19
|
+
return BarReporter(console, verbose=verbose)
|
|
20
|
+
return PlainReporter(console, verbose=verbose)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Turning download events into text for the reporters."""
|
|
2
|
+
|
|
3
|
+
from rayohx import DownloadProgress, EventType
|
|
4
|
+
from rayohx.events import DownloadEvent
|
|
5
|
+
|
|
6
|
+
from rayohx_cli import format as fmt
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def narrate(event: DownloadEvent, *, verbose: bool = False) -> list[str]:
|
|
10
|
+
"""What an event means to a person, as lines of text (usually none or one)."""
|
|
11
|
+
kind = event.type
|
|
12
|
+
data = event.data
|
|
13
|
+
if kind is EventType.STREAM_SELECTED:
|
|
14
|
+
parts = [str(data["resolution"])] if data.get("resolution") else []
|
|
15
|
+
parts.append(fmt.bitrate(int(data["bandwidth"])))
|
|
16
|
+
codecs = ", ".join(data.get("codecs") or [])
|
|
17
|
+
lines = [f"Stream: {', '.join(parts)}" + (f" ({codecs})" if codecs else "")]
|
|
18
|
+
lines += [f"Note: {note}" for note in data.get("notes", [])]
|
|
19
|
+
return lines
|
|
20
|
+
if kind is EventType.PLAYLIST_LOADED:
|
|
21
|
+
if data.get("audio"):
|
|
22
|
+
return [f"Audio track: {data['audio']}"]
|
|
23
|
+
if data.get("subtitles"):
|
|
24
|
+
return [f"Subtitles: {data['subtitles']}"]
|
|
25
|
+
return [f"Loaded the {data.get('kind', '')} playlist"] if verbose else []
|
|
26
|
+
if kind is EventType.FINALIZATION_STARTED:
|
|
27
|
+
return ["Finalizing..."]
|
|
28
|
+
if kind is EventType.SEGMENT_FAILED:
|
|
29
|
+
return [f"Segment {event.segment_index} failed: {event.message}"]
|
|
30
|
+
if kind is EventType.DOWNLOAD_STARTED and verbose:
|
|
31
|
+
return [f"Downloading {event.message}"]
|
|
32
|
+
return []
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def detail(progress: DownloadProgress) -> str:
|
|
36
|
+
parts = [fmt.size(progress.downloaded_bytes)]
|
|
37
|
+
if progress.speed > 0:
|
|
38
|
+
parts.append(fmt.rate(progress.speed))
|
|
39
|
+
if progress.eta_seconds is not None:
|
|
40
|
+
parts.append(f"ETA {fmt.duration(progress.eta_seconds)}")
|
|
41
|
+
return " ".join(parts)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def percent(progress: DownloadProgress) -> float:
|
|
45
|
+
if progress.total_segments:
|
|
46
|
+
return min(1.0, progress.completed_segments / progress.total_segments)
|
|
47
|
+
return 0.0
|