Closed kingosticks closed 1 year ago
Ah thanks for this! Is this ready to merge now or do you first need an answer to your question? I do agree we should make it more robust now it is clear that domains can change anytime. A catch-all seems like a good idea.
The other idea would be to use a regex and grab the first run of digits in the query string. That would catch all three versions and possibly future versions too.
I wasn't sure what the implication of ignoring the expiry was. Perhaps it's actually better to just ignore the URLs we can't parse. I'd be happy to make that extra change.
Maybe make a best effort attempt and on failure log a helpful message to report this unknown format to the project for implementation?
The expiry should only hit you when you somehow repeat a song, loading it from the same URL with the URL cached but not the file. Or you get the URL and then wait a really long time before downloading it. Should be edge cases, so the expiry is a nice to have.
I've had a go, what do you think?
Looks good to me, ready to merge?
Yep!
The CDN URLs list now includes spotifycdn.com which has a different format. It was being erroneously interpreted using the scdn.co format and trying to parse non-digit characters as a timestamp.
It was trying to interpret the entire query string of "https://audio-gm-off.spotifycdn.com/audio/4712bc9e47f7feb4ee3450ef2bb545e1d83c3d54?Expires=1688165560~FullPath~hmac=IIZA28qptl8cuGLq15-SjHKHtLoxzpy_6r_JpAU4MfM=" as a number.
Maybe it would be better to match on the domain? Or at least catch the
parse()
error and just pretend it's not expiring?