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

Automate Apple Music token updates #590

Closed
miraclx opened this issue Nov 7, 2023 · 9 comments · Fixed by #623
Closed

Automate Apple Music token updates #590

miraclx opened this issue Nov 7, 2023 · 9 comments · Fixed by #623
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@miraclx
Copy link
Owner

miraclx commented Nov 7, 2023

The most filed, recurring issue is the Apple Music token expiring - #14, #70, #91, #399, #439, #481, #497, #498, #501, #530, #534, #548, #584 and #585.

It would be great to have the updates automated, and not require new releases of freyr.

Right now? I do the process manually which is;

$ xh https://music.apple.com/us/browse | rg 'assets/index-[a-z0-9]{8}.js' --only-matching
assets/index-e39f660e.js

$ xh https://music.apple.com/assets/index-e39f660e.js | rg 'eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IldlYlBsYXlLaWQifQ[^"]+' --only-matching
eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IldlYlBsYXlLaWQifQ.eyJpc3MiOiJBTVBXZWJQbGF5IiwiaWF0IjoxNjk4Nzg1ODQzLCJleHAiOjE3MDYwNDM0NDMsInJvb3RfaHR0cHNfb3JpZ2luIjpbImFwcGxlLmNvbSJdfQ.67_dZZLL08roWZOP_7OyujGvoudeZN5aQgpvYQfrwxG7EotRme5a6YcZ9aKD66A1bvLY1zBvfoCroC5RJfOJpw

# update the conf.json

We should be able to do this extraction inside freyr itself like we do with Spotify to auto-refresh the token.

@miraclx miraclx added enhancement New feature or request good first issue Good for newcomers labels Nov 7, 2023
@p0we7
Copy link

p0we7 commented Nov 20, 2023

https://music.apple.com/assets/index-d98aab9a.js

Why is the docker image still running with a 401 error even though I replaced the tonken in the default conf.json with the latest token?

@miraclx
Copy link
Owner Author

miraclx commented Nov 21, 2023

First, can you file another issue? since this is a tracking issue for automation not token-related issues.

And in that, can you elaborate on how you are updating the token and building the image?

@zykrah
Copy link

zykrah commented Dec 20, 2023

@miraclx
Copy link
Owner Author

miraclx commented Dec 20, 2023

@zykrah, yeah it's practically equivalent to the script I have in the OP. Just that they're writing it to the file at the end, but you still have to manually call the script.

For freyr, I would like to integrate it directly so that when freyr itself detects that the token has expired, it updates it itself.

@zykrah
Copy link

zykrah commented Dec 20, 2023

I've translated the process into a python script, I don't know much JavaScript but I'm sure it wouldn't be too difficult using requests and regex/whatever other string manipulation? As for detection of whether the token has expired, couldn't you just test for 401 responses whenever you call to the endpoint and then run the token update function (and cache it locally?).

@miraclx
Copy link
Owner Author

miraclx commented Dec 21, 2023

Yes, exactly. We already have detection, just not update and eventual persistence.

Haven't had the time for a while. 😓

@femd1ngu5
Copy link

how can i do this on my own, i cant run the commands (linux)

@femd1ngu5
Copy link

nvm i got used the script and it worked

@miraclx
Copy link
Owner Author

miraclx commented Jan 2, 2024

@Khadeeejah just submitted #623, which is a promising resolution for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants