Skip to content

Commit 91ab698

Browse files
authored
build: release 0.0.2 (#23)
1 parent 74decca commit 91ab698

File tree

7 files changed

+32
-11
lines changed

7 files changed

+32
-11
lines changed

README-en.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ More details:
4747

4848
```bash
4949
dmconvert -h
50-
# usage: dmconvert [-h] [-V] [-f FONTSIZE] [-x RESOLUTIONX] [-y RESOLUTIONY] -i XML [-o ASS]
51-
# The Python toolkit package and cli designed for convert danmaku to ass.
52-
# options:
50+
# optional arguments:
5351
# -h, --help show this help message and exit
5452
# -V, --version Print version information
5553
# -f FONTSIZE, --fontsize FONTSIZE
@@ -60,6 +58,9 @@ dmconvert -h
6058
# The resolution y of the danmaku, default is 1080
6159
# -i XML, --xml XML The input xml file
6260
# -o ASS, --ass ASS The output ass file
61+
62+
# Example:
63+
# dmconvert -f 38 -x 1920 -y 1080 -i sample.xml -o sample.ass
6364
```
6465

6566
### Source Version

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ dmconvert -i sample.xml
4545

4646
```bash
4747
dmconvert -h
48-
# usage: dmconvert [-h] [-V] [-f FONTSIZE] [-x RESOLUTIONX] [-y RESOLUTIONY] -i XML [-o ASS]
49-
# The Python toolkit package and cli designed for convert danmaku to ass.
50-
# options:
48+
# optional arguments:
5149
# -h, --help show this help message and exit
5250
# -V, --version Print version information
5351
# -f FONTSIZE, --fontsize FONTSIZE
@@ -58,6 +56,9 @@ dmconvert -h
5856
# The resolution y of the danmaku, default is 1080
5957
# -i XML, --xml XML The input xml file
6058
# -o ASS, --ass ASS The output ass file
59+
60+
# Example:
61+
# dmconvert -f 38 -x 1920 -y 1080 -i sample.xml -o sample.ass
6162
```
6263

6364
### 直接引用

dmconvert/cli.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,28 @@
44
import sys
55
import os
66
import logging
7+
import textwrap
78
from dmconvert.convert import convert_xml_to_ass
89

910

1011
def cli():
1112
parser = argparse.ArgumentParser(
12-
description="The Python toolkit package and cli designed for convert danmaku to ass."
13+
prog="dmconvert",
14+
formatter_class=argparse.RawDescriptionHelpFormatter,
15+
description=textwrap.dedent('''
16+
The Python toolkit package and cli designed for convert danmaku from xml to ass format.
17+
Source code at https://github.com/timerring/DanmakuConvert
18+
'''),
19+
epilog=textwrap.dedent('''
20+
Example:
21+
dmconvert -f 38 -x 1920 -y 1080 -i input.xml -o output.ass
22+
'''),
1323
)
1424
parser.add_argument(
1525
"-V",
1626
"--version",
1727
action="version",
18-
version="dmconvert 0.0.1",
28+
version="dmconvert 0.0.2 and source code at https://github.com/timerring/DanmakuConvert",
1929
help="Print version information",
2030
)
2131
parser.add_argument(

dmconvert/convert.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
def convert_xml_to_ass(font_size, resolution_x, resolution_y, xml_file, ass_file):
1515
# Parse XML
16+
print("DanmakuConvert v0.0.2", flush=True)
17+
print("https://github.com/timerring/DanmakuConvert", flush=True)
1618
tree = ET.parse(xml_file)
1719
root = tree.getroot()
1820
roll_array = DanmakuArray(resolution_x, resolution_y)
@@ -23,6 +25,7 @@ def convert_xml_to_ass(font_size, resolution_x, resolution_y, xml_file, ass_file
2325
)
2426
draw_gift_and_guard(ass_file, root, font_size, resolution_y)
2527
draw_superchat(ass_file, font_size, resolution_y, root)
28+
print(f"Convert {xml_file} to {ass_file} successfully.", flush=True)
2629

2730

2831
if __name__ == "__main__":

dmconvert/normal/normal_handler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ def draw_normal_danmaku(
6666
):
6767
with open(ass_file, "a", encoding="utf-8") as f:
6868
# Convert each danmaku
69-
for d in root.findall(".//d"):
69+
all_normal_danmaku = root.findall(".//d")
70+
danmaku_count = len(all_normal_danmaku)
71+
print(f"The normal danmaku pool is {danmaku_count}.", flush=True)
72+
for d in all_normal_danmaku:
7073
# Parse attributes
7174
p_attrs = d.get("p").split(",")
7275
appear_time = float(p_attrs[0])

dmconvert/superchat/superchat_handler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ def get_sc_height(line_num, sc_font_size=38):
3030

3131
def draw_superchat(ass_file, font_size, resolution_y, root):
3232
sc_list = []
33-
for sc in root.findall(".//sc"):
33+
all_superchat = root.findall(".//sc")
34+
superchat_count = len(all_superchat)
35+
print(f"The superchat pool is {superchat_count}.", flush=True)
36+
for sc in all_superchat:
3437
appear_time = float(sc.get("ts"))
3538
user_name = sc.get("user")
3639
price = sc.get("price")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "dmconvert"
7-
version = "0.0.1"
7+
version = "0.0.2"
88
authors = [
99
{ name="timerring"},
1010
]

0 commit comments

Comments
 (0)