8
n8n 中文网amn8n.com

基于质量和语言筛选的自动化Sonarr缺失剧集查找器

中级

这是一个Personal Productivity领域的自动化工作流,包含 10 个节点。主要使用 If, Set, Code, SplitOut, HttpRequest 等节点。 带质量和语言筛选的自动化Sonarr缺失剧集查找器

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "524db9d6f45a6821f11407ee382e8ef798434d93ef64e0c8c3a108540b9322a6"
  },
  "nodes": [
    {
      "id": "b7575322-a8cd-48b1-8989-59e8c10f3fb3",
      "name": "信息",
      "type": "n8n-nodes-base.set",
      "position": [
        -220,
        100
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "e03dba6d-c6c4-407b-b65b-15aacb8a4a32",
              "name": "urlSonar",
              "type": "string",
              "value": "http://192.168.31.204:8989"
            },
            {
              "id": "976f2fe4-2d27-43f7-8fba-5f992ab0894e",
              "name": "apikey",
              "type": "string",
              "value": "j7oi8oiji7yih85765tg646ghft6ffd6"
            },
            {
              "id": "00cdb214-7b97-4037-aca9-36569403b340",
              "name": "quality",
              "type": "string",
              "value": "WEBDL-1080p"
            },
            {
              "id": "01c442c9-3ecb-43b1-a112-3cd41c62b232",
              "name": "languages",
              "type": "string",
              "value": "Portuguese (Brazil)"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "bdd74c08-4891-4c55-81a6-1da3c72e8ef5",
      "name": "编辑字段",
      "type": "n8n-nodes-base.set",
      "position": [
        220,
        100
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "598bf523-e5f2-4976-9b66-35e2918d9bdd",
              "name": "records",
              "type": "array",
              "value": "={{ $json.records }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8b898b4a-8a53-48cc-8917-2c406e64c95f",
      "name": "拆分输出",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        440,
        100
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "records"
      },
      "typeVersion": 1
    },
    {
      "id": "117443a3-7a83-4c50-a4af-693c11dd6e3c",
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -440,
        100
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 12
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "55253fdd-9f78-428d-8fd4-d5f4b74c78ef",
      "name": "覆盖并添加到下载队列",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "maxTries": 3,
      "position": [
        1100,
        -100
      ],
      "parameters": {
        "url": "={{ $('info').item.json.urlSonar }}/api/v3/release",
        "method": "POST",
        "options": {},
        "jsonBody": "={{ \n  JSON.stringify({\n    indexerId: $('Loop Over Items').item.json.indexerId,\n    guid: $('Loop Over Items').item.json.guid,\n    seriesId: $('Loop Over Items').item.json.mappedSeriesId,\n    episodeIds: $('Loop Over Items').item.json.mappedEpisodeInfo.map(e => e.id),\n    quality: {\n      quality: {\n        id: $('Loop Over Items').item.json.quality.quality.id,\n        name: $('Loop Over Items').item.json.quality.quality.name,\n        source: $('Loop Over Items').item.json.quality.quality.source,\n        resolution: $('Loop Over Items').item.json.quality.quality.resolution\n      },\n      revision: {\n        version: $('Loop Over Items').item.json.quality.revision.version,\n        real: $('Loop Over Items').item.json.quality.revision.real,\n        isRepack: $('Loop Over Items').item.json.quality.revision.isRepack\n      }\n    },\n    languages: [\n      {\n        id: $('Loop Over Items').item.json.languages[0].id,\n        name: $('Loop Over Items').item.json.languages[0].name\n      }\n    ],\n    downloadClientId: null,\n    shouldOverride: true\n  })\n}}\n",
        "sendBody": true,
        "sendQuery": true,
        "specifyBody": "json",
        "queryParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "={{ $('info').item.json.apikey }}"
            },
            {}
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "alwaysOutputData": false
    },
    {
      "id": "da00208f-c5f7-4276-8c66-af5566e387ad",
      "name": "本季所有剧集的交互式搜索",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1100,
        100
      ],
      "parameters": {
        "url": "={{ $('info').item.json.urlSonar }}/api/v3/release",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "seriesId",
              "value": "={{ $('Split Out').item.json.seriesId }}"
            },
            {
              "name": "seasonNumber",
              "value": "={{ $('Split Out').item.json.seasonNumber }}"
            },
            {
              "name": "apikey",
              "value": "={{ $('info').item.json.apikey }}"
            }
          ]
        }
      },
      "executeOnce": true,
      "notesInFlow": false,
      "typeVersion": 4.2
    },
    {
      "id": "df7c8bf5-ecc7-4af7-8668-6c47cc86bdf9",
      "name": "检查缺失剧集",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        0,
        100
      ],
      "parameters": {
        "url": "={{ $('info').item.json.urlSonar }}/api/v3/wanted/missing",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "page",
              "value": "1"
            },
            {
              "name": "pageSize",
              "value": "100"
            },
            {
              "name": "sortDirection",
              "value": "descending"
            },
            {
              "name": "includeSeries",
              "value": "false"
            },
            {
              "name": "includeImages",
              "value": "false"
            },
            {
              "name": "monitored",
              "value": "true"
            },
            {
              "name": "apikey",
              "value": "={{ $('info').item.json.apikey }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "accept",
              "value": "application/json"
            }
          ]
        }
      },
      "executeOnce": false,
      "typeVersion": 4.2
    },
    {
      "id": "971e172b-1961-41b3-ad0b-0936e7a2c591",
      "name": "验证质量和语言匹配",
      "type": "n8n-nodes-base.if",
      "position": [
        1320,
        175
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "faa46e5b-40ef-4200-9827-50e7d7666f24",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.quality.quality.name }}",
              "rightValue": "={{ $('info').item.json.quality }}"
            },
            {
              "id": "6caeb8cc-f152-497b-9f6b-4a6526c3df00",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.languages[0].name }}",
              "rightValue": "={{ $('info').item.json.languages }}"
            }
          ]
        }
      },
      "executeOnce": false,
      "typeVersion": 2.2
    },
    {
      "id": "7ef44e0f-65a9-4579-9599-de626165d022",
      "name": "筛选系列",
      "type": "n8n-nodes-base.code",
      "position": [
        660,
        100
      ],
      "parameters": {
        "jsCode": "const seenSeasons = new Set();\nconst uniqueItems = [];\n\nfor (const item of $input.all()) {\n  const key = `${item.json.seriesId}-${item.json.seasonNumber}`;\n\n  if (!seenSeasons.has(key)) {\n    item.json.myNewField = 1;\n    uniqueItems.push(item);\n    seenSeasons.add(key);\n  }\n}\n\nuniqueItems.sort((a, b) => {\n  if (a.json.seriesId !== b.json.seriesId) {\n    return a.json.seriesId - b.json.seriesId;\n  }\n  return a.json.seasonNumber - b.json.seasonNumber;\n});\n\nreturn uniqueItems;"
      },
      "typeVersion": 2
    },
    {
      "id": "3bf70dc2-c110-44b8-a9b1-59c3f8ce7e01",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        880,
        100
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    }
  ],
  "pinData": {},
  "connections": {
    "info": {
      "main": [
        [
          {
            "node": "Check for Missing Episodes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Filter Series",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Series": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Override and add to download queue",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Interactive search for all episodes in this season",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check for Missing Episodes": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Override and add to download queue": {
      "main": [
        [],
        []
      ]
    },
    "Validate Quality and Language Match": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Interactive search for all episodes in this season": {
      "main": [
        [
          {
            "node": "Validate Quality and Language Match",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 个人效率

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量10
分类1
节点类型7
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

外部链接
在 n8n.io 查看

分享此工作流