1
0
mirror of https://github.com/rclone/rclone.git synced 2025-11-23 21:44:49 +02:00

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.
This commit is contained in:
aliaj1
2025-11-10 17:56:06 +02:00
committed by GitHub
parent 4c74ded85a
commit e6d82ac6ee

View File

@@ -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 {