Skip to main content

Parse .ass tags.

Project description

AssTagAnalyzer

Tag analyzer for Advanced SubStation Alpha file. This tool allows to parse .ass tag and manipulate them.

Installation and Update

pip install ass-tag-analyzer

Example

from ass_tag_analyzer import parse_line, ass_item_to_text, Format, AssTagFontName, AssValidTagFontName, AssInvalidTagFontName

# Parse an .ass line
line = parse_line(r"{\an7\pos(158,501)\fnArial\bord0.155884}Example")
print(line)

# Convert line to text
print(ass_item_to_text(line))

# Change how to convert float to string
Format.format_float = lambda number: round(number)

# Reconvert line to text. See how the \bord result is different
print(ass_item_to_text(line))

# Search an tag
for ass_item in line:
    if isinstance(ass_item, AssTagFontName):
        if isinstance(ass_item, AssValidTagFontName):
            print(f'An \\fn tag has been found and the value is "{ass_item.name}"')

        elif isinstance(ass_item, AssInvalidTagFontName):
            # You need to get the style that is applied on the line.
            pass

Result

[
    AssTagListOpening(),
    AssValidTagAlignment(is_legacy_tag=False, _AssValidTagAlignment__alignment=<Alignment.TOP_LEFT: 7>),
    AssValidTagPosition(x=158.0, y=501.0),
    AssValidTagFontName(_AssValidTagFontName__name='Arial'),
    AssValidTagBorder(_AssValidTagBorder__size=0.155884),
    AssTagListEnding(),
    AssText(text='Example')
]
{\an7\pos(158,501)\fnArial\bord0.156}Example
{\an7\pos(158,501)\fnArial\bord0}Example
An \fn tag has been found and the value is "Arial"

Dependencies

Acknowledgments

  • ass_tag_parser I used his library to create mine. I got a lot of inspiration from his work.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ass_tag_analyzer-0.0.4.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

ass_tag_analyzer-0.0.4-py3-none-any.whl (30.3 kB view details)

Uploaded Python 3

File details

Details for the file ass_tag_analyzer-0.0.4.tar.gz.

File metadata

  • Download URL: ass_tag_analyzer-0.0.4.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for ass_tag_analyzer-0.0.4.tar.gz
Algorithm Hash digest
SHA256 3570c1c60a365234b21ce4fdf032c102f88b1c8a5ff920e41eb81360b601b1ce
MD5 4d5b7e7eb6c8c9b9c1e5a7d3ef529d45
BLAKE2b-256 b056768191383c761a5e5d56a1af4935164987c21fd9530090fd977577bf1376

See more details on using hashes here.

File details

Details for the file ass_tag_analyzer-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for ass_tag_analyzer-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e319feb6ee208e9e59fff450643ecb3bc4775342b122301f4692a97f141d1067
MD5 e35a7cbd3bfdbdf1d670da1ca12d6806
BLAKE2b-256 7e78d3b16cb38dccab675cc3c49278cf5995e75d0eddfdd9243d864d537721e3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page