Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

🐛 fix: fix lifetime is None #27

Merged
merged 1 commit into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions biliass/biliass.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import re
import xml.dom.minidom
from collections.abc import Generator
from typing import Callable, Tuple, Union
from typing import Callable, Tuple, TypeVar, Union

from biliass.protobuf.danmaku_pb2 import DanmakuEvent

Expand Down Expand Up @@ -41,6 +41,7 @@
#


T = TypeVar("T")
Comment = Tuple[float, float, int, str, Union[int, str], int, float, float, float]


Expand Down Expand Up @@ -200,7 +201,7 @@ def GetPosition(InputPos, isHeight):
to_alpha = 255 - round(to_alpha * 255)
rotate_z = int(comment_args.get(5, 0))
rotate_y = int(comment_args.get(6, 0))
lifetime = float(comment_args.get(3, 4500))
lifetime = float(wrap_default(comment_args.get(3, 4500), 4500))
duration = int(comment_args.get(9, lifetime * 1000))
delay = int(comment_args.get(10, 0))
fontface = comment_args.get(12)
Expand Down Expand Up @@ -577,6 +578,10 @@ def get(self, index, default=None):
return default


def wrap_default(value: T | None, default: T) -> T:
return default if value is None else value


def Danmaku2ASS(
inputs: list[str | bytes] | str | bytes,
stage_width: int,
Expand Down
Loading