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

Commit

Permalink
🐛 fix: fix lifetime is None (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
SigureMo authored May 21, 2024
1 parent a2ba612 commit 99198c6
Showing 1 changed file with 7 additions and 2 deletions.
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

0 comments on commit 99198c6

Please sign in to comment.