Skip to content

Classes to work with ASS (Advanced Substation Alpha) subtitles in PHP

Notifications You must be signed in to change notification settings

jokerrider007/php-ass

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-ass

A set of classes for reading information from .ass (ASS, Advanced Substation Alpha) subtitle files.

Concept

For further details of the file format, see the ASS file specs.

ASS files are split into several blocks or sections in an INI style format. Within each block is a series of unsorted entries.

The classes here allow you to read a valid Sub Station Alpha v4.00+ file and search and retrieve the data within it.

Usage

Use your autoloader for the files or require them as needed.

Call one of the static methods to read from a file:

$assFile = chaostangent\Ass\Ass::fromFile($filename);

Or from a string:

$assFile = chaostangent\Ass\Ass::fromString($data);

Once you've read in the file, you can get all of the read blocks by calling $ass->getBlocks(); or if you want to try and find a specific block by name $ass->findBlocks('string');. Block names are string matched, case sensitive.

For each block you can get the list of entries by doing $block->getEntries();.

Once you have a block you can do one of three things: extract, pluck or search.

Extract

Extract gets you all of one type of data from an ASS file, the currently supported types are dialoge, styles, comments, and misc (everything else).

$styleEntries = $block->getEntries()->extract(chaostangent\Ass\Entries::ENTRY_STYLE);

Pluck

Plucking doesn't return an array of entry objects but an array of strings for a specified type. For instance, if you wanted to gather all of the 'Fontname' values from style entries:

$fontNames = $block->getEntries()->pluck(chaostangent\Ass\Entries::ENTRY_STYLE, 'Fontname');

Search

Does exactly what you expect, do a search for all entries with a specific type, key name and value:

$things = $block->getEntries()->search(chaostangent\Ass\Entries::ENTRY_STYLE, 'Fontname', 'Arial');

TODO

  • Allow reading of embedded information (images, fonts etc.)
  • More consistent interface

Goals

  • Allow reading of dialogue data (and only dialogue data) from ASS files

About

Classes to work with ASS (Advanced Substation Alpha) subtitles in PHP

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%