mirror of
https://github.com/danielmiessler/fabric.git
synced 2026-09-10 07:36:44 -04:00
feat: correct video title (instead of id) and added description to yt transcript api response
This commit is contained in:
parent
26ac5f3bf9
commit
8a3fa9337c
|
|
@ -19,8 +19,10 @@ type YouTubeRequest struct {
|
|||
}
|
||||
|
||||
type YouTubeResponse struct {
|
||||
Transcript string `json:"transcript"`
|
||||
Title string `json:"title"`
|
||||
Transcript string `json:"transcript"`
|
||||
VideoId string `json:"videoId"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
func NewYouTubeHandler(r *gin.Engine, registry *core.PluginRegistry) *YouTubeHandler {
|
||||
|
|
@ -55,6 +57,12 @@ func (h *YouTubeHandler) Transcript(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
var metadata *youtube.VideoMetadata
|
||||
if metadata, err = h.yt.GrabMetadata(videoID); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var transcript string
|
||||
if req.Timestamps {
|
||||
transcript, err = h.yt.GrabTranscriptWithTimestamps(videoID, language)
|
||||
|
|
@ -66,5 +74,5 @@ func (h *YouTubeHandler) Transcript(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, YouTubeResponse{Transcript: transcript, Title: videoID})
|
||||
c.JSON(http.StatusOK, YouTubeResponse{Transcript: transcript, VideoId: videoID, Title: metadata.Title, Description: metadata.Description})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue