PHP Класс SrtParser\srtFile

Показать файл Открыть проект

Открытые методы

Метод Описание
__construct ( $_filename, $_encoding = '' ) srtFile constructor
build ( boolean $stripTags = false, $stripBasic = false, array $replacements = [] ) Builds file content (file_content[_notag])
buildPart ( integer $from, integer $to, boolean $stripTags = false, $stripBasic = false, array $replacements = [] ) Builds file content (file_content[_notag]) from entry $from to entry $to
calcStats ( ) Computes statistics regarding reading speed
changeFPS ( float $old_fps, float $new_fps ) Converts timecodes based on the specified FPS ratio
cp1252_to_utf8 ( string $text ) Converts Windows-1252 (CP-1252) to UTF-8
deleteSub ( integer $_index ) Deletes a cue
detect_utf_encoding ( string $text ) Detects UTF encoding
getEncoding ( )
getFileContent ( ) Getters
getFilename ( )
getSub ( $idx )
getSubCount ( )
getSubs ( )
isValid ( string $_filename ) : boolean Checks if the file is a valid SubRip file
isWebVTT ( )
mergeSrtFile ( srtFile $_srtFile ) Imports subtitles from another srtFile object
save ( string $filename = null, boolean $stripTags = false ) Saves the file
saveStats ( string $filename, $output = 'html' ) Saves statistics as XML file
searchCueFromTimecode ( $_start )
searchWord ( string $word, boolean $case_sensitive = false, boolean $strict = false ) : array Searchs a word/expression and returns ids of the matched entries
setWebVTT ( $_is_WebVTT = true )
shift ( $time, integer $startIndex = false, integer $endIndex = false ) Shifts a range of subtitles a specified amount of time.
sortSubs ( ) Sorts srtFile entries
sync ( integer $startIndex, integer $startTime, integer $endIndex, integer $endTime, boolean $syncLast = true ) : boolean Auto syncs a range of subtitles given their first and last correct times.

Приватные методы

Метод Описание
convertEncoding ( ) Converts file content to UTF-8
getPercent ( $nb ) : integer
loadContent ( ) Loads file content and detect file encoding if undefined
parseSubtitles ( ) Parses file content into srtFileEntry objects

Описание методов

__construct() публичный Метод

srtFile constructor
public __construct ( $_filename, $_encoding = '' )

build() публичный Метод

Builds file content (file_content[_notag])
public build ( boolean $stripTags = false, $stripBasic = false, array $replacements = [] )
$stripTags boolean If true, {\...} tags will be stripped
$replacements array

buildPart() публичный Метод

Builds file content (file_content[_notag]) from entry $from to entry $to
public buildPart ( integer $from, integer $to, boolean $stripTags = false, $stripBasic = false, array $replacements = [] )
$from integer Id of the first entry
$to integer Id of the last entry
$stripTags boolean If true, {\...} tags will be stripped
$replacements array

calcStats() публичный Метод

Computes statistics regarding reading speed
public calcStats ( )

changeFPS() публичный Метод

Converts timecodes based on the specified FPS ratio
public changeFPS ( float $old_fps, float $new_fps )
$old_fps float
$new_fps float

cp1252_to_utf8() публичный статический Метод

Converts Windows-1252 (CP-1252) to UTF-8
public static cp1252_to_utf8 ( string $text )
$text string The string to be converted

deleteSub() публичный Метод

Deletes a cue
public deleteSub ( integer $_index )
$_index integer

detect_utf_encoding() публичный статический Метод

Detects UTF encoding
public static detect_utf_encoding ( string $text )
$text string

getEncoding() публичный Метод

public getEncoding ( )

getFileContent() публичный Метод

Getters
public getFileContent ( )

getFilename() публичный Метод

public getFilename ( )

getSub() публичный Метод

public getSub ( $idx )

getSubCount() публичный Метод

public getSubCount ( )

getSubs() публичный Метод

public getSubs ( )

isValid() публичный статический Метод

Checks if the file is a valid SubRip file
public static isValid ( string $_filename ) : boolean
$_filename string The path to the file
Результат boolean

isWebVTT() публичный Метод

public isWebVTT ( )

mergeSrtFile() публичный Метод

Imports subtitles from another srtFile object
public mergeSrtFile ( srtFile $_srtFile )
$_srtFile srtFile another srtFile object

save() публичный Метод

Saves the file
public save ( string $filename = null, boolean $stripTags = false )
$filename string
$stripTags boolean If true, use file_content_notag instead of file_content

saveStats() публичный Метод

Saves statistics as XML file
public saveStats ( string $filename, $output = 'html' )
$filename string

searchCueFromTimecode() публичный Метод

public searchCueFromTimecode ( $_start )

searchWord() публичный Метод

Searchs a word/expression and returns ids of the matched entries
public searchWord ( string $word, boolean $case_sensitive = false, boolean $strict = false ) : array
$word string
$case_sensitive boolean
$strict boolean
Результат array containing ids of entries

setWebVTT() публичный Метод

public setWebVTT ( $_is_WebVTT = true )

shift() публичный Метод

Shifts a range of subtitles a specified amount of time.
public shift ( $time, integer $startIndex = false, integer $endIndex = false )
$time The time to use (ms), which can be positive or negative.
$startIndex integer The subtitle index the range begins with.
$endIndex integer The subtitle index the range ends with.

sortSubs() публичный Метод

Sorts srtFile entries
public sortSubs ( )

sync() публичный Метод

The subtitles are first shifted to the first subtitle's correct time, and then proportionally adjusted using the last subtitle's correct time. Based on gnome-subtitles (https://git.gnome.org/browse/gnome-subtitles/)
public sync ( integer $startIndex, integer $startTime, integer $endIndex, integer $endTime, boolean $syncLast = true ) : boolean
$startIndex integer The subtitle index to start the adjustment with.
$startTime integer The correct start time for the first subtitle.
$endIndex integer The subtitle index to end the adjustment with.
$endTime integer The correct start time for the last subtitle.
$syncLast boolean Whether to sync the last subtitle.
Результат boolean Whether the subtitles could be adjusted