Files
podcast-search-go/model/transcript.go
2025-03-28 22:27:08 +08:00

58 lines
1.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Package model 提供播客和剧集的数据模型
package model
import (
"time"
)
// TranscriptFormat 表示转录文件的格式
type TranscriptFormat string
const (
// TranscriptFormatJSON 表示JSON格式的转录
TranscriptFormatJSON TranscriptFormat = "json"
// TranscriptFormatSubrip 表示SRT格式的转录
TranscriptFormatSubrip TranscriptFormat = "subrip"
// TranscriptFormatUnsupported 表示不支持的格式
TranscriptFormatUnsupported TranscriptFormat = "unsupported"
)
// TranscriptURL 表示播客中包含的转录URL
type TranscriptURL struct {
// 转录的URL
URL string `json:"url,omitempty"`
// 转录的类型json或srt
Type TranscriptFormat `json:"type,omitempty"`
// 转录的语言
Language string `json:"language,omitempty"`
// 如果设置为captions表示这是一个闭合字幕文件
Rel string `json:"rel,omitempty"`
}
// Transcript 表示一个转录
type Transcript struct {
// 字幕列表
Subtitles []Subtitle `json:"subtitles,omitempty"`
}
// Subtitle 表示转录中的一行
type Subtitle struct {
// 字幕的索引(顺序)
Index int `json:"index,omitempty"`
// 字幕的开始时间
Start time.Duration `json:"start,omitempty"`
// 字幕的结束时间
End time.Duration `json:"end,omitempty"`
// 字幕的文本内容
Data string `json:"data,omitempty"`
// 发言人(可选)
Speaker string `json:"speaker,omitempty"`
}