# Installation from pip3
```shell
pip3 install --verbose subtitlecore
python -m spacy download en_core_web_trf
python -m spacy download es_dep_news_trf
```
# Usage
Please refer to [api docs](https://qishe-nlp.github.io/subtitlecore/).
### Excutable usage
* Get subtitle content
```shell
subtitlecore_content --srtfile test.srt --lang en
```
* Parse srtfile into sentences with timestamp
```shell
subtitlecore_parse2sens --srtfile test.srt --lang en
```
* Parse srtfile into plain text
```shell
subtitlecore_parse2text --srtfile test.srt --lang en
```
### Package usage
```
from subtitlecore import Subtitle
def get_subtitle_content(srtfile, lang):
st = Subtitle(srtfile, lang)
for line_info in st.content:
print(line_info)
def parse2sens(srtfile, lang):
st = Subtitle(srtfile, lang)
content_sens = st.sentenize()
for e in content_sens:
print(e)
def parse2text(srtfile, lang):
st = Subtitle(srtfile, lang)
text = st.plaintext()
print(text)
```
# Development
### Clone project
```
git clone https://github.com/qishe-nlp/subtitlecore.git
```
### Install [poetry](https://python-poetry.org/docs/)
### Install dependencies
```
poetry update
```
### Test
```
poetry run pytest -rP
```
which run tests under `tests/*`
### Execute
```
poetry run subtitlecore_content --help
poetry run subtitlecore_parse2sens --help
poetry run subtitlecore_parse2text --help
```
### Create sphinx docs
```
poetry shell
cd apidocs
sphinx-apidoc -f -o source ../subtitlecore
make html
python -m http.server -d build/html
```
### Host docs on github pages
```
cp -rf apidocs/build/html/* docs/
```
### Build
* Change `version` in `pyproject.toml` and `subtitlecore/__init__.py`
* Build python package by `poetry build`
### Git commit and push
### Publish from local dev env
* Set pypi test environment variables in poetry, refer to [poetry doc](https://python-poetry.org/docs/repositories/)
* Publish to pypi test by `poetry publish -r test`
### Publish through CI
* Github action build and publish package to [test pypi repo](https://test.pypi.org/)
```
git tag [x.x.x]
git push origin master
```
* Manually publish to [pypi repo](https://pypi.org/) through [github action](https://github.com/qishe-nlp/subtitlecore/actions/workflows/pypi.yml)
Raw data
{
"_id": null,
"home_page": "https://github.com/qishe-nlp/subtitlecore",
"name": "subtitlecore",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.12",
"maintainer_email": null,
"keywords": "subtitle, parse, srt",
"author": "Phoenix.Grey",
"author_email": "phoenix.grey0108@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/01/65/62a63bdc15494c8f757ddbcf83dd022fcbc92814520d97a42d892a89298c/subtitlecore-0.1.16.tar.gz",
"platform": null,
"description": "# Installation from pip3\n\n```shell\npip3 install --verbose subtitlecore\npython -m spacy download en_core_web_trf\npython -m spacy download es_dep_news_trf\n```\n\n# Usage\n\nPlease refer to [api docs](https://qishe-nlp.github.io/subtitlecore/).\n\n### Excutable usage\n\n* Get subtitle content\n\n```shell\nsubtitlecore_content --srtfile test.srt --lang en\n``` \n\n* Parse srtfile into sentences with timestamp\n\n```shell\nsubtitlecore_parse2sens --srtfile test.srt --lang en\n```\n\n* Parse srtfile into plain text\n```shell\nsubtitlecore_parse2text --srtfile test.srt --lang en\n```\n\n### Package usage\n```\nfrom subtitlecore import Subtitle\n\ndef get_subtitle_content(srtfile, lang):\n st = Subtitle(srtfile, lang)\n for line_info in st.content:\n print(line_info)\n\ndef parse2sens(srtfile, lang):\n st = Subtitle(srtfile, lang)\n content_sens = st.sentenize()\n for e in content_sens:\n print(e)\n\ndef parse2text(srtfile, lang):\n st = Subtitle(srtfile, lang)\n text = st.plaintext()\n print(text)\n```\n\n# Development\n\n### Clone project\n```\ngit clone https://github.com/qishe-nlp/subtitlecore.git\n```\n\n### Install [poetry](https://python-poetry.org/docs/)\n\n### Install dependencies\n```\npoetry update\n```\n\n### Test\n```\npoetry run pytest -rP\n```\nwhich run tests under `tests/*`\n\n### Execute\n```\npoetry run subtitlecore_content --help\npoetry run subtitlecore_parse2sens --help\npoetry run subtitlecore_parse2text --help\n```\n\n### Create sphinx docs\n```\npoetry shell\ncd apidocs\nsphinx-apidoc -f -o source ../subtitlecore\nmake html\npython -m http.server -d build/html\n```\n\n### Host docs on github pages\n```\ncp -rf apidocs/build/html/* docs/\n```\n\n### Build\n* Change `version` in `pyproject.toml` and `subtitlecore/__init__.py`\n* Build python package by `poetry build`\n\n### Git commit and push\n\n### Publish from local dev env\n* Set pypi test environment variables in poetry, refer to [poetry doc](https://python-poetry.org/docs/repositories/)\n* Publish to pypi test by `poetry publish -r test`\n\n### Publish through CI \n\n* Github action build and publish package to [test pypi repo](https://test.pypi.org/)\n\n```\ngit tag [x.x.x]\ngit push origin master\n```\n\n* Manually publish to [pypi repo](https://pypi.org/) through [github action](https://github.com/qishe-nlp/subtitlecore/actions/workflows/pypi.yml)\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Parse srt file content into well-formed structures",
"version": "0.1.16",
"project_urls": {
"Documentation": "https://qishe-nlp.github.io/subtitlecore/",
"Homepage": "https://github.com/qishe-nlp/subtitlecore",
"Repository": "https://github.com/qishe-nlp/subtitlecore"
},
"split_keywords": [
"subtitle",
" parse",
" srt"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6c0caa2207530f6d6b32262baf118295f4d1a1e4ac8cc2c6d7313498bd3da6e2",
"md5": "d8896530916f0e4150cab392eba738df",
"sha256": "291b6b939ae938f85f6ba0e3bcf75cd3b5184d0ab29ae08cef4a3e7b103b8f30"
},
"downloads": -1,
"filename": "subtitlecore-0.1.16-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d8896530916f0e4150cab392eba738df",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.12",
"size": 5184,
"upload_time": "2024-12-25T11:25:27",
"upload_time_iso_8601": "2024-12-25T11:25:27.066677Z",
"url": "https://files.pythonhosted.org/packages/6c/0c/aa2207530f6d6b32262baf118295f4d1a1e4ac8cc2c6d7313498bd3da6e2/subtitlecore-0.1.16-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "016562a63bdc15494c8f757ddbcf83dd022fcbc92814520d97a42d892a89298c",
"md5": "bdc851f43ad0da81d96fe765d6e97fb9",
"sha256": "665f1b122ee3fc36b9fd1dedbe76b5ae32c7527ee2402ef120c77457d2e53591"
},
"downloads": -1,
"filename": "subtitlecore-0.1.16.tar.gz",
"has_sig": false,
"md5_digest": "bdc851f43ad0da81d96fe765d6e97fb9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.12",
"size": 3520,
"upload_time": "2024-12-25T11:25:29",
"upload_time_iso_8601": "2024-12-25T11:25:29.132578Z",
"url": "https://files.pythonhosted.org/packages/01/65/62a63bdc15494c8f757ddbcf83dd022fcbc92814520d97a42d892a89298c/subtitlecore-0.1.16.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-25 11:25:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "qishe-nlp",
"github_project": "subtitlecore",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "subtitlecore"
}