[php]//Copyright (C)2004 MeteorRain
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//使用方法:
//在$text = "下面一行,贴入小灰熊插件生成的代码(karaoke.add(……))格式,运行php程序即可。
//也可以制作一个提交页面,将$text = "……";整个删去,改成
//$text = $_POST['提交索引'];
//提交索引是textarea的name属性……
//1.0
//2004.7.28
header("Content-type: plain/text");
header("Content-Disposition: attachment; filename=1.ssa");
error_reporting(0);
$text = "
karaoke.add('00:33.227', '00:37.107', '[....]季節はずれの[beach ][side]', '1535,263,274,287,290,231,344,327,329');
karaoke.add('00:37.468', '00:40.604', '夜に隱れ[た...]', '264,246,234,410,1982');
karaoke.add('00:43.595', '00:46.076', '君の橫顏は', '336,463,697,632,353');
karaoke.add('00:46.539', '00:50.107', '何をみつめてるの?', '418,527,232,319,431,298,352,480,511');
karaoke.add('00:52.205', '00:54.836', '僕らは何一つ', '757,305,298,439,599,233');
karaoke.add('00:55.414', '00:57.077', '知るこ[との]ない', '231,250,272,281,333,296');
karaoke.add('00:57.077', '00:58.967', '未來の為に', '194,320,311,698,367');
karaoke.add('00:59.974', '01:01.475', '[手に][入れたり]', '727,774');
karaoke.add('01:01.533', '01:03.645', '[投げ出した][りして]', '1352,760');
karaoke.add('01:04.259', '01:08.475', '儚く誘う行方めざして', '719,375,538,335,418,591,303,328,238,371');
karaoke.add('01:08.733', '01:09.787', '[Flying ][Gone]', '463,591');
";
$sp1_text = explode("\n", $text);
for($i = 0; $i < count($sp1_text); $i++)
{
if($sp1_text[$i] == "") continue;
list($d1, $t1, $d2, $t2, $d3, $s, $d4, $tp, $d5) = explode("'", $sp1_text[$i]);
if(strpos($d1, ".add(") === false) continue;
$t1 = "0:" . substr($t1, 0, 8);
$t2 = "0:" . substr($t2, 0, 8);
$sp_t = explode(",", $tp);
$dest_t = "";
$ntime = 0; //1ms精确度的时间点
$dtime = 0; //10ms精确度的时间点
$wordpos = 0;
for($j = 0; $j < count($sp_t); $j++)
{
$word = substr($s, $wordpos, 1);
if($word == "")
break;
if($word == "[")
{
$word = "";
for(; substr($s, $wordpos + 1, 1) !== "]"; $word .= substr($s, ++$wordpos, 1));
$wordpos += 2;
}
elseif($word > "{")
{
$word = substr($s, $wordpos, 2);
$wordpos += 2;
}
else
$word = substr($s, $wordpos++, 1);
$ntime += $sp_t[$j];
$dest_t .= "{\\\\\K" . strval((int)($ntime / 10 - $dtime)) . "}" . $word;
$dtime += (int)($sp_t[$j] / 10);
}
printf("Dialogue: 0,%s,%s,Default,,0000,0000,0000,,%s\n", $t1, $t2, $dest_t);
}
?>[/php]