(topic: {
segments: { start: number; end: number }[];
quote?: { timestamp?: string } | null;
})
| 1349 | } |
| 1350 | |
| 1351 | function getTopicStartTime(topic: { |
| 1352 | segments: { start: number; end: number }[]; |
| 1353 | quote?: { timestamp?: string } | null; |
| 1354 | }): number { |
| 1355 | if (Array.isArray(topic.segments) && topic.segments.length > 0) { |
| 1356 | return topic.segments[0].start; |
| 1357 | } |
| 1358 | |
| 1359 | const rawTimestamp = topic.quote?.timestamp; |
| 1360 | if (!rawTimestamp) { |
| 1361 | return Infinity; |
| 1362 | } |
| 1363 | |
| 1364 | const cleaned = rawTimestamp.replace(/[\[\]]/g, '').trim(); |
| 1365 | if (!cleaned) { |
| 1366 | return Infinity; |
| 1367 | } |
| 1368 | |
| 1369 | const parts = cleaned.split(/-|–|—| to /i); |
| 1370 | const startPart = parts[0]?.trim(); |
| 1371 | if (!startPart) { |
| 1372 | return Infinity; |
| 1373 | } |
| 1374 | |
| 1375 | const timeSegments = startPart.split(':').map((part) => Number(part)); |
| 1376 | if (timeSegments.some((segment) => Number.isNaN(segment))) { |
| 1377 | return Infinity; |
| 1378 | } |
| 1379 | |
| 1380 | if (timeSegments.length === 3) { |
| 1381 | const [hours, minutes, seconds] = timeSegments; |
| 1382 | return hours * 3600 + minutes * 60 + seconds; |
| 1383 | } |
| 1384 | |
| 1385 | if (timeSegments.length === 2) { |
| 1386 | const [minutes, seconds] = timeSegments; |
| 1387 | return minutes * 60 + seconds; |
| 1388 | } |
| 1389 | |
| 1390 | if (timeSegments.length === 1) { |
| 1391 | return timeSegments[0]; |
| 1392 | } |
| 1393 | |
| 1394 | return Infinity; |
| 1395 | } |
| 1396 | |
| 1397 | function sanitizeThemeList(themes: string[]): string[] { |
| 1398 | const unique = new Set<string>(); |
no outgoing calls
no test coverage detected