bazh / subtitles-parser Goto Github PK
View Code? Open in Web Editor NEWsubrip .srt parser
License: MIT License
subrip .srt parser
License: MIT License
This page incorrectly shows the install command as npm install subtitle-parser
whereas the README in Github repo is correct.
Looks like this wasn't npm published after recent changes?
Hi, would you consider approaching this in an async way? Where instead of
var data = parser.fromSrt(srt);
You would do
parser.fromSrt(srt, function(data){
// some code
});
or (with q)
parser.fromSrt(srt).then(function(data){
// some code
});
Theoretically, this would allow for faster parsing of multiple subtitle files (i think).
if smi file dosen't have any comment, parser spout error.
subtitle-convert/lib/parser/smiparser.js 's 71 line.
parser.end();
var regex = new RegExp('<!--[\\s\\S]*?(?:-->)?' + '<!---+>?' + '|<!(?![dD][oO][cC][tT][yY][pP][eE]|\\[CDATA\\[)[^>]*>?' + '|<[?][^>]*>?', 'g');
encoded.match(regex).forEach(function (el) {
commentList.push(el.replace(/(\r\n){2}|(<!--)|(-->)|/g, '').replace(/^(\r\n)/g, ''));
});
return {
styleList: styleList,
cueList: cueList,
commentList: commentList
};
to
parser.end();
try {
var regex = new RegExp('<!--[\\s\\S]*?(?:-->)?' + '<!---+>?' + '|<!(?![dD][oO][cC][tT][yY][pP][eE]|\\[CDATA\\[)[^>]*>?' + '|<[?][^>]*>?', 'g');
encoded.match(regex).forEach(function (el) {
commentList.push(el.replace(/(\r\n){2}|(<!--)|(-->)|/g, '').replace(/^(\r\n)/g, ''));
});
} catch{
}
return {
styleList: styleList,
cueList: cueList,
commentList: commentList
};
00:00:03.14,00:00:05.37
All right, they got water,[br]orange juice. . .
00:00:05.74,00:00:08.01
. . .and what looks like cider.
and
{488}{511}Hey, Ben.
{517}{593}"Just do it"!
{609}{638}Oh, my God!
The fromSrt()
function does not work when dots are used as decimal separator (instead commas).
For example:
1
00:00:04.240 --> 00:00:09.570
way.
2
00:00:09.570 --> 00:00:10.860
Love about Eurovision.
3
00:00:11.080 --> 00:00:16.050
The whole world's participating on to make sure the world remains a great place that
4
00:00:16.050 --> 00:00:16.450
it is.
5
00:00:16.640 --> 00:00:19.850
We're hosting this song contest as a green events,
Apparently it works well with both commas and dots when changing the regex at line 21:
var regex = /(\d+)\n(\d{2}:\d{2}:\d{2},\d{3}) --> (\d{2}:\d{2}:\d{2},\d{3})/g;
to:
var regex = /(\d+)\n(\d{2}:\d{2}:\d{2}.\d{3}) --> (\d{2}:\d{2}:\d{2}.\d{3})/g;
Happy 2017!
The fromSrt()
function does not work when dots are used as decimal separator (instead commas).
For example:
1
00:00:04.240 --> 00:00:09.570
way.
2
00:00:09.570 --> 00:00:10.860
Love about Eurovision.
3
00:00:11.080 --> 00:00:16.050
The whole world's participating on to make sure the world remains a great place that
4
00:00:16.050 --> 00:00:16.450
it is.
5
00:00:16.640 --> 00:00:19.850
We're hosting this song contest as a green events,
Apparently it works well with both commas and dots when changing the regex at line 21:
var regex = /(\d+)\n(\d{2}:\d{2}:\d{2},\d{3}) --> (\d{2}:\d{2}:\d{2},\d{3})/g;
to:
var regex = /(\d+)\n(\d{2}:\d{2}:\d{2}.\d{3}) --> (\d{2}:\d{2}:\d{2}.\d{3})/g;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.