diff --git a/src/index.ts b/src/index.ts index e1e0ae7..7461382 100644 --- a/src/index.ts +++ b/src/index.ts @@ -44,16 +44,16 @@ export function parse_youtube(content: string): Timestamp[] { content .split("\n") .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 ( content .split("\n") .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[][] - ).map(([_, time_s, title]) => ({ - title, + ).map(([_, time_s, __, title]) => ({ + title: title.replace(/^\s*[-:]\s+/, ""), timestamp: parseTimestamp(time_s), })); }