add Ox.formatSRT
This commit is contained in:
parent
13a339d924
commit
ceca50ae59
1 changed files with 15 additions and 0 deletions
|
@ -740,6 +740,21 @@ Ox.formatRoman = function(number) {
|
|||
return string;
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.formatSRT <f> Formats subtitles as SRT
|
||||
@*/
|
||||
Ox.formatSRT = function(subtitles) {
|
||||
return Ox.sortBy(subtitles, ['in', 'out']).map(function(subtitle, index) {
|
||||
return [
|
||||
index + 1,
|
||||
['in', 'out'].map(function(key) {
|
||||
return Ox.formatDuration(subtitle[key]).replace('.', ',');
|
||||
}).join(' --> '),
|
||||
subtitle['text']
|
||||
].join('\n')
|
||||
}).join('\n\n');
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.formatString <f> Basic string formatting
|
||||
> Ox.formatString('{0}{1}', ['foo', 'bar'])
|
||||
|
|
Loading…
Reference in a new issue