package ytdlp import ( "context" "fmt" ytd "github.com/lrstanley/go-ytdlp" ) // Fetch fetches info from a video on YouTube or other sites supported by yt-dlp func Fetch(ctx context.Context, url string) (*ytd.ExtractedInfo, error) { dl := ytd.New().DumpJSON().RemoteComponents("ejs:github") // TODO Add cookies if available res, err := dl.Run(ctx, url) if err != nil { return nil, err } infos, err := res.GetExtractedInfo() if err != nil { return nil, err } if len(infos) != 1 { return nil, fmt.Errorf("%d infos", len(infos)) } return infos[0], nil }