Turn a public Apple Music playlist into an AI-generated music taste and personality report.
Keywords: Apple Music playlist analyzer, AI music taste analysis, music personality profile, playlist recommendations, music discovery, Python Flask.
- Validates and parses Apple Music playlist URLs.
- Reads public playlists directly from Apple Music web pages—no Apple developer credentials required.
- Supports the Apple Music API as an optional fallback.
- Generates a structured Chinese or English music profile with OpenAI.
- Includes a demo mode that requires no API key.
- Provides clear, actionable error messages.
- Offers both a command-line interface and a local web interface.
On macOS, double-click start.command for a one-step local setup and launch. The first run installs the required Python packages.
Or start it manually:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
python main.py --demopython web_app.pyOpen http://127.0.0.1:5050 in your browser. Enter your API key only when submitting an analysis request. The app does not save it to a file, environment variable, or browser storage.
Public playlists do not require Apple developer credentials. Copy the example environment file and add an OpenAI API key if you want an AI-generated report:
cp .env.example .envpython main.py "https://music.apple.com/cn/playlist/my-playlist/pl.u-demo123"Fetch and export songs without calling OpenAI:
python main.py "APPLE_MUSIC_PLAYLIST_URL" --songs-onlyThe project ignores .env, secrets/, .p8 private keys, generated output, and the local virtual environment. Never paste credentials into source code or commit them to GitHub.
You only need Apple developer credentials if public-page extraction fails or if you later add access to a user's private library. Store the downloaded .p8 file inside the ignored secrets/ directory and configure:
APPLE_TEAM_ID=YOUR_10_CHARACTER_TEAM_ID
APPLE_KEY_ID=YOUR_10_CHARACTER_KEY_ID
APPLE_PRIVATE_KEY_PATH=secrets/AuthKey_YOUR_KEY_ID.p8
APPLE_TOKEN_VALID_DAYS=30The app generates the ES256 developer token in memory and does not write the generated token to disk.
Note
Public-page extraction depends on Apple Music's undocumented web-page structure and may break when Apple changes it.
This project is available under the MIT License. You may use, modify, and redistribute it under the license terms.
输入 Apple Music 公开歌单链接,读取歌曲并生成一份 AI 音乐偏好与人格报告。
搜索关键词: Apple Music 歌单分析、AI 音乐品味分析、音乐人格报告、歌单推荐、音乐发现、Python Flask。
- 验证并解析 Apple Music 歌单链接。
- 无需 Apple 开发者凭证,直接从公开网页读取歌单。
- 可选使用 Apple Music API 作为备用读取方案。
- 使用 OpenAI 生成结构化中文音乐画像。
- 提供不需要任何 API Key 的演示模式。
- 出错时提供清晰、可操作的提示。
- 同时提供命令行和本地网页界面。
在 macOS 上双击 start.command,即可自动准备环境并打开本地网页。第一次启动会安装所需的 Python 软件包。
也可以手动启动:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
python main.py --demopython web_app.py在浏览器中打开 http://127.0.0.1:5050。只有在提交分析请求时才需要输入 API Key;网页不会把它保存到文件、环境变量或浏览器存储。
公开歌单不需要 Apple Developer 凭证。如需生成 AI 报告,复制示例环境文件并填写 OpenAI API Key:
cp .env.example .envpython main.py "https://music.apple.com/cn/playlist/my-playlist/pl.u-demo123"只获取并导出歌曲,不调用 OpenAI:
python main.py "APPLE_MUSIC_歌单链接" --songs-only项目会忽略 .env、secrets/、.p8 私钥、生成结果和本地虚拟环境。不要把任何凭证粘贴进源代码,也不要将其提交到 GitHub。
只有公开网页读取失败,或者以后需要访问用户私人资料库时,才需要 Apple 开发者凭证。请将下载的 .p8 文件放入已被忽略的 secrets/ 目录,并填写:
APPLE_TEAM_ID=你的10位TeamID
APPLE_KEY_ID=你的10位KeyID
APPLE_PRIVATE_KEY_PATH=secrets/AuthKey_你的KeyID.p8
APPLE_TOKEN_VALID_DAYS=30程序会在内存中生成 ES256 Developer Token,不会把生成的 Token 写入磁盘。
Note
公开网页读取依赖 Apple Music 未公开的网页结构,Apple 调整页面后可能暂时失效。
本项目采用 MIT License。你可以在遵守许可证条款的前提下使用、修改和重新分发代码。
