Skip to content

Commit

Permalink
feat: добавлены таймкоды к суммаризации видео
Browse files Browse the repository at this point in the history
  • Loading branch information
Djaler committed Jul 7, 2024
1 parent 5a01c67 commit a1bf244
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ data class VideoSummaryResult(
val keypoints: List<Keypoint>?
)

@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy::class)
data class Keypoint(
val content: String,
val startTime: Long,
val theses: List<Thesis>,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import dev.inmo.tgbotapi.utils.regularln
import org.apache.logging.log4j.LogManager
import org.springframework.context.annotation.Conditional
import org.springframework.stereotype.Component
import java.time.Duration

@Component
@Conditional(YandexApiCondition::class)
Expand Down Expand Up @@ -90,7 +91,7 @@ class TlDrHandler(
messageToReply,
buildEntities {
for (keypoint in videoKeypoints) {
boldln(keypoint.content)
boldln("${buildTimeCode(keypoint.startTime)} ${keypoint.content}")
for (thesis in keypoint.theses) {
regularln("${thesis.content}")
}
Expand All @@ -99,6 +100,18 @@ class TlDrHandler(
)
}

private fun buildTimeCode(startTime: Long): String {
val duration = Duration.ofSeconds(startTime)
val seconds = duration.toSecondsPart()
val minutes = duration.toMinutesPart()
val hours = duration.toHoursPart()
return if (hours != 0) {
String.format("%02d:%02d:%02d", hours, minutes, seconds);
} else {
String.format("%02d:%02d", minutes, seconds);
}
}

private suspend fun replyWithArticleThesis(link: String, messageToReply: Message) {
val thesis = yandexGptService.generateLinkThesis(link)
if (thesis != null) {
Expand Down

0 comments on commit a1bf244

Please sign in to comment.