From 954b9c9037c5c1229358e4d502c9fca62c4ecde6 Mon Sep 17 00:00:00 2001 From: cangui Date: Thu, 19 Jun 2025 19:54:17 +0200 Subject: [PATCH] up --- internal/debridlink/client.go | 93 +++++++++++++++++------------------ renders/renders.go | 2 +- 2 files changed, 47 insertions(+), 48 deletions(-) diff --git a/internal/debridlink/client.go b/internal/debridlink/client.go index cba3660..0908e2e 100644 --- a/internal/debridlink/client.go +++ b/internal/debridlink/client.go @@ -525,57 +525,56 @@ func (c *Client) ListFiles(ctx context.Context, parentID string) ([]File, error) } // =========================== Stream =========================== -func (c *Client) CreateTranscode(ctx context.Context, fileID, preset string) (string, error) { - var resp struct{ TranscodeID string `json:"transcodeId"` } - body := map[string]string{"fileId": fileID, "preset": preset} - if err := c.doJSON(ctx, "POST", "stream/transcode", nil, body, &resp); err != nil { - return "", err - } - return resp.TranscodeID, nil -} +// func (c *Client) CreateTranscode(ctx context.Context, fileID, preset string) (string, error) { +// var resp struct{ TranscodeID string `json:"transcodeId"` } +// body := map[string]string{"fileId": fileID} +// if err := c.doJSON(ctx, "POST", "stream/transcode", nil, body, &resp); err != nil { +// return "", err +// } +// return resp.TranscodeID, nil +// } -func (c *Client) GetTranscode(ctx context.Context, fileID string) (*StreamInfo, error) { - body := struct { - ID string `json:"id"` - }{ - ID: fileID, - } +func (c *Client) CreateTranscode(ctx context.Context, fileID string) (*StreamInfo, error) { + requestBody := map[string]string{ + "id": fileID, + } - var raw struct { - Success bool `json:"success"` - Value struct { - ID string `json:"id"` - StreamURL string `json:"streamUrl"` - DownloadURL string `json:"downloadUrl"` - Type string `json:"type"` - MimeType string `json:"mimetype"` - Domain string `json:"domain"` - File struct { - ID string `json:"id"` - Name string `json:"name"` - Size int64 `json:"size"` - Source string `json:"source"` - } `json:"file"` - } `json:"value"` - } + var raw struct { + Success bool `json:"success"` + Value struct { + ID string `json:"id"` + StreamURL string `json:"streamUrl"` + DownloadURL string `json:"downloadUrl"` + Type string `json:"type"` + MimeType string `json:"mimetype"` + Domain string `json:"domain"` + File struct { + ID string `json:"id"` + Name string `json:"name"` + Size int64 `json:"size"` + Source string `json:"source"` + } `json:"file"` + } `json:"value"` + } - path := "stream/transcode/add" - if err := c.doJSON(ctx, "POST", path, nil, body, &raw); err != nil { - return nil, err - } + path := "stream/transcode/add" + if err := c.doJSON(ctx, "POST", path, nil, requestBody, &raw); err != nil { + return nil, err + } - info := &StreamInfo{ - ID: raw.Value.ID, - StreamURL: raw.Value.StreamURL, - DownloadURL: raw.Value.DownloadURL, - Type: raw.Value.Type, - MimeType: raw.Value.MimeType, - Domain: raw.Value.Domain, - FileID: raw.Value.File.ID, - FileName: raw.Value.File.Name, - FileSize: raw.Value.File.Size, - } - return info, nil + info := &StreamInfo{ + ID: raw.Value.ID, + StreamURL: raw.Value.StreamURL, + DownloadURL: raw.Value.DownloadURL, + Type: raw.Value.Type, + MimeType: raw.Value.MimeType, + Domain: raw.Value.Domain, + FileID: raw.Value.File.ID, + FileName: raw.Value.File.Name, + FileSize: raw.Value.File.Size, + } + return info, nil } + diff --git a/renders/renders.go b/renders/renders.go index 536d3c1..59ab3b0 100644 --- a/renders/renders.go +++ b/renders/renders.go @@ -309,7 +309,7 @@ func HandleAddJob(db *gorm.DB) http.HandlerFunc { // Enregistre chaque lien comme un job "en attente" for _, l := range links { - streamInfo, err := client.GetTranscode(ctx, l.ID) + streamInfo, err := client.CreateTranscode(ctx,l.ID) if err != nil { log.Println("Erreur GetTranscode:", err) return