diff --git a/.gitignore b/.gitignore index 2a0b21c..efba7b3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ /connection.py /__pycache__ /nizika_talking.wav - +/youtube.py diff --git a/common_module.py b/common_module.py new file mode 100644 index 0000000..b052dab --- /dev/null +++ b/common_module.py @@ -0,0 +1,13 @@ +import unicodedata + + +class CommonModule: + @staticmethod + def is_wide (c: str) -> bool: + return unicodedata.east_asian_width (c) in ['F', 'W', 'A'] + + @classmethod + def string_width_per_pt (cls, string: str) -> float: + return sum ([1 if cls.is_wide (c) else .5 + for c in string.decode ('utf-8')]) + diff --git a/main.py b/main.py index 4b84b04..196b910 100644 --- a/main.py +++ b/main.py @@ -8,9 +8,8 @@ from talk import Talk import subprocess from aques import Aques from playsound import playsound - - -YOUTUBE_ID: str = 'Q0kSYNcu5Xk' +from common_module import CommonModule +from youtube import * class Main: diff --git a/youtube.sample.py b/youtube.sample.py new file mode 100644 index 0000000..1efa8f8 --- /dev/null +++ b/youtube.sample.py @@ -0,0 +1,2 @@ +YOUTUBE_ID: str = 'XXXXXXXXXXX' +