排序
根据艺术家和流派的相似性,自动将您的Spotify喜欢的歌曲排序到播放列表中。
特性
- 网络界面 -漂亮的Spotify风格的仪表板,用于管理您的设置和查看比赛历史记录
- 自动调度 -设置您喜欢的间隔和时间,其余的由Sortify处理
- 基于类型的匹配 -使用艺术家流派、重叠检测和流行度进行智能匹配
- 比赛历史 -跟踪已分类到播放列表中的所有歌曲
- 多用户支持 -PostgreSQL后端用于生产部署
- MCP集成 -还可以作为Claude Code的MCP服务器
运作原理
Sortify分析您最近喜欢的歌曲,并使用以下公式将其与现有播放列表进行匹配:
score = (artistOverlap × 0.35) +
(genreOverlap × 0.25) +
(weightedGenreScore × 0.25) +
(popularitySimilarity × 0.15)| 组件 | 重量 | 描述 |
|---|---|---|
| 艺术家重叠 | 35% | 如果曲目艺术家出现在播放列表中,则直接匹配 |
| 类型重叠 | 25% | 类型集的Jaccard相似性 |
| 加权流派 | 25% | 播放列表中频繁出现的流派奖金 |
| 流行度 | 15% | 与播放列表平均流行度相似的曲目 |
快速启动(地方发展)
1.获取Spotify API证书
- 首选 Spotify开发者仪表板
- 创建新应用程序
- 添加以下重定向URI:
- http://localhost:3001/api/auth/callback (适用于网络模式) - http://127.0.0.1:8888/callback (适用于MCP模式)
- 复制您的 客户端ID
2.安装并运行
# Install dependencies
npm install
cd web && npm install && cd ..
# Build
npm run build
cd web && npm run build && cd ..
# Set environment variable
export SPOTIFY_CLIENT_ID=your_client_id_here
# Run the web server
npm run web3.打开应用程序
访问 http://localhost:5173 并使用Spotify登录。
生产部署
为了生产,您需要:
- PostgreSQL 数据库
- 后端 (例如,铁路)
- 前端 (例如,Vercel)
环境变量
后端:
SPOTIFY_CLIENT_ID=your_client_id
DATABASE_URL=postgresql://...
REDIRECT_URI=https://your-backend.com/api/auth/callback
FRONTEND_URL=https://your-frontend.com
BETA_WHITELIST=user1@example.com,user2@example.com # Optional: comma-separated emails for beta access前端:
VITE_API_URL=https://your-backend.comMCP模式(克劳德码)
Sortify还可以作为Claude Code的MCP服务器。
添加到您的 ~/.claude.json:
{
"playlist-matcher": {
"command": "node",
"args": ["/path/to/playlist-matcher/dist/index.js"],
"env": {
"SPOTIFY_CLIENT_ID": "your_client_id_here"
}
}
}MCP工具
| 工具 | 说明 |
|---|---|
spotify_authorize | 启动OAuth登录流程 |
spotify_check_auth | 检查身份验证状态 |
spotify_get_liked_songs | 获取最近喜欢的歌曲 |
spotify_get_liked_songs_with_genres | 获取带有流派信息的喜欢歌曲 |
spotify_get_playlists | 获取您的播放列表 |
spotify_match_songs_to_playlists | 为每首喜欢的歌曲找到最佳播放列表 |
spotify_auto_organize_liked_songs | 匹配歌曲并将其添加到播放列表 |
项目结构
sortify/
├── src/ # Backend (Express + MCP server)
│ ├── web-server.ts # Express API server
│ ├── server.ts # MCP server tools
│ ├── scheduler/ # Cron job runner
│ ├── matching/ # Matching algorithm
│ │ └── genre-matcher.ts # Genre-based matching
│ ├── storage/ # Data persistence
│ │ ├── database.ts # PostgreSQL setup
│ │ └── pg-*.ts # PostgreSQL stores
│ ├── spotify/ # Spotify API client
│ └── auth/ # OAuth handling
│
├── web/ # Frontend (React + Vite)
│ └── src/
│ ├── components/ # React components
│ │ ├── Home.tsx # Settings page
│ │ ├── NewDashboard.tsx # Match history
│ │ └── About.tsx # About page
│ └── api.ts # API client
│
└── package.jsonAPI终点
| 端点 | 描述 |
|---|---|
GET /api/health | 正常运行时间和版本的健康检查 |
GET /api/auth/url | 获取OAuth URL |
GET /api/auth/status | 检查是否经过身份验证 |
POST /api/auth/logout | 注销 |
GET /api/settings | 获取用户设置 |
POST /api/settings | 更新设置 |
GET /api/match-history | 获取比赛历史记录 |
POST /api/sync-now | 触发手动同步 |
许可证
麻省理工学院
