easyrip 3.13.2__py3-none-any.whl → 4.9.1__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.
Files changed (36) hide show
  1. easyrip/__init__.py +5 -1
  2. easyrip/__main__.py +124 -15
  3. easyrip/easyrip_command.py +457 -148
  4. easyrip/easyrip_config/config.py +269 -0
  5. easyrip/easyrip_config/config_key.py +28 -0
  6. easyrip/easyrip_log.py +120 -42
  7. easyrip/easyrip_main.py +509 -259
  8. easyrip/easyrip_mlang/__init__.py +20 -45
  9. easyrip/easyrip_mlang/global_lang_val.py +18 -16
  10. easyrip/easyrip_mlang/lang_en.py +1 -1
  11. easyrip/easyrip_mlang/lang_zh_Hans_CN.py +101 -77
  12. easyrip/easyrip_mlang/translator.py +12 -10
  13. easyrip/easyrip_prompt.py +73 -0
  14. easyrip/easyrip_web/__init__.py +2 -1
  15. easyrip/easyrip_web/http_server.py +56 -42
  16. easyrip/easyrip_web/third_party_api.py +60 -8
  17. easyrip/global_val.py +21 -1
  18. easyrip/ripper/media_info.py +10 -3
  19. easyrip/ripper/param.py +482 -0
  20. easyrip/ripper/ripper.py +260 -574
  21. easyrip/ripper/sub_and_font/__init__.py +10 -0
  22. easyrip/ripper/{font_subset → sub_and_font}/ass.py +95 -84
  23. easyrip/ripper/{font_subset → sub_and_font}/font.py +72 -79
  24. easyrip/ripper/{font_subset → sub_and_font}/subset.py +122 -81
  25. easyrip/utils.py +129 -27
  26. easyrip-4.9.1.dist-info/METADATA +92 -0
  27. easyrip-4.9.1.dist-info/RECORD +31 -0
  28. easyrip/easyrip_config.py +0 -198
  29. easyrip/ripper/__init__.py +0 -10
  30. easyrip/ripper/font_subset/__init__.py +0 -7
  31. easyrip-3.13.2.dist-info/METADATA +0 -89
  32. easyrip-3.13.2.dist-info/RECORD +0 -29
  33. {easyrip-3.13.2.dist-info → easyrip-4.9.1.dist-info}/WHEEL +0 -0
  34. {easyrip-3.13.2.dist-info → easyrip-4.9.1.dist-info}/entry_points.txt +0 -0
  35. {easyrip-3.13.2.dist-info → easyrip-4.9.1.dist-info}/licenses/LICENSE +0 -0
  36. {easyrip-3.13.2.dist-info → easyrip-4.9.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,482 @@
1
+ import enum
2
+ import textwrap
3
+ from functools import reduce
4
+ from typing import Final, LiteralString
5
+
6
+
7
+ class Preset_name(enum.Enum):
8
+ custom = "custom"
9
+
10
+ subset = "subset"
11
+
12
+ flac = "flac"
13
+
14
+ copy = "copy"
15
+
16
+ x264 = "x264"
17
+ x264fast = "x264fast"
18
+ x264slow = "x264slow"
19
+
20
+ x265 = "x265"
21
+ x265fast4 = "x265fast4"
22
+ x265fast3 = "x265fast3"
23
+ x265fast2 = "x265fast2"
24
+ x265fast = "x265fast"
25
+ x265slow = "x265slow"
26
+ x265full = "x265full"
27
+
28
+ svtav1 = "svtav1"
29
+
30
+ vvenc = "vvenc"
31
+
32
+ h264_amf = "h264_amf"
33
+ h264_nvenc = "h264_nvenc"
34
+ h264_qsv = "h264_qsv"
35
+
36
+ hevc_amf = "hevc_amf"
37
+ hevc_nvenc = "hevc_nvenc"
38
+ hevc_qsv = "hevc_qsv"
39
+
40
+ av1_amf = "av1_amf"
41
+ av1_nvenc = "av1_nvenc"
42
+ av1_qsv = "av1_qsv"
43
+
44
+ @classmethod
45
+ def _missing_(cls, value: object):
46
+ from ..easyrip_log import log
47
+
48
+ DEFAULT = cls.custom
49
+ log.error(
50
+ "'{}' is not a valid '{}', set to default value '{}'. Valid options are: {}",
51
+ value,
52
+ cls.__name__,
53
+ DEFAULT.name,
54
+ list(cls.__members__.values()),
55
+ )
56
+ return DEFAULT
57
+
58
+ @classmethod
59
+ def to_help_string(cls, prefix: str = ""):
60
+ return textwrap.indent(
61
+ reduce(
62
+ lambda acc,
63
+ add: f"{acc}{' ' if add.startswith(acc.split()[-1][:4]) else '\n'}{add}",
64
+ tuple[str](cls._value2member_map_),
65
+ ),
66
+ prefix=prefix,
67
+ )
68
+
69
+
70
+ class Audio_codec(enum.Enum):
71
+ copy = "copy"
72
+ libopus = "libopus"
73
+ flac = "flac"
74
+
75
+ # 别名
76
+ opus = libopus
77
+
78
+ @classmethod
79
+ def _missing_(cls, value: object):
80
+ from ..easyrip_log import log
81
+
82
+ DEFAULT = cls.copy
83
+ log.error(
84
+ "'{}' is not a valid '{}', set to default value '{}'. Valid options are: {}",
85
+ value,
86
+ cls.__name__,
87
+ DEFAULT.name,
88
+ list(cls.__members__.values()),
89
+ )
90
+ return DEFAULT
91
+
92
+ @classmethod
93
+ def to_help_string(cls, prefix: str = ""):
94
+ return textwrap.indent(
95
+ reduce(
96
+ lambda acc,
97
+ add: f"{acc}{' ' if add.endswith(acc.split()[-1][-4:]) else '\n'}{add}",
98
+ tuple[str](cls._member_map_),
99
+ ),
100
+ prefix=prefix,
101
+ )
102
+
103
+
104
+ class Muxer(enum.Enum):
105
+ mp4 = "mp4"
106
+ mkv = "mkv"
107
+
108
+ @classmethod
109
+ def _missing_(cls, value: object):
110
+ from ..easyrip_log import log
111
+
112
+ DEFAULT = cls.mkv
113
+ log.error(
114
+ "'{}' is not a valid '{}', set to default value '{}'. Valid options are: {}",
115
+ value,
116
+ cls.__name__,
117
+ DEFAULT.name,
118
+ list(cls.__members__.values()),
119
+ )
120
+ return DEFAULT
121
+
122
+
123
+ X265_PARAMS_NAME: Final[tuple[LiteralString, ...]] = (
124
+ "crf",
125
+ "qpmin",
126
+ "qpmax",
127
+ "psy-rd",
128
+ "rd",
129
+ "rdoq-level",
130
+ "psy-rdoq",
131
+ "qcomp",
132
+ "keyint",
133
+ "min-keyint",
134
+ "deblock",
135
+ "me",
136
+ "merange",
137
+ "hme",
138
+ "hme-search",
139
+ "hme-range",
140
+ "aq-mode",
141
+ "aq-strength",
142
+ "tu-intra-depth",
143
+ "tu-inter-depth",
144
+ "limit-tu",
145
+ "bframes",
146
+ "ref",
147
+ "subme",
148
+ "open-gop",
149
+ "gop-lookahead",
150
+ "rc-lookahead",
151
+ "rect",
152
+ "amp",
153
+ "cbqpoffs",
154
+ "crqpoffs",
155
+ "ipratio",
156
+ "pbratio",
157
+ "early-skip",
158
+ "ctu",
159
+ "min-cu-size",
160
+ "max-tu-size",
161
+ "level-idc",
162
+ "sao",
163
+ )
164
+ X264_PARAMS_NAME: Final[tuple[LiteralString, ...]] = (
165
+ "threads",
166
+ "crf",
167
+ "psy-rd",
168
+ "qcomp",
169
+ "keyint",
170
+ "deblock",
171
+ "qpmin",
172
+ "qpmax",
173
+ "bframes",
174
+ "ref",
175
+ "subme",
176
+ "me",
177
+ "merange",
178
+ "aq-mode",
179
+ "rc-lookahead",
180
+ "min-keyint",
181
+ "trellis",
182
+ "fast-pskip",
183
+ "partitions",
184
+ "direct",
185
+ )
186
+
187
+
188
+ _DEFAULT_X265_PARAMS: Final[dict[LiteralString, LiteralString]] = {
189
+ "crf": "20",
190
+ "qpmin": "6",
191
+ "qpmax": "32",
192
+ "rd": "3",
193
+ "psy-rd": "2",
194
+ "rdoq-level": "0",
195
+ "psy-rdoq": "0",
196
+ "qcomp": "0.68",
197
+ "keyint": "250",
198
+ "min-keyint": "2",
199
+ "deblock": "0,0",
200
+ "me": "umh",
201
+ "merange": "57",
202
+ "hme": "1",
203
+ "hme-search": "hex,hex,hex",
204
+ "hme-range": "16,57,92",
205
+ "aq-mode": "2",
206
+ "aq-strength": "1",
207
+ "tu-intra-depth": "1",
208
+ "tu-inter-depth": "1",
209
+ "limit-tu": "0",
210
+ "bframes": "16",
211
+ "ref": "8",
212
+ "subme": "2",
213
+ "open-gop": "1",
214
+ "gop-lookahead": "0",
215
+ "rc-lookahead": "20",
216
+ "rect": "0",
217
+ "amp": "0",
218
+ "cbqpoffs": "0",
219
+ "crqpoffs": "0",
220
+ "ipratio": "1.4",
221
+ "pbratio": "1.3",
222
+ "early-skip": "1",
223
+ "ctu": "64",
224
+ "min-cu-size": "8",
225
+ "max-tu-size": "32",
226
+ "level-idc": "0",
227
+ "sao": "0",
228
+ "weightb": "1",
229
+ "info": "1",
230
+ }
231
+
232
+
233
+ PRESET_OPT_NAME: Final[dict[Preset_name, tuple[LiteralString, ...]]] = {
234
+ Preset_name.x264: X264_PARAMS_NAME,
235
+ Preset_name.x264fast: X264_PARAMS_NAME,
236
+ Preset_name.x264slow: X264_PARAMS_NAME,
237
+ Preset_name.x265: X265_PARAMS_NAME,
238
+ Preset_name.x265fast4: X265_PARAMS_NAME,
239
+ Preset_name.x265fast3: X265_PARAMS_NAME,
240
+ Preset_name.x265fast2: X265_PARAMS_NAME,
241
+ Preset_name.x265fast: X265_PARAMS_NAME,
242
+ Preset_name.x265slow: X265_PARAMS_NAME,
243
+ Preset_name.x265full: X265_PARAMS_NAME,
244
+ }
245
+ DEFAULT_PRESET_PARAMS: Final[dict[Preset_name, dict[LiteralString, LiteralString]]] = {
246
+ Preset_name.x264fast: {
247
+ "threads": "auto",
248
+ "crf": "20",
249
+ "psy-rd": "0.6,0.15",
250
+ "qcomp": "0.66",
251
+ "keyint": "250",
252
+ "deblock": "0,0",
253
+ "qpmin": "8",
254
+ "qpmax": "32",
255
+ "bframes": "8",
256
+ "ref": "4",
257
+ "subme": "5",
258
+ "me": "hex",
259
+ "merange": "16",
260
+ "aq-mode": "1",
261
+ "rc-lookahead": "60",
262
+ "min-keyint": "2",
263
+ "trellis": "1",
264
+ "fast-pskip": "1",
265
+ "weightb": "1",
266
+ "partitions": "all",
267
+ "direct": "auto",
268
+ },
269
+ Preset_name.x264slow: {
270
+ "threads": "auto",
271
+ "crf": "21",
272
+ "psy-rd": "0.6,0.15",
273
+ "qcomp": "0.66",
274
+ "keyint": "250",
275
+ "deblock": "-1,-1",
276
+ "qpmin": "8",
277
+ "qpmax": "32",
278
+ "bframes": "16",
279
+ "ref": "8",
280
+ "subme": "7",
281
+ "me": "umh",
282
+ "merange": "24",
283
+ "aq-mode": "3",
284
+ "rc-lookahead": "120",
285
+ "min-keyint": "2",
286
+ "trellis": "2",
287
+ "fast-pskip": "0",
288
+ "weightb": "1",
289
+ "partitions": "all",
290
+ "direct": "auto",
291
+ },
292
+ Preset_name.x265fast4: _DEFAULT_X265_PARAMS
293
+ | dict[LiteralString, LiteralString](
294
+ {
295
+ "crf": "18",
296
+ "qpmin": "12",
297
+ "qpmax": "28",
298
+ "rd": "2",
299
+ "rdoq-level": "1",
300
+ "me": "hex",
301
+ "merange": "57",
302
+ "hme-search": "hex,hex,hex",
303
+ "hme-range": "16,32,48",
304
+ "aq-mode": "1",
305
+ "tu-intra-depth": "1",
306
+ "tu-inter-depth": "1",
307
+ "limit-tu": "4",
308
+ "bframes": "8",
309
+ "ref": "6",
310
+ "subme": "3",
311
+ "open-gop": "0",
312
+ "gop-lookahead": "0",
313
+ "rc-lookahead": "48",
314
+ "cbqpoffs": "-1",
315
+ "crqpoffs": "-1",
316
+ "pbratio": "1.28",
317
+ }
318
+ ),
319
+ Preset_name.x265fast3: _DEFAULT_X265_PARAMS
320
+ | dict[LiteralString, LiteralString](
321
+ {
322
+ "crf": "18",
323
+ "qpmin": "12",
324
+ "qpmax": "28",
325
+ "rdoq-level": "1",
326
+ "deblock": "-0.5,-0.5",
327
+ "me": "hex",
328
+ "merange": "57",
329
+ "hme-search": "hex,hex,hex",
330
+ "hme-range": "16,32,57",
331
+ "aq-mode": "3",
332
+ "tu-intra-depth": "2",
333
+ "tu-inter-depth": "2",
334
+ "limit-tu": "4",
335
+ "bframes": "12",
336
+ "ref": "6",
337
+ "subme": "3",
338
+ "open-gop": "0",
339
+ "gop-lookahead": "0",
340
+ "rc-lookahead": "120",
341
+ "cbqpoffs": "-1",
342
+ "crqpoffs": "-1",
343
+ "pbratio": "1.27",
344
+ }
345
+ ),
346
+ Preset_name.x265fast2: _DEFAULT_X265_PARAMS
347
+ | dict[LiteralString, LiteralString](
348
+ {
349
+ "crf": "18",
350
+ "qpmin": "12",
351
+ "qpmax": "28",
352
+ "rdoq-level": "2",
353
+ "deblock": "-1,-1",
354
+ "me": "hex",
355
+ "merange": "57",
356
+ "hme-search": "hex,hex,hex",
357
+ "hme-range": "16,57,92",
358
+ "aq-mode": "3",
359
+ "tu-intra-depth": "3",
360
+ "tu-inter-depth": "2",
361
+ "limit-tu": "4",
362
+ "ref": "6",
363
+ "subme": "4",
364
+ "open-gop": "0",
365
+ "gop-lookahead": "0",
366
+ "rc-lookahead": "192",
367
+ "cbqpoffs": "-1",
368
+ "crqpoffs": "-1",
369
+ "pbratio": "1.25",
370
+ }
371
+ ),
372
+ Preset_name.x265fast: _DEFAULT_X265_PARAMS
373
+ | dict[LiteralString, LiteralString](
374
+ {
375
+ "crf": "18",
376
+ "qpmin": "12",
377
+ "qpmax": "28",
378
+ "psy-rd": "1.8",
379
+ "rdoq-level": "2",
380
+ "psy-rdoq": "0.4",
381
+ "keyint": "312",
382
+ "deblock": "-1,-1",
383
+ "me": "umh",
384
+ "merange": "57",
385
+ "hme-search": "umh,hex,hex",
386
+ "hme-range": "16,57,92",
387
+ "aq-mode": "4",
388
+ "tu-intra-depth": "4",
389
+ "tu-inter-depth": "3",
390
+ "limit-tu": "4",
391
+ "subme": "5",
392
+ "gop-lookahead": "8",
393
+ "rc-lookahead": "216",
394
+ "cbqpoffs": "-2",
395
+ "crqpoffs": "-2",
396
+ "pbratio": "1.2",
397
+ }
398
+ ),
399
+ Preset_name.x265slow: _DEFAULT_X265_PARAMS
400
+ | dict[LiteralString, LiteralString](
401
+ {
402
+ "crf": "17.5",
403
+ "qpmin": "12",
404
+ "qpmax": "28",
405
+ "rd": "5",
406
+ "psy-rd": "1.8",
407
+ "rdoq-level": "2",
408
+ "psy-rdoq": "0.4",
409
+ "qcomp": "0.7",
410
+ "keyint": "312",
411
+ "deblock": "-1,-1",
412
+ "me": "umh",
413
+ "merange": "57",
414
+ "hme-search": "umh,hex,hex",
415
+ "hme-range": "16,57,184",
416
+ "aq-mode": "4",
417
+ "aq-strength": "1",
418
+ "tu-intra-depth": "4",
419
+ "tu-inter-depth": "3",
420
+ "limit-tu": "2",
421
+ "subme": "6",
422
+ "gop-lookahead": "14",
423
+ "rc-lookahead": "250",
424
+ "rect": "1",
425
+ "min-keyint": "2",
426
+ "cbqpoffs": "-2",
427
+ "crqpoffs": "-2",
428
+ "pbratio": "1.2",
429
+ "early-skip": "0",
430
+ }
431
+ ),
432
+ Preset_name.x265full: _DEFAULT_X265_PARAMS
433
+ | dict[LiteralString, LiteralString](
434
+ {
435
+ "crf": "17",
436
+ "qpmin": "3",
437
+ "qpmax": "21.5",
438
+ "psy-rd": "2.2",
439
+ "rd": "5",
440
+ "rdoq-level": "2",
441
+ "psy-rdoq": "1.6",
442
+ "qcomp": "0.72",
443
+ "keyint": "266",
444
+ "min-keyint": "2",
445
+ "deblock": "-1,-1",
446
+ "me": "umh",
447
+ "merange": "160",
448
+ "hme-search": "full,umh,hex",
449
+ "hme-range": "16,92,320",
450
+ "aq-mode": "4",
451
+ "aq-strength": "1.2",
452
+ "tu-intra-depth": "4",
453
+ "tu-inter-depth": "4",
454
+ "limit-tu": "2",
455
+ "subme": "7",
456
+ "open-gop": "1",
457
+ "gop-lookahead": "14",
458
+ "rc-lookahead": "250",
459
+ "rect": "1",
460
+ "amp": "1",
461
+ "cbqpoffs": "-3",
462
+ "crqpoffs": "-3",
463
+ "ipratio": "1.43",
464
+ "pbratio": "1.2",
465
+ "early-skip": "0",
466
+ }
467
+ ),
468
+ }
469
+
470
+
471
+ SUBTITLE_SUFFIX_SET: Final[set[LiteralString]] = {
472
+ ".srt",
473
+ ".ass",
474
+ ".ssa",
475
+ ".sup",
476
+ ".idx",
477
+ }
478
+ FONT_SUFFIX_SET: Final[set[LiteralString]] = {
479
+ ".otf",
480
+ ".ttf",
481
+ ".ttc",
482
+ }