-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from sudoskys/dev
feat(update 1.0.0): refactor | Break Change
- Loading branch information
Showing
31 changed files
with
857 additions
and
700 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: publish | ||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- pypi* | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
pypi-publish: | ||
name: upload release to PyPI | ||
runs-on: ubuntu-latest | ||
permissions: | ||
# IMPORTANT: this permission is mandatory for trusted publishing | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: pdm-project/setup-pdm@v3 | ||
|
||
- name: Publish package distributions to PyPI | ||
run: pdm publish |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Run tests | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
- develop | ||
- '**-develop' | ||
|
||
jobs: | ||
Testing: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
python-version: [ '3.8', '3.9', '3.10', '3.11' ] | ||
os: [ ubuntu-latest ] # , windows-latest, macos-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up PDM | ||
uses: pdm-project/setup-pdm@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
pdm install --no-lock -G testing | ||
- name: Run Tests | ||
run: | | ||
pdm run -v pytest tests |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,4 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
/.pdm-python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: check-added-large-files | ||
|
||
# check python requirements | ||
- repo: https://github.com/pdm-project/pdm | ||
rev: 2.11.2 # a PDM release exposing the hook | ||
hooks: | ||
- id: pdm-lock-check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,32 @@ | ||
# subtitle_utils | ||
|
||
 | ||
 | ||
|
||
<p align="center"> | ||
<img src="https://img.shields.io/badge/Python-3.7|8|9|10-green" alt="Python" > | ||
<img src="https://img.shields.io/badge/Python-3.8|9|10|11-green" alt="Python" > | ||
<img src="https://img.shields.io/pypi/dm/subtitle_utils.svg" alt="Download"> | ||
</p> | ||
|
||
Subtilte Conversion utils - ass2srt vtt2bcc srt2bcc ass2bcc and more | ||
|
||
`pip install -U subtitle_utils` | ||
## Install | ||
|
||
## 使用 | ||
``` | ||
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) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# -*- coding: utf-8 -*- | ||
# @Time : 2024/1/18 下午11:09 | ||
# @Author : sudoskys | ||
# @File : split_exp.py | ||
|
||
method = "ass2srt" | ||
sub_key, key = method.split("2", maxsplit=1) | ||
|
||
print(sub_key, key) |
Oops, something went wrong.