From d7692875dbc923f54560726dff14b3130e2a8264 Mon Sep 17 00:00:00 2001 From: Vladimir Zagainov Date: Sun, 18 Oct 2026 11:56:11 +0300 Subject: [PATCH] Add debug logging to GetTrackDownloadURL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The library returns download_info but GetTrackDownloadURL cannot extract a working URL (bestInfo.URL is empty). Added debug logging of all download info candidates and a more descriptive error message to diagnose why Yandex API returns entries without URL. This is a ym-dl issue, not a library issue — the library correctly returns download_info; ym-dl fails to build a download URL from it. --- internal/yandex/client.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/yandex/client.go b/internal/yandex/client.go index ad375d8..5439190 100644 --- a/internal/yandex/client.go +++ b/internal/yandex/client.go @@ -221,6 +221,12 @@ func (c *YandexClient) GetTrackDownloadURL(ctx context.Context, trackID string) return "", fmt.Errorf("no suitable download info found") } + if c.debug { + for i, info := range downloadInfos { + c.logger.Debug("download info candidate", "index", i, "codec", info.Codec, "bitrate", info.Bitrate, "direct_link", info.DirectLink, "url", info.URL) + } + } + // If we have a direct URL, use it if bestInfo.URL != "" && bestInfo.DirectLink { return bestInfo.URL, nil @@ -253,5 +259,5 @@ func (c *YandexClient) GetTrackDownloadURL(ctx context.Context, trackID string) return finalURL, nil } - return "", fmt.Errorf("no download URL available") + return "", fmt.Errorf("no download URL available: bestInfo.URL is empty (codec=%s, bitrate=%d, direct_link=%v)", bestInfo.Codec, bestInfo.Bitrate, bestInfo.DirectLink) }