Add debug logging to GetTrackDownloadURL
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.
This commit is contained in:
1 parent
5dcdd92d40
commit
d7692875db
1 file changed
+7
-1
@@ -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)
|
||||
}
|
||||
Reference in new issue
Block a user