diff --git a/materialious/src/lib/misc.ts b/materialious/src/lib/misc.ts index aad36367..a8099c05 100644 --- a/materialious/src/lib/misc.ts +++ b/materialious/src/lib/misc.ts @@ -40,31 +40,46 @@ export interface PhasedDescription { export function phaseDescription(content: string): PhasedDescription { const timestamps: { title: string; time: number; timePretty: string; }[] = []; + console.log(content); const lines = content.split('\n'); - const regex = /(\d+:\d+(?::\d+)?)(?:\s(.+))?/; - const filteredLines = lines.filter(line => { - const match = regex.exec(line); + const urlRegex = /(\d+:\d+(?::\d+)?)<\/a>\s*(.+)/; - if (match !== null) { - const timestamp = match[1]; - const title = match[2] || ''; - timestamps.push({ - time: convertToSeconds(timestamp), - title: title, - timePretty: timestamp - }); - return false; + let filteredLines: string[] = []; + lines.forEach( + (line) => { + const urlMatch = urlRegex.exec(line); + const timestampMatch = timestampRegex.exec(line); + + if (urlMatch !== null && timestampMatch === null) { + // If line contains a URL but not a timestamp, modify the URL + const modifiedLine = line.replace(/ parseInt(part)); let seconds = 0; diff --git a/materialious/src/routes/watch/[slug]/+page.svelte b/materialious/src/routes/watch/[slug]/+page.svelte index 05e4b875..4b433f41 100644 --- a/materialious/src/routes/watch/[slug]/+page.svelte +++ b/materialious/src/routes/watch/[slug]/+page.svelte @@ -217,7 +217,9 @@

{numberWithCommas(data.video.viewCount)} views • {data.video.publishedText}

- {@html data.video.descriptionHtml} +
+ {@html data.content.description} +
{#if data.content} {#if data.content.timestamps.length > 0}
Chapters
diff --git a/materialious/src/routes/watch/[slug]/+page.ts b/materialious/src/routes/watch/[slug]/+page.ts index 0e24d9bf..09529f79 100644 --- a/materialious/src/routes/watch/[slug]/+page.ts +++ b/materialious/src/routes/watch/[slug]/+page.ts @@ -45,7 +45,7 @@ export async function load({ params, url }) { returnYTDislikes: returnYTDislikes, comments: comments, subscribed: await amSubscribed(video.authorId), - content: phaseDescription(video.description), + content: phaseDescription(video.descriptionHtml), playlistId: url.searchParams.get('playlist'), personalPlaylists: personalPlaylists };