This commit is contained in:
Kuba Orlik 2023-12-15 21:13:32 +01:00
parent 5efabcdc62
commit 2ecaa54e18

View File

@ -44,16 +44,16 @@ export function parse_youtube(content: string): Timestamp[] {
content content
.split("\n") .split("\n")
.filter((l) => l.length > 4) .filter((l) => l.length > 4)
.map((l) => l.match(/([0-9]{1,}:[0-9]{2})\s(.*)/)) .map((l) => l.match(/(([0-9]:)?[0-9]{1,2}:[0-9]{2})\s(.*)/))
); );
return ( return (
content content
.split("\n") .split("\n")
.filter((l) => l.length > 4) .filter((l) => l.length > 4)
.map((l) => l.match(/([0-9]{1,}:[0-9]{2})\s(.*)/)) .map((l) => l.match(/(([0-9]:)?[0-9]{1,2}:[0-9]{2})\s(.*)/))
.filter((m) => m != null) as string[][] .filter((m) => m != null) as string[][]
).map(([_, time_s, title]) => ({ ).map(([_, time_s, __, title]) => ({
title, title: title.replace(/^\s*[-:]\s+/, ""),
timestamp: parseTimestamp(time_s), timestamp: parseTimestamp(time_s),
})); }));
} }