From e6d82ac6eef100326a14c332dd1cecc900a7cecd Mon Sep 17 00:00:00 2001 From: aliaj1 Date: Mon, 10 Nov 2025 17:56:06 +0200 Subject: [PATCH] ulozto: Fix downloads returning HTML error page The uloz.to backend was failing to download files, instead returning an HTML page with a "Slow download" message. This was caused by recent changes in the uloz.to API. This commit fixes the issue by making the following changes to the download process: 1. The `hash` received from the download link API is now appended as a query parameter to the download URL. 2. The download is now performed using the authenticated `rest` client to ensure premium access is recognized. 3. The `DeviceID` is now generated dynamically for each download request to avoid potential rate-limiting of a static ID. --- backend/ulozto/ulozto.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/backend/ulozto/ulozto.go b/backend/ulozto/ulozto.go index 7c3ab29ee..8cab77fee 100644 --- a/backend/ulozto/ulozto.go +++ b/backend/ulozto/ulozto.go @@ -801,8 +801,7 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (rc io.Read req := &api.GetDownloadLinkRequest{ Slug: o.slug, UserLogin: o.fs.opt.Username, - // Has to be set but doesn't seem to be used server side. - DeviceID: "foobar", + DeviceID: fmt.Sprintf("%d", time.Now().UnixNano()), } var resp *api.GetDownloadLinkResponse @@ -815,16 +814,26 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (rc io.Read return nil, err } + downloadURL := resp.Link + if resp.Hash != "" { + if strings.Contains(downloadURL, "?") { + downloadURL += "&" + } else { + downloadURL += "?" + } + downloadURL += "hash=" + url.QueryEscape(resp.Hash) + } + opts = rest.Opts{ Method: "GET", - RootURL: resp.Link, + RootURL: downloadURL, Options: options, } var httpResp *http.Response err = o.fs.pacer.Call(func() (bool, error) { - httpResp, err = o.fs.cdn.Call(ctx, &opts) + httpResp, err = o.fs.rest.Call(ctx, &opts) return o.fs.shouldRetry(ctx, httpResp, err, true) }) if err != nil {