Merge pull request #1362 from doublex/master
#46 - two patches from 'jamesoflol'
This commit is contained in:
commit
566b957e65
@ -17,17 +17,17 @@ const parseVtt = vttDataString => {
|
|||||||
if (!is.number(result.startTime)) {
|
if (!is.number(result.startTime)) {
|
||||||
// The line with start and end times on it is the first line of interest
|
// The line with start and end times on it is the first line of interest
|
||||||
const matchTimes = line.match(
|
const matchTimes = line.match(
|
||||||
/([0-9]{2}):([0-9]{2}):([0-9]{2}).([0-9]{2,3})( ?--> ?)([0-9]{2}):([0-9]{2}):([0-9]{2}).([0-9]{2,3})/,
|
/([0-9]{2})?:?([0-9]{2}):([0-9]{2}).([0-9]{2,3})( ?--> ?)([0-9]{2})?:?([0-9]{2}):([0-9]{2}).([0-9]{2,3})/,
|
||||||
); // Note that this currently ignores caption formatting directives that are optionally on the end of this line - fine for non-captions VTT
|
); // Note that this currently ignores caption formatting directives that are optionally on the end of this line - fine for non-captions VTT
|
||||||
|
|
||||||
if (matchTimes) {
|
if (matchTimes) {
|
||||||
result.startTime =
|
result.startTime =
|
||||||
Number(matchTimes[1]) * 60 * 60 +
|
Number(matchTimes[1] || 0) * 60 * 60 +
|
||||||
Number(matchTimes[2]) * 60 +
|
Number(matchTimes[2]) * 60 +
|
||||||
Number(matchTimes[3]) +
|
Number(matchTimes[3]) +
|
||||||
Number(`0.${matchTimes[4]}`);
|
Number(`0.${matchTimes[4]}`);
|
||||||
result.endTime =
|
result.endTime =
|
||||||
Number(matchTimes[6]) * 60 * 60 +
|
Number(matchTimes[6] || 0) * 60 * 60 +
|
||||||
Number(matchTimes[7]) * 60 +
|
Number(matchTimes[7]) * 60 +
|
||||||
Number(matchTimes[8]) +
|
Number(matchTimes[8]) +
|
||||||
Number(`0.${matchTimes[9]}`);
|
Number(`0.${matchTimes[9]}`);
|
||||||
@ -148,7 +148,10 @@ class PreviewThumbnails {
|
|||||||
|
|
||||||
// If the URLs don't start with '/', then we need to set their relative path to be the location of the VTT file
|
// If the URLs don't start with '/', then we need to set their relative path to be the location of the VTT file
|
||||||
// If the URLs do start with '/', then they obviously don't need a prefix, so it will remain blank
|
// If the URLs do start with '/', then they obviously don't need a prefix, so it will remain blank
|
||||||
if (!thumbnail.frames[0].text.startsWith('/')) {
|
// If the thumbnail URLs start with with none of '/', 'http://' or 'https://', then we need to set their relative path to be the location of the VTT file
|
||||||
|
if (!thumbnail.frames[0].text.startsWith('/') &&
|
||||||
|
!thumbnail.frames[0].text.startsWith('http://') &&
|
||||||
|
!thumbnail.frames[0].text.startsWith('https://')) {
|
||||||
thumbnail.urlPrefix = url.substring(0, url.lastIndexOf('/') + 1);
|
thumbnail.urlPrefix = url.substring(0, url.lastIndexOf('/') + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user