easyrip 4.10.0__tar.gz → 4.11.0__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.
Files changed (36) hide show
  1. {easyrip-4.10.0 → easyrip-4.11.0}/PKG-INFO +1 -1
  2. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/global_val.py +1 -1
  3. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/ripper/sub_and_font/ass.py +86 -6
  4. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip.egg-info/PKG-INFO +1 -1
  5. {easyrip-4.10.0 → easyrip-4.11.0}/LICENSE +0 -0
  6. {easyrip-4.10.0 → easyrip-4.11.0}/README.md +0 -0
  7. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/__init__.py +0 -0
  8. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/__main__.py +0 -0
  9. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/easyrip_command.py +0 -0
  10. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/easyrip_config/config.py +0 -0
  11. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/easyrip_config/config_key.py +0 -0
  12. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/easyrip_log.py +0 -0
  13. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/easyrip_main.py +0 -0
  14. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/easyrip_mlang/__init__.py +0 -0
  15. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/easyrip_mlang/global_lang_val.py +0 -0
  16. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/easyrip_mlang/lang_en.py +0 -0
  17. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/easyrip_mlang/lang_zh_Hans_CN.py +0 -0
  18. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/easyrip_mlang/translator.py +0 -0
  19. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/easyrip_prompt.py +0 -0
  20. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/easyrip_web/__init__.py +0 -0
  21. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/easyrip_web/http_server.py +0 -0
  22. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/easyrip_web/third_party_api.py +0 -0
  23. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/ripper/media_info.py +0 -0
  24. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/ripper/param.py +0 -0
  25. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/ripper/ripper.py +0 -0
  26. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/ripper/sub_and_font/__init__.py +0 -0
  27. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/ripper/sub_and_font/font.py +0 -0
  28. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/ripper/sub_and_font/subset.py +0 -0
  29. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip/utils.py +0 -0
  30. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip.egg-info/SOURCES.txt +0 -0
  31. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip.egg-info/dependency_links.txt +0 -0
  32. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip.egg-info/entry_points.txt +0 -0
  33. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip.egg-info/requires.txt +0 -0
  34. {easyrip-4.10.0 → easyrip-4.11.0}/easyrip.egg-info/top_level.txt +0 -0
  35. {easyrip-4.10.0 → easyrip-4.11.0}/pyproject.toml +0 -0
  36. {easyrip-4.10.0 → easyrip-4.11.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: easyrip
3
- Version: 4.10.0
3
+ Version: 4.11.0
4
4
  Author: op200
5
5
  License-Expression: AGPL-3.0-or-later
6
6
  Project-URL: Homepage, https://github.com/op200/EasyRip
@@ -3,7 +3,7 @@ import sys
3
3
  from pathlib import Path
4
4
 
5
5
  PROJECT_NAME = "Easy Rip"
6
- PROJECT_VERSION = "4.10.0"
6
+ PROJECT_VERSION = "4.11.0"
7
7
  PROJECT_TITLE = f"{PROJECT_NAME} v{PROJECT_VERSION}"
8
8
  PROJECT_URL = "https://github.com/op200/EasyRip"
9
9
  PROJECT_RELEASE_API = "https://api.github.com/repos/op200/EasyRip/releases/latest"
@@ -2,11 +2,13 @@ import enum
2
2
  import itertools
3
3
  import re
4
4
  from dataclasses import dataclass, field
5
+ from functools import total_ordering
5
6
  from pathlib import Path
7
+ from typing import Self
6
8
 
7
9
  from ...easyrip_log import log
8
10
  from ...easyrip_mlang import Mlang_exception
9
- from ...utils import read_text, uudecode_ssa, uuencode_ssa
11
+ from ...utils import read_text, time_str_to_sec, uudecode_ssa, uuencode_ssa
10
12
 
11
13
 
12
14
  class Style_fmt_it(enum.Enum):
@@ -264,6 +266,75 @@ class Styles:
264
266
  )
265
267
 
266
268
 
