Skip to content

Commit

Permalink
For HTML transcripts, just use the next segment's startTime for the e…
Browse files Browse the repository at this point in the history
…ndTime instead of adding the startTime to it.

Resolves #14
  • Loading branch information
stevencrader committed Apr 2, 2023
1 parent 344bbfe commit af759a2
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 89 deletions.
3 changes: 1 addition & 2 deletions src/formats/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ const getSegmentsFromHTMLElements = (elements: Array<HTMLElement>): Array<Segmen
// update endTime of previous Segment
const totalSegments = outSegments.length
if (totalSegments > 0) {
outSegments[totalSegments - 1].endTime =
outSegments[totalSegments - 1].startTime + s.segment.startTime
outSegments[totalSegments - 1].endTime = s.segment.startTime
outSegments[totalSegments - 1].endTimeFormatted = timestampFormatter.format(
outSegments[totalSegments - 1].endTime
)
Expand Down
6 changes: 3 additions & 3 deletions test/html.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, test } from "@jest/globals"

import { Segment } from "../src"
import { parseHTML } from "../src/formats/html"
import { Segment } from "../src/types"

import { readFile, TestFiles } from "./test_utils"

Expand Down Expand Up @@ -225,8 +225,8 @@ describe("Bad HTML data", () => {
{
startTime: 1,
startTimeFormatted: "00:00:01.000",
endTime: 31,
endTimeFormatted: "00:00:31.000",
endTime: 30,
endTimeFormatted: "00:00:30.000",
speaker: "Kevin",
body: "It is so stinking nice to like, show up and record this show. And Travis has already put together an outline. Kevin's got suggestions, I throw my thoughts into the mix. And then Travis goes and does all the work from there, too. It's out into the wild. And I don't see anything. That's an absolute joy for at least two thirds of the team. Yeah, I mean, exactly.",
},
Expand Down
2 changes: 1 addition & 1 deletion test/json.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, test } from "@jest/globals"

import { Segment } from "../src"
import { parseJSON } from "../src/formats/json"
import { Segment } from "../src/types"

import { readFile, TestFiles } from "./test_utils"

Expand Down
2 changes: 1 addition & 1 deletion test/srt.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, jest, test } from "@jest/globals"

import { Segment } from "../src"
import { parseSRT, parseSRTSegment, SRTSegment } from "../src/formats/srt"
import { Segment } from "../src/types"

import { readFile, TestFiles } from "./test_utils"

Expand Down
3 changes: 1 addition & 2 deletions test/test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { describe, expect, test } from "@jest/globals"

import { combineSingleWordSegments, convertFile, determineFormat } from "../src"
import { Segment, TranscriptFormat } from "../src/types"
import { combineSingleWordSegments, convertFile, determineFormat, Segment, TranscriptFormat } from "../src"

import { readFile, TestFiles } from "./test_utils"

Expand Down
128 changes: 64 additions & 64 deletions test/test_files/buzzcast_html_parsed.json

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions test/test_files/podnews_weekly_review_html_parsed.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/test_utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"
import * as path from "node:path"

import { Segment } from "../src/types"
import { Segment } from "../src"

export enum TestFiles {
TRANSCRIPT_HTML_BUZZCAST = "buzzcast.html",
Expand Down

0 comments on commit af759a2

Please sign in to comment.