Name | pyass JSON |
Version |
0.1.2
JSON |
| download |
home_page | https://github.com/xIceArcher/pyass |
Summary | A library to read, manipulate, and write Advanced SubStation Alpha (.ass) files |
upload_time | 2023-06-28 05:53:37 |
maintainer | |
docs_url | None |
author | xIceArcher |
requires_python | >=3.10,<4.0 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# pyass
A library to read, manipulate, and write Advanced SubStation Alpha (.ass) files
## Installation
```bash
pip3 install pyass
```
## Quickstart
```python
import pyass
from datetime import timedelta
# subtitles.ass
'''
[Script Info]
; Script generated by Aegisub 3.2.2
; http://www.aegisub.org/
Title: New subtitles
ScriptType: v4.00+
WrapStyle: 0
PlayResX: 640
PlayResY: 480
ScaledBorderAndShadow: yes
[Aegisub Project Garbage]
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Arial,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,2,10,10,10,1
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,This is an event
'''
# Read an .ass file
# .ass files are typically encoded using "utf_8_sig"
with open("subtitles.ass", encoding="utf_8_sig") as f:
script = pyass.load(f)
# Read styles
for style in script.styles:
# Style name: Default, Font name: Arial, Font size: 20, Primary color: &H00FFFFFF
print(f'Style name: {style.name}, Font name: {style.fontName}, Font size: {style.fontSize}, Primary color: {style.primaryColor}')
# Modify styles
script.styles[0].fontName = "Times New Roman"
# Add styles
script.styles.append(pyass.Style(name="New Style", primaryColor=pyass.Color(r=0xFF)))
for style in script.styles:
# Style name: Default, Font name: Times New Roman, Font size: 20, Primary color: &H00FFFFFF
# Style name: New Style, Font name: Arial, Font size: 48, Primary color: &H000000FF
print(f'Style name: {style.name}, Font name: {style.fontName}, Font size: {style.fontSize}, Primary color: {style.primaryColor}')
# Read events
for event in script.events:
# Style: Default, Start: 0:00:00.00, End: 0:00:05.00, Text: This is an event
print(f'Style: {event.style}, Start: {event.start}, End: {event.end}, Text: {event.text}')
# Modify events
script.events[0].text = "Some new text"
# Add events
script.events.append(pyass.Event(format=pyass.EventFormat.COMMENT, start=timedelta(seconds=0), end=timedelta(seconds=10), text="This is a comment"))
for event in script.events:
# Style: Default, Start: 0:00:00.00, End: 0:00:05.00, Text: Some new text
# Style: Default, Start: 0:00:00, End: 0:00:10, Text: This is a comment
print(f'Style: {event.style}, Start: {event.start}, End: {event.end}, Text: {event.text}')
# Write an .ass file
# .ass files are typically encoded using "utf_8_sig"
with open("new_subtitles.ass", "w+", encoding="utf_8_sig") as f:
pyass.dump(script, f)
# new_subtitles.ass
'''
[Script Info]
; Script generated by Aegisub 3.2.2
; http://www.aegisub.org/
Title: New subtitles
ScriptType: v4.00+
WrapStyle: 0
PlayResX: 640
PlayResY: 480
ScaledBorderAndShadow: yes
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Times New Roman,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,2,10,10,10,1
Style: New Style,Arial,48,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,2,10,10,10,1
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,Some new text
Comment: 0,0:00:00.00,0:00:10.00,Default,,0,0,0,,This is a comment
'''
```
Raw data
{
"_id": null,
"home_page": "https://github.com/xIceArcher/pyass",
"name": "pyass",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "xIceArcher",
"author_email": "xicearcher@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/45/9a/37c1576192e984cfde0966a4d64e6809277c2ad677f3ef36628d12bf0975/pyass-0.1.2.tar.gz",
"platform": null,
"description": "# pyass\n\nA library to read, manipulate, and write Advanced SubStation Alpha (.ass) files\n\n## Installation\n```bash\npip3 install pyass\n```\n\n## Quickstart\n```python\nimport pyass\n\nfrom datetime import timedelta\n\n# subtitles.ass\n'''\n[Script Info]\n; Script generated by Aegisub 3.2.2\n; http://www.aegisub.org/\nTitle: New subtitles\nScriptType: v4.00+\nWrapStyle: 0\nPlayResX: 640\nPlayResY: 480\nScaledBorderAndShadow: yes\n\n[Aegisub Project Garbage]\n\n[V4+ Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding\nStyle: Default,Arial,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,2,10,10,10,1\n\n[Events]\nFormat: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\nDialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,This is an event\n'''\n\n# Read an .ass file\n# .ass files are typically encoded using \"utf_8_sig\"\nwith open(\"subtitles.ass\", encoding=\"utf_8_sig\") as f:\n script = pyass.load(f)\n\n# Read styles\nfor style in script.styles:\n # Style name: Default, Font name: Arial, Font size: 20, Primary color: &H00FFFFFF\n print(f'Style name: {style.name}, Font name: {style.fontName}, Font size: {style.fontSize}, Primary color: {style.primaryColor}')\n\n# Modify styles\nscript.styles[0].fontName = \"Times New Roman\"\n\n# Add styles\nscript.styles.append(pyass.Style(name=\"New Style\", primaryColor=pyass.Color(r=0xFF)))\n\nfor style in script.styles:\n # Style name: Default, Font name: Times New Roman, Font size: 20, Primary color: &H00FFFFFF\n # Style name: New Style, Font name: Arial, Font size: 48, Primary color: &H000000FF\n print(f'Style name: {style.name}, Font name: {style.fontName}, Font size: {style.fontSize}, Primary color: {style.primaryColor}')\n\n# Read events\nfor event in script.events:\n # Style: Default, Start: 0:00:00.00, End: 0:00:05.00, Text: This is an event\n print(f'Style: {event.style}, Start: {event.start}, End: {event.end}, Text: {event.text}')\n\n# Modify events\nscript.events[0].text = \"Some new text\"\n\n# Add events\nscript.events.append(pyass.Event(format=pyass.EventFormat.COMMENT, start=timedelta(seconds=0), end=timedelta(seconds=10), text=\"This is a comment\"))\n\nfor event in script.events:\n # Style: Default, Start: 0:00:00.00, End: 0:00:05.00, Text: Some new text\n # Style: Default, Start: 0:00:00, End: 0:00:10, Text: This is a comment\n print(f'Style: {event.style}, Start: {event.start}, End: {event.end}, Text: {event.text}')\n\n# Write an .ass file\n# .ass files are typically encoded using \"utf_8_sig\"\nwith open(\"new_subtitles.ass\", \"w+\", encoding=\"utf_8_sig\") as f:\n pyass.dump(script, f)\n\n# new_subtitles.ass\n'''\n[Script Info]\n; Script generated by Aegisub 3.2.2\n; http://www.aegisub.org/\nTitle: New subtitles\nScriptType: v4.00+\nWrapStyle: 0\nPlayResX: 640\nPlayResY: 480\nScaledBorderAndShadow: yes\n\n[V4+ Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding\nStyle: Default,Times New Roman,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,2,10,10,10,1\nStyle: New Style,Arial,48,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,2,10,10,10,1\n\n[Events]\nFormat: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\nDialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,Some new text\nComment: 0,0:00:00.00,0:00:10.00,Default,,0,0,0,,This is a comment\n'''\n```\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A library to read, manipulate, and write Advanced SubStation Alpha (.ass) files",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/xIceArcher/pyass",
"Repository": "https://github.com/xIceArcher/pyass"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2bb34454b2b46ca28ba74e3da2668a871b1cc3779213653e77b4be24ebea5550",
"md5": "1c7db44e4325540fe5823ab0d543f3d2",
"sha256": "778c9aaa6b895b9248936d4696254b29f3bbfacd5c371e02021a0f12b5ec6a7c"
},
"downloads": -1,
"filename": "pyass-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1c7db44e4325540fe5823ab0d543f3d2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10,<4.0",
"size": 16306,
"upload_time": "2023-06-28T05:53:36",
"upload_time_iso_8601": "2023-06-28T05:53:36.034063Z",
"url": "https://files.pythonhosted.org/packages/2b/b3/4454b2b46ca28ba74e3da2668a871b1cc3779213653e77b4be24ebea5550/pyass-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "459a37c1576192e984cfde0966a4d64e6809277c2ad677f3ef36628d12bf0975",
"md5": "ab3ab2d5be9340870b8c448ce6e94fcf",
"sha256": "226782d5885665bdbd33a4c0a7dcb4cc7455b594f58add57acf6f37311745280"
},
"downloads": -1,
"filename": "pyass-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "ab3ab2d5be9340870b8c448ce6e94fcf",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10,<4.0",
"size": 13454,
"upload_time": "2023-06-28T05:53:37",
"upload_time_iso_8601": "2023-06-28T05:53:37.561521Z",
"url": "https://files.pythonhosted.org/packages/45/9a/37c1576192e984cfde0966a4d64e6809277c2ad677f3ef36628d12bf0975/pyass-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-28 05:53:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "xIceArcher",
"github_project": "pyass",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pyass"
}