Skip to content

Commit

Permalink
Improve Youtube Smart Note feature
Browse files Browse the repository at this point in the history
  • Loading branch information
blackforestboi committed Feb 26, 2024
1 parent a5287de commit 5d737bf
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/sidebar/annotations-sidebar/containers/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4573,6 +4573,12 @@ export class SidebarContainerLogic extends UILogic<
return formattedHrs + formattedMins + formattedSecs
}

createHumanTimestamp(startTime) {
const minutes = Math.floor(startTime / 60)
const seconds = startTime % 60
return `${minutes}:${seconds.toString().padStart(2, '0')}`
}

createYoutubeTimestampWithAISummary: EventHandler<
'createYoutubeTimestampWithAISummary'
> = async ({ previousState, event }) => {
Expand Down Expand Up @@ -4610,11 +4616,9 @@ export class SidebarContainerLogic extends UILogic<
const maxRetries = 30
let handledSuccessfully = false

const humanTimestamp = `${Math.floor(
event.videoRangeTimestamps.startTimeSecs / 60,
)}:${(event.videoRangeTimestamps.startTimeSecs % 60)
.toString()
.padStart(2, '0')}`
const humanTimestamp = this.createHumanTimestamp(
event.videoRangeTimestamps.startTimeSecs,
)

const videoURLWithTime = constructVideoURLwithTimeStamp(
window.location.href,
Expand All @@ -4640,7 +4644,12 @@ export class SidebarContainerLogic extends UILogic<
}

const combinedText = filteredTranscript
.map((item) => item.text)
.map(({ start, text }) => ({
start: Math.floor(start),
timestamp: this.createHumanTimestamp(Math.floor(start)),
text,
}))
.map((item) => JSON.stringify(item))
.join(' ')

let prompt = event.prompt ?? 'Summarise this concisely and briefly'
Expand Down

0 comments on commit 5d737bf

Please sign in to comment.