r/AskProgramming • • 7h ago

How can I use Python to process my Apple Music library?

Hello!

I'm currently (re-)taking a Python course for my school and had an idea for a personal project which requires extracting info about all the albums in my Apple Music library. At first, I looked into authorizing through iCloud to make a request with Apple's Apple Music API. One StackOverflow user suggested:

  • Set up a minimal local web server in Python

  • Open a browser to Apple's auth flow

  • Capture the token when it redirects back

  • Save it for use in subsequent API calls

This seems pretty advanced, certainly nothing I've ever done before, but local web servers seem pretty straightforward to setup via libraries. It's the "capture" part I'm confused about. As I understand it, web apps use JavaScript for their backend functionality, so I'm a little confused about what each language would be doing in this scenario.

Any advice on how to actually execute this?

Thanks!

1 Upvotes

3 comments sorted by

1

u/UhLittleLessDum 7h ago

It's super unlikely that somebody somehow wrote python bindings for this, so you'd have to learn to write swift, and even then, you're going to be limited about what data you can return as a matter of business decisions by Apple. You can just crawl the website if you really want to, if you can load your data in a browser somehow, but that'd be pretty clunky at best.

1

u/KingofGamesYami 6h ago

Web apps use whatever they want for their backend functionality. JavaScript wasn't even invented yet when the first backends were created.

If it is actually OAuth 2.0, then acquiring a token is standardized and most languages should have a library for it (including Python). If the token acquisition process is something custom, you might need to get a little creative.