This commit is contained in:
cangui 2025-06-19 20:15:23 +02:00
parent f530d9da51
commit f123e928c2

View File

@ -535,46 +535,45 @@ func (c *Client) ListFiles(ctx context.Context, parentID string) ([]File, error)
// } // }
func (c *Client) CreateTranscode(ctx context.Context, fileID string) (*StreamInfo, error) { func (c *Client) CreateTranscode(ctx context.Context, fileID string) (*StreamInfo, error) {
requestBody := map[string]string{ body := map[string]string{"id": fileID}
"id": fileID,
}
var raw struct { var raw struct {
Success bool `json:"success"` Success bool `json:"success"`
Value struct { Value struct {
ID string `json:"id"` ID string `json:"id"`
StreamURL string `json:"streamUrl"` StreamURL string `json:"streamUrl"`
DownloadURL string `json:"downloadUrl"` DownloadURL string `json:"downloadUrl"`
Type string `json:"type"` Type string `json:"type"`
MimeType string `json:"mimetype"` MimeType string `json:"mimetype"`
Domain string `json:"domain"` Domain string `json:"domain"`
File struct { File struct {
ID string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Size int64 `json:"size"` Size int64 `json:"size"`
Source string `json:"source"` Source string `json:"source"`
} `json:"file"` } `json:"file"`
} `json:"value"` } `json:"value"`
} }
path := "stream/transcode/add" path := "stream/transcode/add"
if err := c.doJSON(ctx, "POST", path, nil, requestBody, &raw); err != nil { if err := c.doJSON(ctx, "POST", path, nil, body, &raw); err != nil {
return nil, err return nil, err
} }
info := &StreamInfo{ info := &StreamInfo{
ID: raw.Value.ID, ID: raw.Value.ID,
StreamURL: raw.Value.StreamURL, StreamURL: raw.Value.StreamURL,
DownloadURL: raw.Value.DownloadURL, DownloadURL: raw.Value.DownloadURL,
Type: raw.Value.Type, Type: raw.Value.Type,
MimeType: raw.Value.MimeType, MimeType: raw.Value.MimeType,
Domain: raw.Value.Domain, Domain: raw.Value.Domain,
FileID: raw.Value.File.ID, FileID: raw.Value.File.ID,
FileName: raw.Value.File.Name, FileName: raw.Value.File.Name,
FileSize: raw.Value.File.Size, FileSize: raw.Value.File.Size,
} }
return info, nil return info, nil
} }