自动下载Spotify最近喜欢的歌曲
高级
这是一个Other领域的自动化工作流,包含 23 个节点。主要使用 If, Set, Code, Filter, Spotify 等节点。 通过Spotify自动下载最近喜欢的歌曲
前置要求
- •无特殊前置要求,导入即可使用
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "84ba6d895254e080ac2b4916d987aa66b000f88d4d919a6b9c76848f9b8a7616",
"templateId": "2285",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "96c1dcb2-1fbe-4be5-b8e3-b5d2626bb5e8",
"name": "如果没有播放列表",
"type": "n8n-nodes-base.if",
"position": [
1180,
635.2020978272825
],
"parameters": {
"options": {},
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "4cd09fd5-f5bf-4f82-94f4-938e6d6fc1db",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.isEmpty() }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2
},
{
"id": "d17fdd6c-b998-4d41-9e44-34133577067b",
"name": "创建下载播放列表",
"type": "n8n-nodes-base.spotify",
"position": [
1840,
435.2020978272825
],
"parameters": {
"name": "Downloads",
"resource": "playlist",
"operation": "create",
"additionalFields": {}
},
"credentials": {
"spotifyOAuth2Api": {
"id": "MXfVMBGiR5OTHLNn",
"name": "Spotify account"
}
},
"typeVersion": 1
},
{
"id": "2250ac0d-5a7c-460c-a9b2-d3b1bcb44ac7",
"name": "获取喜欢的曲目",
"type": "n8n-nodes-base.spotify",
"position": [
2500,
735.2020978272825
],
"parameters": {
"limit": "={{ $('Globals').item.json.download_limit }}",
"resource": "library"
},
"credentials": {
"spotifyOAuth2Api": {
"id": "MXfVMBGiR5OTHLNn",
"name": "Spotify account"
}
},
"typeVersion": 1
},
{
"id": "ce3eed87-3d8a-4c37-84b7-7f08dd8d91bb",
"name": "遍历项目",
"type": "n8n-nodes-base.splitInBatches",
"position": [
2960,
735.2020978272825
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "0d5b326e-7bfa-48b6-a618-083e8e374632",
"name": "聚合",
"type": "n8n-nodes-base.aggregate",
"position": [
1400,
735.2020978272825
],
"parameters": {
"options": {},
"fieldsToAggregate": {
"fieldToAggregate": [
{
"fieldToAggregate": "name"
},
{
"fieldToAggregate": "uri"
}
]
}
},
"typeVersion": 1
},
{
"id": "113305f3-8003-4771-a260-2136d62d45ca",
"name": "拆分输出",
"type": "n8n-nodes-base.splitOut",
"position": [
1840,
735.2020978272825
],
"parameters": {
"options": {},
"fieldToSplitOut": "name, uri"
},
"typeVersion": 1
},
{
"id": "8684eaf3-104e-40b6-91b3-738b15f2b361",
"name": "添加曲目到下载",
"type": "n8n-nodes-base.spotify",
"position": [
3220,
835.2020978272825
],
"parameters": {
"id": "={{ $('Filter out Downloads Playlist').item.json.uri }}",
"trackID": "={{ $('Get Liked Tracks').item.json.track.uri }}",
"resource": "playlist",
"additionalFields": {
"position": 0
}
},
"credentials": {
"spotifyOAuth2Api": {
"id": "MXfVMBGiR5OTHLNn",
"name": "Spotify account"
}
},
"typeVersion": 1
},
{
"id": "a9f44907-b324-4a89-b81c-7b514b0a52cb",
"name": "获取下载播放列表",
"type": "n8n-nodes-base.spotify",
"position": [
2280,
735.2020978272825
],
"parameters": {
"id": "={{ $json.uri }}",
"resource": "playlist",
"operation": "get"
},
"credentials": {
"spotifyOAuth2Api": {
"id": "MXfVMBGiR5OTHLNn",
"name": "Spotify account"
}
},
"typeVersion": 1
},
{
"id": "75f69264-9653-46de-a571-f080238d0df1",
"name": "过滤出新曲目",
"type": "n8n-nodes-base.code",
"position": [
2720,
735.2020978272825
],
"parameters": {
"jsCode": "var downloades_uris = [];\nfor (const download of $('Get Downloads Playlist').first().json.tracks.items) {\n downloades_uris.push(download.track.uri);\n}\n\nvar result = [];\nfor (const item of $input.all()) {\n if (!downloades_uris.includes(item.json.track.uri)) {\n result.push(item);\n }\n}\n\nreturn result.reverse();"
},
"typeVersion": 2
},
{
"id": "54fa426a-f37c-4e9a-a817-f31a9e820d76",
"name": "获取要移除的曲目",
"type": "n8n-nodes-base.code",
"position": [
3440,
640
],
"parameters": {
"jsCode": "var liked_uris = [];\nfor (const liked of $('Get Liked Tracks').all()) {\n liked_uris.push(liked.json.track.uri);\n}\n\nvar result = [];\nfor (const item of $input.first().json.tracks.items) {\n if (!liked_uris.includes(item.track.uri)) {\n result.push(item);\n }\n}\n\nreturn result;"
},
"executeOnce": true,
"typeVersion": 2
},
{
"id": "3368ac49-64bc-4c51-8796-0fb5843ad899",
"name": "从下载中移除最旧的曲目",
"type": "n8n-nodes-base.spotify",
"position": [
3660,
635.2020978272825
],
"parameters": {
"id": "={{ $('Get Downloads Playlist').item.json.uri }}",
"trackID": "={{ $json.track.uri }}",
"resource": "playlist",
"operation": "delete"
},
"credentials": {
"spotifyOAuth2Api": {
"id": "MXfVMBGiR5OTHLNn",
"name": "Spotify account"
}
},
"typeVersion": 1
},
{
"id": "6ba744e0-f925-4901-8a01-b6da9c6b9e61",
"name": "过滤出下载播放列表",
"type": "n8n-nodes-base.filter",
"position": [
2060,
735.2020978272825
],
"parameters": {
"options": {},
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "04fec444-230c-4b55-a887-d4dd290c99ee",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.name }}",
"rightValue": "Downloads"
}
]
}
},
"typeVersion": 2
},
{
"id": "d1a583cb-1c60-44f3-9111-755805e81bf1",
"name": "获取更新的下载播放列表",
"type": "n8n-nodes-base.spotify",
"position": [
3220,
635.2020978272825
],
"parameters": {
"id": "={{ $('Filter out Downloads Playlist').item.json.uri }}",
"resource": "playlist",
"operation": "get"
},
"credentials": {
"spotifyOAuth2Api": {
"id": "MXfVMBGiR5OTHLNn",
"name": "Spotify account"
}
},
"executeOnce": true,
"typeVersion": 1
},
{
"id": "1f976308-b9db-4c59-8321-582a84c45374",
"name": "获取所有播放列表",
"type": "n8n-nodes-base.spotify",
"position": [
960,
635.2020978272825
],
"parameters": {
"resource": "playlist",
"operation": "getUserPlaylists",
"returnAll": true
},
"credentials": {
"spotifyOAuth2Api": {
"id": "MXfVMBGiR5OTHLNn",
"name": "Spotify account"
}
},
"typeVersion": 1,
"alwaysOutputData": true
},
{
"id": "c715d18a-981f-4cfa-b3ca-3ee9753ef7ca",
"name": "计划触发器",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
460,
635.2020978272825
],
"parameters": {
"rule": {
"interval": [
{}
]
}
},
"typeVersion": 1.2
},
{
"id": "b3afc8a7-39dc-429a-b440-8d2394ab528e",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
640,
475.2020978272825
],
"parameters": {
"width": 251.77358490566033,
"height": 334.6415094339622,
"content": "## 设置全局变量"
},
"typeVersion": 1
},
{
"id": "1867b7d6-771c-4915-b8ef-227b3ad21c09",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
380,
475.2020978272825
],
"parameters": {
"width": 251.77358490566033,
"height": 334.6415094339622,
"content": "## 设置触发器"
},
"typeVersion": 1
},
{
"id": "3f48a599-e41f-42ec-94c3-03315039612b",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
380,
240
],
"parameters": {
"color": 5,
"width": 511.919459860262,
"height": 227.98938005910577,
"content": "## 信息"
},
"typeVersion": 1
},
{
"id": "6b101255-c9ef-407c-9cf4-d9afde6d8613",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
900,
395.2020978272825
],
"parameters": {
"color": 7,
"width": 1535.0943396226407,
"height": 509.28301886792553,
"content": "按名称获取\"下载\"播放列表。如果不存在,则创建它。"
},
"typeVersion": 1
},
{
"id": "ae08fb14-34e5-454f-95f7-5de3a17dc6f7",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
2440,
655.2020978272825
],
"parameters": {
"color": 7,
"width": 435.1879320261786,
"height": 247.95572576973242,
"content": "获取所有最新喜欢的歌曲,并检查它们是否已存在于下载播放列表中。"
},
"typeVersion": 1
},
{
"id": "5603cad0-6b4d-479c-89e4-af0c950a95c3",
"name": "便签5",
"type": "n8n-nodes-base.stickyNote",
"position": [
2880,
575.2020978272825
],
"parameters": {
"color": 7,
"width": 955.93368580286,
"height": 452.51466620839244,
"content": "将新曲目添加到下载播放列表。如果曲目超过定义的限制,则移除曲目。"
},
"typeVersion": 1
},
{
"id": "6c40ce51-3361-4baf-b81e-b6e9b94a0a1c",
"name": "如果未找到下载播放列表",
"type": "n8n-nodes-base.if",
"position": [
1620,
735.2020978272825
],
"parameters": {
"options": {},
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "faf80ff7-8870-4f2e-94c0-998535caeac4",
"operator": {
"type": "array",
"operation": "notContains",
"rightType": "any"
},
"leftValue": "={{ $json.name }}",
"rightValue": "Downloads"
}
]
}
},
"typeVersion": 2
},
{
"id": "637e0927-387f-46f9-8402-f87300f1fb6d",
"name": "全局变量",
"type": "n8n-nodes-base.set",
"position": [
720,
640
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "077181f9-80b9-40c2-81db-69d49376da7d",
"name": "download_limit",
"type": "number",
"value": 50
}
]
}
},
"typeVersion": 3.3
}
],
"pinData": {},
"connections": {
"Globals": {
"main": [
[
{
"node": "Get all Playlists",
"type": "main",
"index": 0
}
]
]
},
"Aggregate": {
"main": [
[
{
"node": "If no Downloads Playlist found",
"type": "main",
"index": 0
}
]
]
},
"Split Out": {
"main": [
[
{
"node": "Filter out Downloads Playlist",
"type": "main",
"index": 0
}
]
]
},
"If no playlist": {
"main": [
[
{
"node": "Create Downloads Playlist",
"type": "main",
"index": 0
}
],
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[
{
"node": "Get Updated Downloads Playlist",
"type": "main",
"index": 0
}
],
[
{
"node": "Add tracks to Downloads",
"type": "main",
"index": 0
}
]
]
},
"Get Liked Tracks": {
"main": [
[
{
"node": "Filter out new tracks",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Globals",
"type": "main",
"index": 0
}
]
]
},
"Get all Playlists": {
"main": [
[
{
"node": "If no playlist",
"type": "main",
"index": 0
}
]
]
},
"Get tracks to remove": {
"main": [
[
{
"node": "Remove oldest tracks from Downloads",
"type": "main",
"index": 0
}
]
]
},
"Filter out new tracks": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Get Downloads Playlist": {
"main": [
[
{
"node": "Get Liked Tracks",
"type": "main",
"index": 0
}
]
]
},
"Add tracks to Downloads": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Create Downloads Playlist": {
"main": [
[
{
"node": "Get all Playlists",
"type": "main",
"index": 0
}
]
]
},
"Filter out Downloads Playlist": {
"main": [
[
{
"node": "Get Downloads Playlist",
"type": "main",
"index": 0
}
]
]
},
"Get Updated Downloads Playlist": {
"main": [
[
{
"node": "Get tracks to remove",
"type": "main",
"index": 0
}
]
]
},
"If no Downloads Playlist found": {
"main": [
[
{
"node": "Create Downloads Playlist",
"type": "main",
"index": 0
}
],
[
{
"node": "Split Out",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 其他
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
实时Notion Todoist双向同步模板
使用Redis的Notion Todoist实时双向同步
If
Set
Code
+26
246 节点Mario
销售
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他
使用AI汇总Slack频道活动生成周报
使用AI汇总Slack频道活动生成周报
If
Set
Code
+13
47 节点Jimleuk
其他
AI 代理餐厅 [模板]
🤖 WhatsApp、Instagram 和 Messenger 的 AI 餐厅助手
If
N8n
Set
+37
239 节点Amanda Benks
其他
Clockify 备份模板
基于月度报告将 Clockify 备份到 Github
If
Set
Filter
+9
21 节点Mario
其他
工作流导入器
使用多表单导入工作流并映射其凭据
If
N8n
Set
+15
58 节点Mario
其他
工作流信息
难度等级
高级
节点数量23
分类1
节点类型10
作者
Mario
@octionicWorkflow Optimization Expert | Software Architect. Use my link to book an initial consultation for custom built workflows using n8n.
外部链接
在 n8n.io 查看 →
分享此工作流