Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new format for Expires url parameter in CDN Manager #736

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

tagdara
Copy link
Contributor

@tagdara tagdara commented Oct 20, 2023

In the last few days I noticed a number of track crashes or skips and discovered errors in the log similar to this:

2023-10-19 22:39:36,593 WARN CdnManager:186 - Couldn't extract expiration, invalid parameter in CDN url: https://audio4-gm-fb.spotifycdn.com/audio/b2...43?Expires=1697866776~FullPath~hmac=_Pl...t0=

Supported formats previously came in two flavors:

I added support for this new Expires parameter into setUrl in the CDN Manager, matching the format of the code which checks the token version

@@ -178,6 +182,18 @@ void setUrl(@NotNull HttpUrl url) {
}

expiration = expireAt * 1000;

} else if ( expiresStr != null && !expiresStr.isEmpty()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can never get expiresAt==null. But you can get a NumberFormatException.
I would replace this else if-block with

                } else if (expiresStr != null && !expiresStr.isEmpty()) {
                    String expiresStrVal = expiresStr.split("~")[0];
                    try {
                        expiration = Long.parseLong(expiresStrVal) * 1000;
                        LOGGER.info("Expires-based expiration {} ms", expiration);
                    } catch (NumberFormatException e) {
                        expiration = -1;
                        LOGGER.warn("Invalid Expires param in CDN url: {}", url);
                    }

                 } else {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants