-
Notifications
You must be signed in to change notification settings - Fork 1
/
subtitle.tmp.class.php
50 lines (45 loc) · 1.3 KB
/
subtitle.tmp.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* Parsing TMPlayer format.
*/
///http://www.gtw.avx.pl/modules.php?name=Content2&pa=showpage&pid=39
class TmpSubtitle extends Subtitle{
// private $events;
// protected final function _addLine($l)
protected function _parse(&$f){
//$a = explode("\n",$f);
preg_match_all("/(\d+:\d+:\d+)[: =](.+)/",$f,$a,PREG_SET_ORDER);
$ll = '';
foreach($a AS $l){
if($ll != $l[2]){
$ll = $l[2];
$this->_addLine(Array(
//'_org' => $l[0],
'start' => MTime::fromTmp($l[1]),
'text' => MText::fromTmp(trim($l[2]))
));
}
}
return true;
}
public function get(){
ksort($this->events);
$out = Array();
foreach($this->events AS $l){
$out[] = MTime::toTmp($l['start']).':'.MText::toTmp($l['text']);
if(!empty($l['end']) && ($l['start']+4) < $l['end'])
$out[] = MTime::toTmp($l['start']+4).':'.MText::toTmp($l['text']);
}
return join("\n", $out);
}
public function decodeTime($v){
return MTime::fromTmp($v);
}
public function encodeTime($t){
return MTime::toTmp($t);
}
public static function getVersion(){
return '$Id: subtitle.tmp.class.php,v 1.2 2009/08/29 22:47:50 wojtekb Exp $';
}
}
?>