tstor/pkg/ytdlp/info.go
royalcat e9df8925d1
Some checks failed
docker / build-docker (linux/amd64) (push) Failing after 18s
docker / build-docker (linux/386) (push) Successful in 1m57s
docker / build-docker (linux/arm64) (push) Successful in 7m22s
docker / build-docker (linux/arm/v7) (push) Successful in 7m53s
docker / build-docker (linux/arm64/v8) (push) Failing after 3h2m18s
storage rework
2024-06-15 01:14:44 +03:00

33 lines
513 B
Go

package ytdlp
import (
"bytes"
"context"
"encoding/json"
"os/exec"
)
func (c *Client) Info(ctx context.Context, url string) (*Info, error) {
args := []string{
"-q", "-J", url,
}
cmd := exec.CommandContext(ctx, c.binary, args...)
var stdout bytes.Buffer
var stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err := cmd.Run()
if err != nil {
return nil, err
}
var info Info
err = json.Unmarshal(stdout.Bytes(), &info)
if err != nil {
return nil, err
}
return &info, nil
}