Files
n8n-backup-v2/workflows/kubWVFN16Jar4v4Q.json
2026-01-02 22:48:32 +00:00

127 lines
3.8 KiB
JSON

{
"id": "kubWVFN16Jar4v4Q",
"name": "Audiobook Notification Router",
"nodes": [
{
"parameters": {},
"id": "workflow-trigger",
"name": "Execute Workflow Trigger",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"typeVersion": 1.1,
"position": [
100,
300
]
},
{
"parameters": {
"operation": "send",
"sendTo": "admin@ben.io",
"subject": "={{ $json.emailSubject }}",
"message": "={{ $json.emailHtmlBody }}",
"options": {}
},
"id": "send-gmail",
"name": "Send Gmail",
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
700,
200
],
"credentials": {
"gmailOAuth2": {
"id": "Os1ux3h3zFlC2XkG",
"name": "Gmail account"
}
}
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "status",
"name": "status",
"value": "sent",
"type": "string"
}
]
}
},
"id": "return-status",
"name": "Return Status",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
900,
200
]
},
{
"id": "685a8518-fcbf-4a0c-84d0-3ab4dacb61a4",
"name": "Build Email HTML (Item)",
"type": "n8n-nodes-base.functionItem",
"typeVersion": 1,
"position": [
500,
200
],
"parameters": {
"functionCode": "const torrentCount = Number($json.torrent_count) || 0;\nconst torrents = Array.isArray($json.torrents) ? $json.torrents : [];\n\nfunction getMAMStatus(t) {\n return t.mam_torrent_id\n ? `✅ <a href=\"https://www.myanonamouse.net/t/${t.mam_torrent_id}\">Yes</a>`\n : '❌ No';\n}\n\nconst rows = torrents.length\n ? torrents.map(t => `\n <tr>\n <td>${t.title || ''}</td>\n <td>${t.seeders ?? ''}</td>\n <td>${t.size || ''}</td>\n <td>${getMAMStatus(t)}</td>\n <td>${t.link ? `<a href=\"${t.link}\">Download</a>` : ''}</td>\n </tr>\n `).join('')\n : '<tr><td colspan=\"5\">No torrents this run</td></tr>';\n\nconst emailHtmlBody = `\n <h2>${torrentCount} New Audiobook Torrent(s) Found</h2>\n <table border=\"1\" cellpadding=\"8\" cellspacing=\"0\" style=\"border-collapse: collapse;\">\n <thead>\n <tr>\n <th>Title</th>\n <th>Seeders</th>\n <th>Size</th>\n <th>On MAM?</th>\n <th>Links</th>\n </tr>\n </thead>\n <tbody>\n ${rows}\n </tbody>\n </table>\n`;\n\nreturn {\n emailSubject: `${torrentCount} New Audiobook Torrent(s) Found`,\n emailHtmlBody,\n torrentCount,\n};"
}
}
],
"connections": {
"Send Gmail": {
"main": [
[
{
"node": "Return Status",
"type": "main",
"index": 0
}
]
]
},
"Execute Workflow Trigger": {
"main": [
[
{
"node": "Build Email HTML (Item)",
"type": "main",
"index": 0
}
]
]
},
"Build Email HTML (Item)": {
"main": [
[
{
"node": "Send Gmail",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"saveExecutionProgress": true,
"saveManualExecutions": true,
"saveDataErrorExecution": "all",
"saveDataSuccessExecution": "all",
"executionOrder": "v1"
},
"triggerCount": 0,
"versionId": "8496ee58-493a-4604-bba1-e06c5b27879a",
"owner": {
"type": "personal",
"projectId": "FeLO36wNUAcn61Wj",
"projectName": "Ben W <admin@ben.io>",
"personalEmail": "admin@ben.io"
},
"parentFolderId": "kUg4HIPXraph3M0E",
"isArchived": false
}