mirror of
https://github.com/TeamPiped/Piped.git
synced 2025-10-14 19:38:18 +00:00
correct parsing for timestamp-links in current video
This commit is contained in:

committed by
robertkleinschuster

parent
3dfdf8806f
commit
66f3584895
@@ -6,3 +6,24 @@ export const isEmail = input => {
|
||||
);
|
||||
return result;
|
||||
};
|
||||
|
||||
export const parseTimeParam = time => {
|
||||
let start = 0;
|
||||
if (/^[\d]*$/g.test(time)) {
|
||||
start = time;
|
||||
} else {
|
||||
const hours = /([\d]*)h/gi.exec(time)?.[1];
|
||||
const minutes = /([\d]*)m/gi.exec(time)?.[1];
|
||||
const seconds = /([\d]*)s/gi.exec(time)?.[1];
|
||||
if (hours) {
|
||||
start += parseInt(hours) * 60 * 60;
|
||||
}
|
||||
if (minutes) {
|
||||
start += parseInt(minutes) * 60;
|
||||
}
|
||||
if (seconds) {
|
||||
start += parseInt(seconds);
|
||||
}
|
||||
}
|
||||
return start;
|
||||
};
|
||||
|
Reference in New Issue
Block a user