269
+ @total_ordering
270
+ class Ass_time:
271
+ def __init__(
272
+ self,
273
+ h: int = 0,
274
+ m: int = 0,
275
+ s: int = 0,
276
+ ms: int = 0,
277
+ ) -> None:
278
+ self.h = h
279
+ self.m = m
280
+ self.s = s
281
+ self.ms = ms
282
+
283
+ def __str__(self) -> str:
284
+ return f"{self.h:02d}:{self.m:02d}:{self.s:02d}.{self.ms // 10:02d}"
285
+
286
+ def __hash__(self) -> int:
287
+ return hash((self.h, self.m, self.s, self.ms))
288
+
289
+ def __eq__(self, value: object) -> bool:
290
+ if isinstance(value, Ass_time):
291
+ return (self.h, self.m, self.s, self.ms) == (
292
+ value.h,
293
+ value.m,
294
+ value.s,
295
+ value.ms,
296
+ )
297
+ return NotImplemented
298
+
299
+ def __lt__(self, value: object) -> bool:
300
+ if isinstance(value, Ass_time):
301
+ return (self.h, self.m, self.s, self.ms) < (
302
+ value.h,
303
+ value.m,
304
+ value.s,
305
+ value.ms,
306
+ )
307
+ return NotImplemented
308
+
309
+ def __add__(self, other: object) -> Self:
310
+ if isinstance(other, Ass_time):
311
+ return self.__class__.from_ms(self.total_ms() + other.total_ms())
312
+ return NotImplemented
313
+
314
+ def __sub__(self, other: object) -> Self:
315
+ if isinstance(other, Ass_time):
316
+ return self.__class__.from_ms(self.total_ms() - other.total_ms())
317
+ return NotImplemented
318
+
319
+ @classmethod
320
+ def from_ms(cls, ms: int) -> Self:
321
+ return cls(
322
+ ms // 3_600_000,
323
+ (ms % 3_600_000) // 60_000,
324
+ (ms % 60_000) // 1000,
325
+ ms % 1000,
326
+ )
327
+
328
+ @classmethod
329
+ def from_str(cls, ass_time_str: str) -> Self:
330
+ return cls.from_ms(
331
+ round(time_str_to_sec(ass_time_str) * 1000),
332
+ )
333
+
334
+ def total_ms(self) -> int:
335
+ return self.h * 3_600_000 + self.m * 60_000 + self.s * 1000 + self.ms
336
+
337
+
267
338
  class Event_fmt_it(enum.Enum):
268
339
  Layer = "Layer"
269
340
  Start = "Start"
@@ -291,8 +362,8 @@ class Event_data:
291
362
  type: Event_type
292
363
 
293
364
  Layer: int
294
- Start: str
295
- End: str
365
+ Start: Ass_time
366
+ End: Ass_time
296
367
  Style: str
297
368
  Name: str
298
369
  MarginL: int
@@ -451,8 +522,12 @@ class Events:
451
522
  res = Event_data(
452
523
  type=event_type,
453
524
  Layer=int(event_tuple[self.fmt_index[Event_fmt_it.Layer]]),
454
- Start=event_tuple[self.fmt_index[Event_fmt_it.Start]],
455
- End=event_tuple[self.fmt_index[Event_fmt_it.End]],
525
+ Start=Ass_time.from_str(
526
+ event_tuple[self.fmt_index[Event_fmt_it.Start]],
527
+ ),
528
+ End=Ass_time.from_str(
529
+ event_tuple[self.fmt_index[Event_fmt_it.End]],
530
+ ),
456
531
  Style=event_tuple[self.fmt_index[Event_fmt_it.Style]],
457
532
  Name=event_tuple[self.fmt_index[Event_fmt_it.Name]],
458
533
  MarginL=int(event_tuple[self.fmt_index[Event_fmt_it.MarginL]]),
@@ -496,7 +571,11 @@ class Events:
496
571
  )
497
572
  for event in self.data
498
573
  if (drop_non_render is False)
499
- or (event.type != Event_type.Comment and event.Text)
574
+ or (
575
+ event.type != Event_type.Comment
576
+ and event.Text
577
+ and event.Start < event.End
578
+ )
500
579
  ),
501
580
  )
502
581
  )
@@ -762,6 +841,7 @@ class Ass:
762
841
 
763
842
  def __str__(
764
843
  self,
844
+ *,
765
845
  drop_non_render: bool = False,
766
846
  drop_unkow_data: bool = False,
767
847
  drop_fonts: bool = False,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: easyrip
3
- Version: 4.10.0
3
+ Version: 4.11.0
4
4
  Author: op200
5
5
  License-Expression: AGPL-3.0-or-later
6
6
  Project-URL: Homepage, https://github.com/op200/EasyRip
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes