From 49cdabdab40b708192d685260d2707f813e2de68 Mon Sep 17 00:00:00 2001 From: Masoud Date: Wed, 21 Apr 2021 14:15:37 +0430 Subject: [PATCH 1/3] Update SubPlayerJS.js Better Handling of line split. supports CR+LF. "line" var will always have 1 line(child). --- SubPlayerJS.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SubPlayerJS.js b/SubPlayerJS.js index b44c166..cda25eb 100644 --- a/SubPlayerJS.js +++ b/SubPlayerJS.js @@ -511,10 +511,10 @@ class SubPlayerJS { } static parseSubRip(srt, videoid){ - var lines = srt.split(/[\r\n]+[\r\n]+/); + var lines = srt.split(/[\r\n]+/g); // CR+LF $.each(lines, function(key, line) { if (line.indexOf("-->") > -1) { - var parts = line.split(/[\r\n]+/)[1].split(/[\r\n]+/)[0].split('-->'); + var parts = line.split(/[\r\n]+/)[0].split('-->'); parts[0] = SubPlayerJS.timeStampToSeconds(parts[0], "srt"); parts[1] = SubPlayerJS.timeStampToSeconds(parts[1], "srt"); From 6f7208e6998ec9ed3916743c7a20a8f6fe22dd5a Mon Sep 17 00:00:00 2001 From: Masoud Date: Wed, 21 Apr 2021 14:51:41 +0430 Subject: [PATCH 2/3] Update demo.html rawgit will close down! --- demo.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demo.html b/demo.html index 4d51d06..491e3e5 100644 --- a/demo.html +++ b/demo.html @@ -1,7 +1,7 @@ Demo Player - + @@ -44,4 +44,4 @@

Inferno Trailer - SubRip - .srt

- \ No newline at end of file + From f246f270bc48b851f7c1b5fed06f723ef597638a Mon Sep 17 00:00:00 2001 From: Masoud Date: Wed, 21 Apr 2021 15:50:11 +0430 Subject: [PATCH 3/3] Update SubPlayerJS.js If each line in subrip file is ended with CR+LF, split doesn't work properly, therefore we need to remove all "CR". --- SubPlayerJS.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SubPlayerJS.js b/SubPlayerJS.js index cda25eb..ed2c416 100644 --- a/SubPlayerJS.js +++ b/SubPlayerJS.js @@ -511,10 +511,12 @@ class SubPlayerJS { } static parseSubRip(srt, videoid){ - var lines = srt.split(/[\r\n]+/g); // CR+LF + var lines = srt.replaceAll("\r",""); //in case each line ended with cr+lf + lines = lines.split(/[\r\n]+[\r\n]+/); + $.each(lines, function(key, line) { if (line.indexOf("-->") > -1) { - var parts = line.split(/[\r\n]+/)[0].split('-->'); + var parts = line.split(/[\r\n]+/)[1].split(/[\r\n]+/)[0].split('-->'); parts[0] = SubPlayerJS.timeStampToSeconds(parts[0], "srt"); parts[1] = SubPlayerJS.timeStampToSeconds(parts[1], "srt");