Skip to content

Commit

Permalink
Merge pull request #6 from sudoskys/dev
Browse files Browse the repository at this point in the history
feat(update 1.0.0): refactor | Break Change
  • Loading branch information
sudoskys committed Jan 18, 2024
2 parents fc0fc86 + 095b972 commit 14026f9
Show file tree
Hide file tree
Showing 31 changed files with 857 additions and 700 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/publish.yml
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
39 changes: 0 additions & 39 deletions .github/workflows/python-publish.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/python_test.yml
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
38 changes: 0 additions & 38 deletions .github/workflows/test.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,4 @@ dmypy.json

# Pyre type checker
.pyre/
/.pdm-python
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
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
43 changes: 21 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
# subtitle_utils

![cover](https://raw.githubusercontent.com/sudoskys/subtitle_utils/main/cover.jpg)
![cover](https://raw.githubusercontent.com/sudoskys/subtitle_utils/main/src/cover.jpg)

<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)
```
9 changes: 9 additions & 0 deletions feature_test/direct.py
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)
9 changes: 9 additions & 0 deletions feature_test/split_exp.py
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)
Loading

0 comments on commit 14026f9

Please sign in to comment.