{ "id": "kn1gehxiWbkRfDFFAKx0x", "name": "MAM Check for Completed", "nodes": [ { "parameters": { "rule": { "interval": [ { "field": "hours" } ] } }, "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.3, "position": [ -512, -16 ], "id": "e621dd75-f5c0-48e6-816c-15f22fb500ba", "name": "Schedule Trigger" }, { "parameters": { "workflowId": { "__rl": true, "value": "NChjOd3ILEmt0FdyAt8qA", "mode": "list", "cachedResultUrl": "/workflow/NChjOd3ILEmt0FdyAt8qA", "cachedResultName": "Transmission: Get Session" }, "workflowInputs": { "mappingMode": "defineBelow", "value": { "server_id": "seed-1.dfw.ben.io" }, "matchingColumns": [ "server_id" ], "schema": [ { "id": "server_id", "displayName": "server_id", "required": false, "defaultMatch": false, "display": true, "canBeUsedToMatch": true, "type": "string", "removed": false } ], "attemptToConvertTypes": false, "convertFieldsToString": true }, "options": {} }, "type": "n8n-nodes-base.executeWorkflow", "typeVersion": 1.3, "position": [ -304, -16 ], "id": "10e82b7b-fdc4-4d95-a5e7-4df97bb700f7", "name": "Call 'Transmission: Get Session'" }, { "parameters": { "method": "POST", "url": "http://seed-1.dfw.ben.io:9091/transmission/rpc", "authentication": "genericCredentialType", "genericAuthType": "httpBasicAuth", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "X-Transmission-Session-Id", "value": "={{ $json.session_id }}" } ] }, "sendBody": true, "specifyBody": "json", "jsonBody": "{\n \"method\": \"torrent-get\",\n \"arguments\": {\n \"fields\": [\n \"id\",\n \"name\",\n \"hashString\",\n \"percentDone\",\n \"isFinished\",\n \"downloadDir\",\n \"addedDate\" \n ]\n }\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.3, "position": [ -96, -16 ], "id": "c49a3e03-7fab-43d7-a430-4cbaa089ca2c", "name": "HTTP Request", "credentials": { "httpBasicAuth": { "id": "iymUPilnVhfL3h5D", "name": "transmission" } } }, { "parameters": { "language": "pythonNative", "pythonCode": "import time\n\n# Output list\nresults = []\n\n# Define your time window (2 hours in seconds to match your node name)\n# 2 * 60 * 60 = 7200\nTIME_WINDOW = 2 * 60 * 60\ncurrent_time = time.time()\n\n# 1. Get the list of torrents from the HTTP response\ninput_data = _items[0]['json']\ntorrents = input_data.get('arguments', {}).get('torrents', [])\n\nfor torrent in torrents:\n # 2. Check if download is 100% complete (1.0)\n is_downloaded = torrent.get('percentDone') == 1\n \n # 3. Filter Logic (Check if added recently)\n added_date = torrent.get('addedDate', 0)\n age_in_seconds = current_time - added_date\n \n # Optional: Uncomment this if you ALSO only want completed items\n # is_complete = torrent.get('percentDone') == 1\n\n if age_in_seconds <= TIME_WINDOW: # and is_complete:\n # 4. Return the FULL object\n # We pass the entire 'torrent' dictionary directly\n results.append({\n \"json\": torrent\n })\n\nreturn results" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 112, -16 ], "id": "18ad2b6e-824b-4fac-8924-ddbf35f45579", "name": "Filter for last 2 hours" }, { "parameters": { "operation": "select", "schema": { "__rl": true, "value": "public", "mode": "list", "cachedResultName": "public" }, "table": { "__rl": true, "value": "smb_general_books", "mode": "list", "cachedResultName": "smb_general_books" }, "where": { "values": [ {} ] }, "options": {} }, "type": "n8n-nodes-base.postgres", "typeVersion": 2.6, "position": [ 384, -112 ], "id": "0fa625e2-3e86-4abe-a837-f876d2d08f10", "name": "Select rows from a table", "credentials": { "postgres": { "id": "9grzZwW7Br6SzdV8", "name": "n8n-media" } } } ], "connections": { "Schedule Trigger": { "main": [ [ { "node": "Call 'Transmission: Get Session'", "type": "main", "index": 0 } ] ] }, "Call 'Transmission: Get Session'": { "main": [ [ { "node": "HTTP Request", "type": "main", "index": 0 } ] ] }, "HTTP Request": { "main": [ [ { "node": "Filter for last 2 hours", "type": "main", "index": 0 } ] ] }, "Filter for last 2 hours": { "main": [ [] ] } }, "settings": { "executionOrder": "v1", "availableInMCP": false }, "triggerCount": 0, "versionId": "26ae4972-43fe-4776-b2ed-af9f7c88aa42", "owner": { "type": "personal", "projectId": "FeLO36wNUAcn61Wj", "projectName": "Ben W ", "personalEmail": "admin@ben.io" }, "parentFolderId": "6tDyZCwqELStb6Ik", "isArchived": false }