From 095b9727ce7ae6f342a44ff4883a31713002d79e Mon Sep 17 00:00:00 2001 From: sudoskys Date: Fri, 19 Jan 2024 00:02:00 +0800 Subject: [PATCH] :sparkles: feat: Add support for converting SRT to BCC --- README.md | 28 +++++++++++----------------- feature_test/direct.py | 9 +++++++++ 2 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 feature_test/direct.py diff --git a/README.md b/README.md index 7439151..05ae591 100644 --- a/README.md +++ b/README.md @@ -18,21 +18,15 @@ pip install -U subtitle_utils ## Usage ```python -import subtitle_utils - -method = subtitle_utils.SeeAvailableMethods() -print(method) - - -def get_convert(pre: str = "ass", aft: str = "srt", input_str: str = None) -> str: - _result_group = subtitle_utils.FormatConverter(pre=pre, aft=aft, strs=input_str) - _result_group: subtitle_utils.Returner - if not _result_group.status: - print(_result_group.dict()) - return "" - result: str - result = _result_group.data - print(f"{_result_group.pre}->{print(_result_group.aft)}") - print(_result_group.msg) - return result +from subtitle_utils import get_method, show_available, srt2bcc + +print("Available methods:") +print(show_available()) + +with open("test.srt", 'r') as file_io: + test_result = get_method(method="srt2bcc")(content=file_io) + print(test_result) + +_result = srt2bcc(content="1\n00:00:00,000 --> 00:00:01,000\nHello World") +print(_result) ``` diff --git a/feature_test/direct.py b/feature_test/direct.py new file mode 100644 index 0000000..869088a --- /dev/null +++ b/feature_test/direct.py @@ -0,0 +1,9 @@ +# -*- coding: utf-8 -*- +# @Time : 2024/1/19 上午12:01 +# @Author : sudoskys +# @File : direct.py +# @Software: PyCharm +from subtitle_utils import srt2bcc + +_result = srt2bcc(content="1\n00:00:00,000 --> 00:00:01,000\nHello World") +print(_result)