Skip to content

Commit 69aa775

Browse files
committed
✨ feat: rename Danmaku2ASS to convert_to_ass
1 parent 9707994 commit 69aa775

File tree

6 files changed

+43
-7
lines changed

6 files changed

+43
-7
lines changed

packages/biliass/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ biliass danmaku.pb -s 1920x1080 -f protobuf -o danmaku.ass
3131
```
3232

3333
```python
34-
from biliass import Danmaku2ASS
34+
from biliass import convert_to_ass
3535

3636
# xml
37-
Danmaku2ASS(
37+
convert_to_ass(
3838
xml_text_or_bytes,
3939
width,
4040
height,
@@ -50,7 +50,7 @@ Danmaku2ASS(
5050
)
5151

5252
# protobuf
53-
Danmaku2ASS(
53+
convert_to_ass(
5454
protobuf_bytes, # only bytes
5555
width,
5656
height,

packages/biliass/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ authors = [
77
{ name = "Star Brilliant", email = "m13253@hotmail.com" },
88
{ name = "Nyakku Shigure", email = "sigure.qaq@gmail.com" },
99
]
10-
keywords = ["bilibili", "yutto", "Danmaku2ASS"]
10+
keywords = ["bilibili", "yutto", "danmaku", "ASS"]
1111
license = { text = "GPLv3" }
1212
classifiers = [
1313
"Operating System :: OS Independent",

packages/biliass/src/biliass/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from .biliass import (
66
Danmaku2ASS as Danmaku2ASS,
7+
convert_to_ass as convert_to_ass,
78
read_comments_bilibili_protobuf as read_comments_bilibili_protobuf,
89
read_comments_bilibili_xml as read_comments_bilibili_xml,
910
)

packages/biliass/src/biliass/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import logging
55
import sys
66

7-
from biliass import Danmaku2ASS
7+
from biliass import convert_to_ass
88
from biliass.__version__ import VERSION as biliass_version
99

1010

@@ -103,7 +103,7 @@ def main():
103103
fout = open(args.output, "w", encoding="utf-8-sig", errors="replace", newline="\r\n") # noqa: PTH123
104104
else:
105105
fout = sys.stdout
106-
output = Danmaku2ASS(
106+
output = convert_to_ass(
107107
inputs,
108108
width,
109109
height,

packages/biliass/src/biliass/biliass.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
from collections.abc import Callable
34
from typing import TypeVar, cast
45

56
from biliass._core import (
@@ -37,6 +38,40 @@ def Danmaku2ASS(
3738
duration_still: float = 5.0,
3839
comment_filter: str | None = None,
3940
is_reduce_comments: bool = False,
41+
progress_callback: Callable[[int, int], None] | None = None,
42+
) -> str:
43+
print("Function `Danmaku2ASS` is deprecated in biliass 2.0.0, Please use `convert_to_ass` instead.")
44+
if progress_callback is not None:
45+
print("`progress_callback` is deprecated in 2.0.0 and will be removed in 2.1.0")
46+
return convert_to_ass(
47+
inputs,
48+
stage_width,
49+
stage_height,
50+
input_format,
51+
reserve_blank,
52+
font_face,
53+
font_size,
54+
text_opacity,
55+
duration_marquee,
56+
duration_still,
57+
comment_filter,
58+
is_reduce_comments,
59+
)
60+
61+
62+
def convert_to_ass(
63+
inputs: list[str | bytes] | str | bytes,
64+
stage_width: int,
65+
stage_height: int,
66+
input_format: str = "xml",
67+
reserve_blank: int = 0,
68+
font_face: str = "sans-serif",
69+
font_size: float = 25.0,
70+
text_opacity: float = 1.0,
71+
duration_marquee: float = 5.0,
72+
duration_still: float = 5.0,
73+
comment_filter: str | None = None,
74+
is_reduce_comments: bool = False,
4075
) -> str:
4176
comment_filters: list[str] = [comment_filter] if comment_filter is not None else []
4277
if not isinstance(inputs, list):

tests/test_biliass/test_corpus

0 commit comments

Comments
 (0)