Konvertiranje srt titlova u XML ? - Reseno
Moderator: cicans
- triva911
- Joomla! Apprentice
- Posts: 42
- Joined: Sun Apr 04, 2010 5:59 pm
Konvertiranje srt titlova u XML ? - Reseno
Na netu sam pronasao razne javascripte za konvertovanje , ali neznam kako se to koristi , dali mi neko moze objasniti sve u vezi konvertovanja SRT u XML , unapred hvala.
Last edited by triva911 on Sat Apr 17, 2010 2:13 pm, edited 1 time in total.
- TheHacker
- Joomla! Ace
- Posts: 1316
- Joined: Sat Oct 13, 2007 1:12 pm
- Location: Beograd
- Contact:
Re: Konvertiranje srt titlova u XML ?
kakve ovo ima veze sa joomla cms.om?
Web Arena - Tutorijali - Photoshop, Joomla, JavaScript... zanimljivosti, inspiracija... http://webarena.rs
- triva911
- Joomla! Apprentice
- Posts: 42
- Joined: Sun Apr 04, 2010 5:59 pm
Re: Konvertiranje srt titlova u XML ?
Izvini , mozda nije pravo mesto za ovakvo pitanje , a da li ti znas kako da to odradim ?
- Leftfield
- Joomla! Virtuoso
- Posts: 4441
- Joined: Fri Dec 08, 2006 3:33 am
- Contact:
Re: Konvertiranje srt titlova u XML ?
Ajde triva911 stvarno neznaš kako se to konertuje?
SEO & SEM Manager https://vujosevic.com/
- triva911
- Joomla! Apprentice
- Posts: 42
- Joined: Sun Apr 04, 2010 5:59 pm
Re: Konvertiranje srt titlova u XML ?
Neznam Leftfield , da znam nebih pitaoLeftfield wrote:Ajde triva911 stvarno neznaš kako se to konertuje?
- Leftfield
- Joomla! Virtuoso
- Posts: 4441
- Joined: Fri Dec 08, 2006 3:33 am
- Contact:
Re: Konvertiranje srt titlova u XML ?
Neznam ni ja . (šala, šala, nisam mogao da izdržim)
SEO & SEM Manager https://vujosevic.com/
- cicans
- Joomla! Hero
- Posts: 2274
- Joined: Fri Oct 12, 2007 10:31 am
- Location: Novi Sad, Serbia
- Contact:
Re: Konvertiranje srt titlova u XML ?
"Drevna mudrost": Nije vazno ako nesto ne znam, bitno je da znam nekog ko to zna, a ono sto Google ne moze da pronadje to onda verovatno i ne postoji
http://www.codemiles.com/php/php-srt-to ... t1347.html
Jeste da ovo nema veze sa Joomlom, ali mozda moze da posluzi za neki flash, probaj, pa ako uspes napisi sta si uradio.
http://www.codemiles.com/php/php-srt-to ... t1347.html
Jeste da ovo nema veze sa Joomlom, ali mozda moze da posluzi za neki flash, probaj, pa ako uspes napisi sta si uradio.
Blog: http://www.kuvarancije.com/
Serbian Joomla!® Translation Team Coordinator http://www.joomla-serbia.com/
Follow me on Twitter @cicans - Svetlana Zec
Serbian Joomla!® Translation Team Coordinator http://www.joomla-serbia.com/
Follow me on Twitter @cicans - Svetlana Zec
- triva911
- Joomla! Apprentice
- Posts: 42
- Joined: Sun Apr 04, 2010 5:59 pm
Re: Konvertiranje srt titlova u XML ?
Hvala reseno , znaci ovako to radi ,
Prvo treba napraviti sledece foldere na serveru
\---media
|
+---temp
| captions-1.xml (converted file)
| captions-2.xml (converted file)
| captions-3.xml (converted file)
|
+---captions
| captions-1.srt
| captions-2.srt
| captions-3.srt
| srt-xml.php (the conversion script)
- ili ako nece da radi skripta premjestiti sve u temp folder i iz temp foldera pokrenuti srt-xml.php i onda ce konvertovati srt u xml ,
Ovako treba da izgleda srt-xml.php
Posle samo treba pokrenuti skritpu u browseru http://my.domain.com/path/media/captions/srt-xml.php
Prvo treba napraviti sledece foldere na serveru
\---media
|
+---temp
| captions-1.xml (converted file)
| captions-2.xml (converted file)
| captions-3.xml (converted file)
|
+---captions
| captions-1.srt
| captions-2.srt
| captions-3.srt
| srt-xml.php (the conversion script)
- ili ako nece da radi skripta premjestiti sve u temp folder i iz temp foldera pokrenuti srt-xml.php i onda ce konvertovati srt u xml ,
Ovako treba da izgleda srt-xml.php
Code: Select all
<?php
// script to convert multi-line srt caption files to new-format (02-05-08) tt XML caption files
$use_cdata_tags = true;
$debug_output = true;
// the directory to write the new files in
// it must exist, be writeable, and be outside of the directory that is being scanned
$new_directory = '../temp/';
/////////////////////////////////// no user configuration below this \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// get filename or scan directory if it's a directory
$filename = (isset($_GET["filename"])) ? strval($_GET["filename"]) : "./";
// read each file into an array
$it = new RecursiveDirectoryIterator("$filename");
foreach(new RecursiveIteratorIterator($it) as $file)
{
// debug('Filename', $file); exit;
// debug('Ext', substr(strtolower($file), (strlen($file) - 4), 4));// exit;
// debug - only use test file
// if($file == '.\multi-line_test_file.srt')
// check for .srt extension
if(substr(strtolower($file), (strlen($file) - 4), 4) == '.srt')
{
$ttxml = '';
$full_line = '';
if($file_array = file($file))
{
// write tt , head, and div elements for the new file
$ttxml .= "<tt xml:lang='en' xmlns='http://www.w3.org/2006/10/ttaf1' xmlns:tts='http://www.w3.org/2006/10/ttaf1#style'>\n";
$ttxml .= " <head>\n";
$ttxml .= " </head>\n";
$ttxml .= " <body>\n";
$ttxml .= " <div xml:id=\"captions\">\n";
foreach($file_array as $line)
{
$line = rtrim($line);
// debug('Line', $line);
// get begin and end
// 00 : 00 : 32 , 000 --> 00 : 00 : 37 , 000
if(preg_match('/(\d\d):(\d\d):(\d\d),(\d\d\d) --> (\d\d):(\d\d):(\d\d),(\d\d\d)/', $line, $match))
{
$begin = $match[1] . ":" . $match[2] . ":" . $match[3] . "." . $match[4];
$end = $match[5] . ":" . $match[6] . ":" . $match[7] . "." . $match[8];
$full_line = '';
}
// if the next line is not blank, get the text
elseif($line != '')
{
if($full_line != '')
{
$full_line .= '<br />' . $line;
}
else
{
$full_line .= $line;
}
}
// if the next line is blank, write the paragraph
if($line == '')
{
// write new paragraph
// <p begin="00:08:01.50" end="00:08:07.50">Nothing is going on.</p>
if($use_cdata_tags)
{
$ttxml .= " <p begin=\"" . $begin . "\" end=\"" . $end . "\"><![CDATA[" . $full_line . "]]></p>\n";
}
else
{
$ttxml .= " <p begin=\"" . $begin . "\" end=\"" . $end . "\">" . $full_line . "</p>\n";
}
// debug('Text', $line);
// debug('ttxml', $ttxml); exit;
$full_line = '';
}
}
// write ending tags
$ttxml .= " </div>\n";
$ttxml .= " </body\n"; $ttxml .= "</tt>\n";
// write new file
$new_file = $new_directory . substr($file, 0, (strlen($file) - 4)) . '.xml';
$fh = fopen($new_file, 'w') or die('Can\'t open: ' . $new_file);
fwrite($fh, $ttxml) or die('Can\'t write to: ' . $new_file);
fclose($fh);
}
}
}
function debug($title, $value)
{
global $debug_output;
if ($debug_output)
{
print "<pre>";
if (is_array($value))
{
print $title . ":\n";
print_r($value);
}
else
{
print $title . ": " . $value;
}
print "</pre>\n";
}
}
?>